0

嗨,我试图模拟车辆绕一个半径转弯。这就是我目前正在做的

  1. 计算转弯半径。
  2. 计算加速度并添加到速度。
  3. 使用速度大小来确定一次更新中行进的距离。
  4. 用于arctan( distanceTraveled / turnRadius )获取旋转角度。
  5. 更新车辆角度。
  6. 通过车辆角度旋转速度。例如velocity *= Quaternion.AngleAxis(angle, Vector3.up)
  7. 用速度更新车辆位置。

我目前漂移很多,不能直行。任何想法如何正确实现这一点?

4

2 回答 2

0
1. You want to calculate the radius of the turn, what do you know to calculate it?

2. You can calculate the acceleration by the formula: a = v²/r , here is v the velocity of the rotating object, r is the radius.

3. The distance is just the velocity times the time travelled.

4. The angle of rotation can be calculated by:

   the "travelled" angle per second = w = 2*pi*revelotions per second "n"
         w= 2*pi*n
w*t="travelled" angle = angle
angle = 2*pi*n*t

we also know that= v = 2*pi*r*n  n=v/(2*pi*r)
You can put that in the formulo for the angle in function of the velocity.

5. I think it is answerred in 4.

6. you have to use sin and cosine to calculate the components of the velocity on every axis. If you know what derivatives are you can use them to calculate the tangence line on the circle where the object moves on. The velocity is in the same direction of the tangence line.


Hope this helped
于 2012-12-27T17:34:41.543 回答
0
1. Calculate the radius of the turn.
2. Calculate acceleration and add to velocity.
3. Use velocity magnitude to determine distance travelled in one update.

到目前为止,一切都很好。

4. Use arctan( distanceTraveled / turnRadius ) to get the angle of rotation.

坚持,稍等。首先,这与第 2 步冲突。要么您使用加速度来产生转弯,要么您正在使用圆的几何形状来强制转弯。如果你试图混合这些,你充其量只会漂移。其次,你不应该在这里使用 arctan,它只是 angle=(distanceTraveled/radius)。

5. Update vehicle angle.

您是否分别跟踪方位和态度?也就是说,你能模拟一辆侧滑的汽车吗?或者您是否假设汽车指向它正在移动的方向?如果是后者,那么您将保留相同信息的冗余副本,这会引起错误。

6. Rotate velocity by vehicle angle. e.g. velocity *= Quaternion.AngleAxis(angle, Vector3.up).

如果您正确执行了第 2 步,则第 2 步应该已经涵盖了这一点。

7. Update vehicle position with velocity

听起来很合理。

于 2012-12-23T10:21:25.203 回答