Ideas? I was figuring take the position by delta positionâ€¦ or magnitude of the vector of the direction the car is traveling? I dont know how to do that tho.

Car.Chassis.Body.Velocity

Actually, if you want a "speedometer" then you want to do the dot of the Velocity with the "forward" vector, because sideways velocity shouldn't count.

If I do that, I get weird speeds if I'm sitting still and turn the wheels. Plus at a dead stop, for some reason its never exactly 0â€¦

Anyway, I'm trying to calculate slip angle and slip ratio Can someone check my code to make sure I'm doing my math right or see ways of optimization? I basically need forward and sideways velocities and the yaw of the car to derive slip angle. Slip ratio is just the difference between the speed (hence the speedometer) and (from what I can tell) the rim velocity.

Vector3 unitFwdVec = carObject.Car.Chassis.Body.Orientation.Forward;

Vector3 unitDirVec = carObject.Car.Chassis.Body.Velocity;

unitFwdVec.Normalize();

unitDirVec.Normalize();

double xVel = carObject.Car.Chassis.Body.Velocity.X;

double zVel = carObject.Car.Chassis.Body.Velocity.Z;

//double latVel = Vector3.Dot(carObject.Car.Chassis.Body.Velocity, carObject.Car.Chassis.Body.Orientation.Left);

//double longVel = Vector3.Dot(carObject.Car.Chassis.Body.Velocity, unitFwdVec);

double yaw = Math.Acos(Vector3.Dot(unitFwdVec, unitDirVec));

double carSin = Math.Sin(yaw);

double carCos = Math.Cos(yaw);

double latVel = ((xVel * carCos) + (zVel * carSin));

double longVel = ((xVel * (-carSin)) + (zVel * carCos));

float slipAngle = Math.Atan2(latVel, longVel);

Edit: Apparently my way of finding yaw is skewed (lol). The best way to get a euler angle out of a rotation matrix is Atan2(two points in the matrix). Which two. I have yet to figure out.

Some sources say M23, M33. Racer uses M31, M33. Other places say M23, M13. *sigh* guess ill try them out to find which is the number I want.

Depends on whether you're using Y-up, Z-up, or Z-down (the three most common conventions in physical simulation).

XNA uses Y-up. A lot of gaming types use Z-up. Mil/Sim types often use Z-down.

Yea, I'm still trying to find yaw. the unit vec method successfully got me no where. using the orientation matrix didn't seem to help since I'm pulling info out of orientation, which has no info on the vector of where the car is traveling.

Here is my best try so far (im at work so I cant try it):

double yaw2 = Math.Acos((Vector3.Dot(unitFwdVec, carObject.Car.Chassis.Body.Velocity)) / (carObject.Car.Chassis.Body.Velocity.Length()));

Thats based on the fact that theta = ArcCos(Dot(A,B)/(|A||B|))

http://upload.wikimedia.org/math/f/5/8/f587371bc1b7d0819c76900eda99656a.png basically

If I make them unit vectors. I can drop out the bottom of the equation but I dont know if that will skew results. I guess I have to wait to get home to try it. Thanks for the help!

Edit: I just had an epiphany!

The side velocity of the car is Vector3.Dot(Car.Velocity, Car.Orientation.Left)

Forward is the same but .forward

and the slip angle is Atan2(SideVel, fwdVel)!