Rigid Body Physics - Inertia Tensor Space

Started by
30 comments, last by d07RiV 8 years, 8 months ago

I.e. instead of doing q += t/2 * (0,w) * q, do q = (cos phi/2, sin phi/2 * w) * q ?

I looked through the article Dirk pointed to and actually it should be:


q = (cos phi/2, sin phi/2 * w / phi) * q

I checked this formula out and it gives very *slightly* different results than adding vector to quaternion. But the error, at least visually, doesn't seem to be problematic.


I don't think that overloading operator+ is a good idea because if someone else reads your code it might not be immediately apparent to him what your are trying to do. Writing a simple function IntegrateOrientation() would be much more meaningful in this case (e.g. look for self-documenting code). I also like the term of 'navigation depth' in that context. It means if I read a function in some code how deep do I need to navigate into sub functions to understand the code. Ideally I can understand the overall function by just looking at the top level code. It makes you a lot of friends writing readable code.

Integration is, roughly speaking, summation so I would disagree with you on that smile.png. Anyway, I prefer using function quaternion.AddVector (like in my Python code).


Regarding the original problem I think we have been through all details and you should be able to figure out the problem yourself. Just take your Unity example and then step through both programs side by side until you find the problem. This shouldn't really be too hard!

Which problem are you referring to at the moment? The original one from the first post of this thread we've solved already. You gave me the right tensor transformation formula and I found the bug in my quaternion integration code. Problem solved smile.png.

Advertisement

Yeah where w is the normalized vector. It won't make a difference unless your angular velocities are large enough, in which case it will rotate slower (or faster?) than it should - because sin(x) is almost the same as x when x is small (actually in the 'easy' method the multiplier is essentially x/sqrt(1+x^2) after you normalize it):

qtCYLtc.png

This topic is closed to new replies.

Advertisement