# Physics of the spring. How to find the point of rotation using a quaternion?

Hello. Write a simulation of a spring with ODE and Panda3D for rendering. With a simple movement it's simple: the force is applied proportional to the distance is subtracted, the force is proportional to speed and the body gradually returns to a given point. If proportional speed read, the body performs harmonic oscillations in the vicinity of a given point. With the rotation and the moment... Neither rotation matrices nor their derivatives, or their arccosine and arctinus no result. In the best case, the body spins around 0Z in the worst does random spins and flies into space. To keep the specified angle, do not want in any.

The successful implementation of the rotation I don't consider the rotation only 0X and 0Y. The body get quarternion and make every moment proportional to X or Y. of course any deviation around the Z axis leads to the unwinding and space flight. If the body does not rotate around Z, the body successfully holds a specified angle after applying external forces.

How to calculate the torque necessary to rotate in the direction specified by the quaternion, the body adhered to a given angle?
September 26th 19 at 06:47
September 26th 19 at 06:49
You mean the inertia tensor? This is not a quaternion.
Thing catchy (yet familiar), but in fact completely analogous to linear mechanics: how do you get the vector acceleration by dividing the force vector on the inertia, as surely you get a vector of the angular acceleration by dividing the moment of the force vector on the inertia tensor. And no twitching of the left will not work - mother nature will take care of (with proper design of the inertia tensor, of course).
Thank you!
I understand that the dampers are red and lemon axles(springs) you did fine. But the damper for the blue gives you a strange reaction. So? - anahi_Monahan commented on September 26th 19 at 07:10
Yes. The truth behind red and lemon also can not answer. - deangelo.Stokes commented on September 26th 19 at 07:13
In particular cases of rotation strictly according to the coordinate axes of the tensor operations are equivalent to operations with the scalar moments of inertia about corresponding axes, Ixx, Iyy, Izz.
⃗α=⃗M/Ix - anahi_Monahan commented on September 26th 19 at 06:52
The angle of a body in ODE is specified by a quaternion. And here is how to convert the quaternion in the moment of inertia is I have no idea. - deangelo.Stokes commented on September 26th 19 at 06:55
The moment of inertia does not depend on the orientation! As well as the mass does not depend on the coordinates. What makes you think that? - anahi_Monahan commented on September 26th 19 at 06:58
So I bad explained what I need. And the moment of inertia then there is nothing. In short: there are two bodies, one fixed rigidly in the orientation of Q0=(w=1,x=0,y=0,z=0) and not moving anywhere, the second pinned him with ball joint and spring, which does not allow him to deviate from the Q. And I need to know the Torque moment relative to global axes depending on the orientation vector of the second body specified by the quaternion Q2. - deangelo.Stokes commented on September 26th 19 at 07:01
Still don't understand.
Q0 is a unit quaternion, that is, zero turn (where? what is the initial orientation for all turns, including zero?), that is nowhere in particular, the body 1 is not rotated, not exactly clear where it is generally turned off. Then begins the hurdy-gurdy. While I can imagine that the center of the body 1 is the center of rotation of the body 2. The ball joint has 3 degrees of freedom in all three planes. That is not restrict the body 2 in any way, except distance to the center of rotation. The body 2 can be rotated as anything and even anyone. And where are you spring-neeku put in? And what is Q? Q0 you defined as zero rotation, and Q (I suspect - also a quaternion) is not determined, then there is every possible direction. Then there restricts "any possible direction of the body" to anyone - is not clear. You should at least cernovice shemki planted... To your design to see one eye. - anahi_Monahan commented on September 26th 19 at 07:04
Mentioning Q I meant the quaternion that specifies the direction to which the spring tends to rotate the second body. In the simplest case, it coincides with Q0. In the ideal case, the second body performs harmonic oscillations, which must be extinguished, if the program is to make an additional correction for the quenching of the Torque moment given angular velocity. The oscillation amplitude is determined by the initial position of the second body.

i67.fastpic.ru/big/2014/0730/bc/46a217b24553e9af9d...
This whole Saga stems from the fact that in Open Dinamic Engine, which calculates physics, yet support restrictions. This disadvantage I decided to fix writing a library that calculates the reaction of the springs. - deangelo.Stokes commented on September 26th 19 at 07:07
Okay. Not that I know who ODE, but try to reformulate the puzzle already in terms of drawing (which you really shouldn't have signed axes, and other letters as needed). I was curious kinematics, but right now I pick Unity3D, so I will try to figure out. - anahi_Monahan commented on September 26th 19 at 07:16
September 26th 19 at 06:51
David Baraff in his lectures describes this whole thing:
www.cs.cmu.edu/~baraff/sigcourse/notesd1.pdf
The moment of inertia is a diagonal matrix, which is set in the time of the creation of the body. It's a sort of "mass" for rotational motion.
Thanks, found this book. Read again.
Unfortunately, neither the formula nor the sample that would have led me to the solution I found. Body stubbornly spins around its axis 0Z and blasts off to outer space. - anahi_Monahan commented on September 26th 19 at 06:54
September 26th 19 at 06:53
The idea is I just need to know what the angle of the quaternion forms with the coordinate axes. Just how to do it?
A quaternion is a very abstract thing. Still like to ask "what is the angle it forms with the coordinate axes, the number of purple color". You mean "how to find Euler angles from the orientation quaternion of the specified kind"? - anahi_Monahan commented on September 26th 19 at 06:56

Find more questions by tags C++MathematicsmechanicPhysicsPython