27.11.2013, 18:15
(
Последний раз редактировалось Dragonsaurus; 28.11.2013 в 12:29.
)
Quote:
No, I mean spinning the car. So instead of drifting you end up going backwards (like a reverse J-turn).
|
Let's say the vehicle's heading angle (The one generated from the velocity vectors) is 0 degrees, so the vehicle is heading north.
1) When going straight, drift angle is 0.
2) When the facing angle is acute to the heading angle (0 < angle < 90 or 270 < angle < 360), the vehicle's drift will be 0 < drift < 90 degrees.
3) When the facing angle is perpendicular to the heading angle (90 or -90 degrees), the vehicle's drift is 90 degrees.
4) When the facing angle is obtuse according to the heading angle, which means the vehicle is going backwards with some angle (0 < angle < 90 or 270 < angle < 360) the theoretical angle would be 90 < drift < 180 degrees (?!?!). In this case the real drift should be decreading after the facing angle reaches 90 degrees.
That's what these lines do:
pawn Код:
a[2] = (a[2] > 180.0) ? (floatsub(a[2], 180.0)) : (a[2]);
return (a[2] >= 90.0) ? (floatsub(180.0, a[2])) : (a[2]);
But the vehicle's not drifting. So the lines above take case of this issue.
Basically:
1) Drift is 0.
2) Drift increases.
2) Drift reaches the max value.
4) Drift decreases.
5) Drift is again 0.
J-turn: Starts from 0 drift, continues to 90 (When the facing angle is perpendicular to the heading angle), decreases when the angle is > 90 and turns back to 0, when the difference between facing angle and heading angle is 180 degrees.
Same logic if the car continues to spin until reaches back to it's first stage (Facing angle = heading angle).
I hope I cleared something with this reply