
[ad_1]
I’m making an attempt to unravel an issue involving Quaternions and 3D rotation.
I’m utilizing a video games engine (Torque 3D) for a challenge that I’m creating. I’ve modified the gravity system in order that the participant is pulled in three dimensions in direction of a central level (the middle of a spherical world).
I would really like the participant to additionally flip in order that their toes are going through this central level, no matter their place or preliminary orientation. I would like the participant to have the ability to stand on the spherical world, and at present, despite the fact that they’re being pulled to the middle of the world accurately, the orientation would not change.
The orientation is held in a Quaternion known as “mOrient”.
I do know that the answer will contain rotation matrices, and possibly world/native house translations, however I’m not certain the right way to put all this collectively.
I’m at present making an attempt this, unsuccessfully:
Assume (0,0,0) is the middle level, getPosition() is the place of the participant.
mOrient is the gamers 3D rotation quaternion, that is what I want to vary.
Point3F gravityvec = Point3F(0, 0, 0) - getPosition();
gravityvec.normalize();
QuatF q = QuatF(gravityvec);
mOrient = q;
Does anybody have an answer for this?
I’m programming in C++ inside a video games engine, however Pseudocode can be wonderful, I simply want some help with the mathematical facet.
[ad_2]