Convert Global Velocity to Local Velocity
by Demolishun · in Torque Game Engine · 10/22/2005 (1:11 pm) · 6 replies
Sorry, that is my head hitting the table a few times. This problem is driving me nuts. Here is my question:
Is there an way to convert the mRigid.linVelocity to vehicle local x, y , z velocities?
I am trying to rewrite the wheeledVehicle code to use "cheater" physics and need to be able to treat linear and rotational velocities with respect to the vehicle and not the world. I have messed with transforms and the like, but came to conclusion that I need to use the vehicle rotation somehow and not the vehicle position.
Thanks,
Frank Carney
P.S. I did not post in the public physics section because I expect to post engine code.
About the author
I love programming, I love programming things that go click, whirr, boom. For organized T3D Links visit: http://demolishun.com/?page_id=67
#2
10/22/2005 (3:24 pm)
Great! I will look into it.
#3
Note: The "vel" has to be a VectorF of default value, a Point3F will NOT work. Must be the way it is initialized.
DOH! Okay, it can be a Point3F since in mPoint.h:
Thanks, this dang engine is full of everything! Now I need to test this on a rotational velocity.
Stay tuned,
Frank
10/22/2005 (3:41 pm)
Here is how you do it:VectorF vel; mWorldToObj.mulV(mRigid.linVelocity,&vel);
Note: The "vel" has to be a VectorF of default value, a Point3F will NOT work. Must be the way it is initialized.
DOH! Okay, it can be a Point3F since in mPoint.h:
typedef Point3F VectorF;
Thanks, this dang engine is full of everything! Now I need to test this on a rotational velocity.
Stay tuned,
Frank
#4
10/22/2005 (5:08 pm)
I would suspect (haven't checked) that overloading will mean that you can't do a Point3FVariable->len(), which returns the magnitude of the vector. There are probably a few other minor aspects that a VectorF gives you that a Point3F doesn't.
#5
10/22/2005 (9:04 pm)
You can do Point3F->len()... they are really the exact same thing... I rarely use VectorF...
#6
In regards to the original topic, I'd like to point out that while there's no difference between a Point3F and a VectorF, there is a difference between MatrixF::mulP (typically for rotating and translating points) and MatrixF::mulV (typically for rotating vectors; note the lack of translation).
10/23/2005 (12:05 am)
It's not overloading. Think of it instead as an alias. VectorF is another name for Point3F. Use either, as they are completely interchangeable. I use VectorF when the values represent a vector, and Point3F when they represent a point. eg: VectorF myVelocity v.s. Point3F myPosition. Just makes the code read better, in my opinion.In regards to the original topic, I'd like to point out that while there's no difference between a Point3F and a VectorF, there is a difference between MatrixF::mulP (typically for rotating and translating points) and MatrixF::mulV (typically for rotating vectors; note the lack of translation).
Torque 3D Owner Stephen Zepp
There isn't much documentation on how exactly they get used, but I'm working on it!