O
O
olkeyn2014-07-29 01:56:29
Python
olkeyn, 2014-07-29 01:56:29

Spring physics. How to find the moment of rotation through a quaternion?

Hello. I write a spring simulation using ODE and Panda3D for visualization. With a simple movement, everything is simple: a force is applied in proportion to the distance, a force is subtracted in proportion to the speed, and the body smoothly returns to a given point. If proportional to the speed is not subtracted, the body performs harmonic oscillations in the vicinity of a given point. With rotation and moment it is complete... Neither rotation matrices, nor their derivatives, nor their inverse cosines and inverse sines give a result. At best, the body spins around 0Z, at worst it makes random rotations and flies into space. Doesn't want to stick to the given angle.
The most successful implementation of rotation I have so far takes into account rotation only along 0X and 0Y. We get a quaternion for the body and apply a moment proportional to X or Y. Of course, any deviation around the Z axis entails untwisting and flying into space. If the body does not rotate around Z, the body successfully holds the given angle when external forces are applied.
How to calculate the moment required to rotate in the direction given by the quaternion so that the body adheres to the given angle?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
EndUser, 2014-07-29
@EndUser

Do you mean the inertia tensor? It's not a quaternion.
The thing is tricky (while you understand), but in fact it is completely similar to linear mechanics: just as you get the acceleration vector by dividing the force vector by inertia, you get the angular acceleration vector by dividing the moment of force vector by the inertia tensor. And no left jerking will work - mother nature herself will take care of it (with the correct design of the inertia tensor, of course).

L
lookid, 2014-07-29
@lookid

David Baraff describes this whole thing in his course of lectures:
www.cs.cmu.edu/~baraff/sigcourse/notesd1.pdf
Moment of inertia is a diagonal matrix that is set at the time of body creation. This is a sort of "mass" for rotational movement.

O
olkeyn, 2014-07-29
@olkeyn

In theory, I just need to find out what angle the quaternion forms with the coordinate axes. But how to do it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question