如何模拟转弯半径

时间:2012-12-22 14:43:40

标签: physics game-physics

您好我试图模拟绕半径转弯的车辆。这就是我目前正在做的事情

  1. 计算转弯半径。
  2. 计算加速度并增加速度。
  3. 使用速度幅度来确定一次更新中的行进距离。
  4. 使用arctan( distanceTraveled / turnRadius )获取旋转角度。
  5. 更新车辆角度。
  6. 按车辆角度旋转速度。例如velocity *= Quaternion.AngleAxis(angle, Vector3.up)
  7. 以速度更新车辆位置。
  8. 我目前正在大量漂移而不是直接开车。任何想法如何正确实现这个?

2 个答案:

答案 0 :(得分: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

听起来很合理。

答案 1 :(得分: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