#### Archived

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

# physics - rotational velocity

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

## Recommended Posts

arg! I'm having problems implenting rotational velocity in my code - i know it's a physics question, but this forum has been really helpful in the past so here goes. I'm currently trying to implement 2D rotational velocities - the setting at the moment is a vehicle that i want to turn around a corner. i have based a lot of my code on the (lesson 39?) tutorial on physics, so am hence using the Euler method to solve my equations. I'm not sure if the results I'm getting are due to the timestep I'm using, as I know the Euler method gets a bit hairy at large timesteps, or just my equations - so I thought i'd give you an outline of my forces etc that I'm applying first, and see if anyone has any suggestions. As I'm not sure that I've got my friction forces right I don't know if the oscillations etc that I'm getting are because these are wrong, or like i said, due to the euler method. right - so far i get an angular velocity as follows-> Thrust is a vector that provides the linear motion, which seems to work well. I take the cross product of that and a vector from the center of mass to the wheels. I figure this is the torque. I divide this by the a constant ( i know in true 3d rotation i'd have an inertia matrix, but i just scale the torque vector down as i'm only concerned with rotation about the y axis) and multiply by dt to get the angular velocity. then the rotation theta is the length of that multiplied by dt again. I then rotate by theta about the angular velocity vector - in psuedo code: Vtorque= cross(Vthrust,Vdistance) Vrotvelocity = (Vtorque/(mass/2))*dt STheta = Vrotvelocity.length * dt I'm using a mass of 200, a dt of 0.0001, and thrust is limited to 500. I iterate the above three steps (plus other forces) 100 times before drawing anything. As I have no gravity ( no collision detection yet) I've tried a few forces to damp the angular velocity but nothing seems to work. at the moment i'm taking the cross product of the angular velocity with the distance vector mentioned above, unitizing it and multiplying by the length of Vrotvelocity, but it's all pretty arbitrary. Does anyone have any ideas from looking at that post as is? I hope I've been fairly clear - it's hard to describe the results i'm getting as they are so erratic. they do usually seem ok when the angular velocity is small tho, but start to go mental (ie increasing angular velocities when no force applied) when things are moving faster. I'd really appreciate any help you can offer - I have been working on this for last 3 days so I have tried to sort it myself! Cheers lads! [edited by - coke_baby on November 10, 2003 4:08:13 PM]

##### Share on other sites
Vrotvelocity = (Vtorque/(mass/2))*dt should actually be
Vrotvelocity += (Vtorque/(mass/2))*dt due to integration - torque*time becomes angular acceleration, acceleration*time provides only the change in velocity over dt, not the total velocity. This will prevent massive velocity changes which you seem to be describing

Aside from that, it looks good

##### Share on other sites
sorry, i do use += for both theta and Vrotvelocity, my mistake.
will keep trying..
EDIT
I suppose I can add that one of the worst problems is that when everything seems to be going fine, the orientation of the vehicle will suddenly 'snap' to a different position - (rotation wise) - even though there is no apparent sudden change in angular velocity (which i am writing with other info as debug, to screen)
I've already fixed one problem, that being that i wasn't adjusting the distance from the center of mass to the wheels properly as the vehicle rotated, which has stablised things a bit.

[edited by - coke_baby on November 10, 2003 5:45:37 PM]

##### Share on other sites
in case anyone''s interested, my oscillations were due to the way i was rotating the car - i was using the angular velocity vector as my axis of rotation, so when it changed direction (ie the angular velocity passed through zero), the car was getting rotated in the opposite direction - say it''s ''angle of attack'' was +35, and the angular velocity changed from +ve to -ve, then the new angle of attack would be -(35 + change in theta) instead of (35-change in theta).
if that makes sense. so i''m checking the direction of the angular velocity vector now and making allowances for that. not so elegant, but it works.
hopefully this will be of use to someone else!

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 10
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632922
• Total Posts
3009225
• ### Who's Online (See full list)

There are no registered users currently online

×