Archived

This topic is now archived and is closed to further replies.

Accelerating and Rotating

This topic is 5129 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have a simple car that can speed up, slow down and turn left and right. I don''t know how to handle with incorrect rotation when I increase the velocity. When I speed up the radius of the circle that the car is moving along start to increase. I calculate the new position of the car with: position.x += (float)(velocity.x*cos(DEG2RAD(yRot))); position.z += (float)((-velocity.z)*(sin(DEG2RAD(yRot)))); glTranslatef(position.x, 0.0f, position.z); glRotatef(yRot, 0.0f, 1.0f, 0.0f); I would be grateful for any replies. Regards!

Share this post


Link to post
Share on other sites
myeh... if your rotational velocity is constant, when your car speeds up its gonna go in larger circles... if you wanna have the same circle radius then you have to make your rotational velocity proportional to the speed of the car...

Share this post


Link to post
Share on other sites
Thanks for all relpies.

I thought that something was wrong because it looks a little bit abnormal. But I guess, if the whole car physics was added, it would look much better.

Share this post


Link to post
Share on other sites
you may want to limit how fast the car is turning, or its linear velocity, depending on the car grip.

Generaly, the acceleration the car can take is in relation with the force acting down on the car, meaning, the gravity.

so acceleration shouls always be < gravity * grip.

in your case, V = r.W (linear velocity equal radius of turn times angular velocity). So, if the velocity increases, and the angular velocity stays the same, the radius will increase.

so,
V = r.W
amax = Vmax² / r

=> amax = W².r
=> r = amax / W²
so

Vmax = amax . W
Vmax = (gravity . grip).W

you turn at constant speed, the maximum linear velocity the car can take is then amax . W, so you can limit the velocity of the car that way.

equaly, Wmax = V / amax, so you can also limit the truning radius of the car like that. you can use the exceedent and play a skidding sound or something.

also, the radius of turn in the case the car is coasting around a circle in a constant linear and angular velocity is

r = wheelbase / sin(steering_angle)

for example, you can therefore calculate the minimum turning radius, using the maximum steering_angle. wheelbase = 3 meters, mas angle = 30 degrees, turning radius = 6 meters.

Share this post


Link to post
Share on other sites
Hi,

thanks for yor explanation but I''m not sure if I understand everything.

amax - is the maximum acceleration ?
W - is the angle ? In my case yRot, right ??


Share this post


Link to post
Share on other sites