找回密码
 欢迎注册
查看: 3131|回复: 4

[求助] ORCA避障算法中,判断小球是否会碰撞的疑惑

[复制链接]
发表于 2021-11-9 20:35:14 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?欢迎注册

×
算法的背景是,球A B在平面上运动,已知A B当前速度与位置。如何判断检测时间T后,两球是否碰撞

网上有文章介绍改算法。下面是摘抄的截图
原文在:https://stackoverflow.com/questi ... runcated-cone-in-3d
参考:https://zhuanlan.zhihu.com/p/74888471

XM4Dz.png   
TF5Z2.png
klbZu.png

其中有段算法 不太明白,期望大神解惑

  1.     const Vector3 relativePosition = other->position_ - position_;                        //相对位置
  2.     const Vector3 relativeVelocity = velocity_ - other->velocity_;                        //相对速度
  3.     const float distSq = absSq(relativePosition);                                                //相对距离的平方
  4.     const float combinedRadius = radius_ + other->radius_;                                //合并半径
  5.     const float combinedRadiusSq = sqr(combinedRadius);                                //半径平方

  6.     Plane plane;
  7.     Vector3 u;

  8.     if (distSq > combinedRadiusSq) {
  9.         /* No collision. */
  10.         const Vector3 w = relativeVelocity - tau * relativePosition;
  11.         /* Vector from cutoff center to relative velocity. */
  12.         const float wLengthSq = absSq(w);

  13.         const float dotProduct = w * relativePosition;

  14.         if (dotProduct < 0.0f && sqr(dotProduct) > combinedRadiusSq * wLengthSq) {        // 第二个条件不明白   文章有解释:dotProduct = sqrt(wLengthSq) * |P| * cos(psi) and |P| * cos(pi/2 - phi) = combinedRadius then cos(psi)^2 > cos(pi/2 - phi)^2  没看懂
  15.             /* Project on cut-off circle. */                                                                               
  16.             const float wLength = std::sqrt(wLengthSq);
  17.             const Vector3 unitW = w / wLength;

  18.             plane.normal = unitW;
  19.             u = (combinedRadius * tau - wLength) * unitW;
  20.         }
  21.         else {
  22.         }
  23.     }
复制代码
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2021-11-9 22:46:14 | 显示全部楼层
二球心距离大于两半径之和就不会碰撞。碰撞检测。
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2021-11-9 22:48:07 | 显示全部楼层
做过空间多粒子布朗运动的模拟,做凸多面体的碰撞检测用到闵可夫斯基和。
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2021-11-14 17:27:37 | 显示全部楼层
这个问题能解决讨论的人不会很多,有门槛的。
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2021-11-14 17:28:21 | 显示全部楼层
在自动泊车系统里这是关键算法
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

小黑屋|手机版|数学研发网 ( 苏ICP备07505100号 )

GMT+8, 2024-4-26 11:34 , Processed in 0.062881 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表