Advertisement

Locking 'roll' in Quarternions

Started by January 06, 2002 03:51 PM
22 comments, last by LTJ 22 years, 6 months ago
Quaternions - what a bizarre thing to be so passionately against... If you don't like 'em, don't use 'em...

In the meantime, I appreciate the articles in Game Developer.

Mr. Jaszcz - be very careful comparing pinkies here...

Edited by - CrazedGenius on January 15, 2002 12:41:33 AM
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
heh.. i caught the symbolism of that, but i really meant my little pinky.. oh, never mind..

you know why i''m so passionate about it? cuz if you don''t then these fools will spread the garbage, and eventually you''ll have to use their system (if it spreads enough). look at intel byte order.. see, nobody spoke up, and now we''re stuck with some majorly fucked up shit.. how''s that for an answer?
--bart
Advertisement
Actually, no symbolism intended... The point was that you walk an extremely dangerous line when you post your resume online and then trash talk to people whose backgrounds you don''t know.

as for the garbage spreading, blame Hamilton. Based on the uptake of quaternions in the general public since their inception, I''d guess we have awhile to go before we end up in an Orwellian world ruled by Quaternions (the "axis" powers??). Then of course, you might have the last laugh when we lose our identities and are all given imaginary numbers.

Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
quote:

listen kiddies, i know more physics in my little pinky that you'll even know in your life time, if you don't believe me, go to my page and read the shielding theory..



Been there, not been impressed. There are cleaner expressions of light pressure effects. Especially when you realize that the impulse of a single photon is known. Or when you've studied Maxwell's equations. Which should let you realize that your r^-2 result is due to your closed-surface integration.

Sorry, no cookie.

quote:

as a matter of fact i did take college level physics classes, and guess what, they never talk about torques that are acting along different rotational axis. yup, it's pretty easy to see that torques acting on the same axis just add, but the other case ain't so simple, is it? chew on that for a while.



Sum of torques = first derivative of angular momentum = moment of inertia times angular acceleration. These are vector quantities so you have to remember that the axes themselves can change, but beside that, there is no great secret.

Edited by - Fruny on January 16, 2002 10:37:14 AM
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
heh, ok, all kidding aside, i still don't understand what's up with this rotation shit, i'll just list some stuff, feel free to ridicule me some more..

#1: the torque vector is the axis of rotation with the magnitude encoding the angle, which i think is kinda weird to start with..

#2: i guess torques still add in 3d, but they have to be happening at the same time. torques happening at different times have to be handled differently.. i guess the whole idea is that the vector sum of the torques points in the "mid-vector", with different magnitudes changing this slightly. anyhow this is somewhat difficult to visualize.. i'd almost prefer to handle all torques separately instead of adding them, but i guess the math does work out..

#3: encoding angular velocity with a single vector/magnitude is kinda weird once again, and as you mentioned this vector changes direction over time, so it's not really intuitive. how about having a whole matrix to encode angular velocity? as we all know, orientation matricies can also be used to rotate stuff..

#4: torques would operate on the angular velocity matrix, according to the inertia of the object.. i don't know how to compute this, but i'll think about it. i think this is what they call "the tensor". i dunno, sounds to me like you could just scale the torque by the mass inverse instead of doing all this complicated stuff..

#5 (edit): hrm, i guess intertia is mass times angluar velocity, so you'd have to somehow multiply the angular velocity matrix by mass.. or scale the torque by the inverse angular velocity matrix * mass..

--bart



Edited by - bpj1138 on January 16, 2002 6:53:24 PM
--bart
Ok. I'll try to answer. Vectors are in bold (except where I forget ). Errors are purely mine : as I'm doing that from memory so I may get signs wrong & the like. Feel free to correct me.

#1 This is directly related to question 3.

When you learned in class that the torque (at point G) of a force was T = F*r*sin(theta), that was a simplification of the real expression, where T = r x F . Where r is the vector from the center of mass G to the point of application. The scalar expression was actually the magnitude of the vector, which you then used in T = I*d^2(theta)/dt^2.
The same is still true in vector form.

#2

I agree that it is not easy to visualize. Yet, remember that, just like forces, torques do not have an 'instantaneous' effect. (i.e. they are not impulses). They apply an acceleration, not a discontinuous change in velocity. Just like you've been told that the acceleration was the sum of the forces divided by the mass, the angular acceleration is the sum of the torques divided by the moment of inertia. I'll grant you that the addition of torques is a bit more complex than the addition of forces, since you have to take into account the point of application (i.e. bring back all the torques to the same point first), but as you said, the math works out.

#3

Actually here, it is not weird at all, and even makes sense once you understand the logic . The reason why angular velocity is represented by a vector is because it lets you reconstruct the velocity in any point of your solid. If your angular velocity is w , that your axis of rotation passes through A, that you have an overall linear velocity V (i.e. velocity in A). Then the velocity of the object at point B is V (B) = V (A) + w xAB . The vector w can change over time if your axis of rotation changes over time (e.g. a spinning top, the earth or a gyroscope).

#4 Yes, torques do affect the angular velocity. See #5

Tensors are something completely (well nearly completely, it's still physics (and yet...) ) unrelated. It is a notation (yep just like vector notation) used to make formulas in Continuum Mechanics (and Relativity, and Fluid Mechanics ...) easier to write, manipulate and understand (even though I barely passed my Continuum Mech final 4 years ago). To explain quickly : a scalar is a rank 0 tensor, a vector is a rank 1 tensor, a matrix is a rank 2 tensor, a cube of number is a rank 3 tensor ... and so on.
There is a 'primer' online there, good luck with it.

#5

The computation of the moment of inertia with respect to a given axis is actually a simple one : you are making the sum (integral) of the product of the mass of every physical 'point' that make up your object, by the distance of that point to the axis. (i.e. Inertia w.r.t. axis AB I_AB = sum( mass(P)*distance(P,AB) for all P).


I hope I've been clear enough. If the reply is hazy, ask again.

Edited by - Fruny on January 16, 2002 8:21:02 PM
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Advertisement
quote:
Original post by bpj1138
hrm, i use a combination of euler angles and basis vectors, the orientation is kept as basis vectors, but you rotate the orientation using normal X/Y/Z rotations. the best way is to have to have two matricies or three, one for direction, one for roll, and one for pitch, multiply them out to get the final result. the math ends up a lot more readable..


Quaternions are to rotations, what vectors are to points. That''s like saying putting dx/dt & dy/dt together is more readable than using a velocity vector... perhaps if there''s only one of them. And you have no ability to twiddle yaw - wouldn''t it be neat if you could lean around corners?
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
bpj1138:
Like you, I typically use an orthonormal basis for storing the orientation of all my objects. I agree it with you that it is very useful. Whenever you need to adjust the orientation, you compose a transformation matrix and apply it to the basis and you are all set. Its also handy, because at any time, regardless of how your object is oriented, you always have 6 options for rotation: X, Y, Z, as well as true yaw, pitch and roll from the objects perspective (its perceived "X, Y, Z" axis, which is actually the vectors of the basis). I've worked with quats, and I find the orthonormal basis to be a much cleaner solution.

Where I do find quats to be handy is when interpolating between a starting and ending orthonormal basis. Mostly, I use this in skeletal animation, interpolating between keyframes. To be honest, I dont really know that there is a simple, accurate, and fast way to do this with matricies. I've looked a lot and never found a solution (and I suspect if I found one, it might be a bit mathematically intensive). However, doing so using quats it pretty trivial.

quote:
Original post by bpj1138
look at intel byte order.. see, nobody spoke up, and now we're stuck with some majorly f***** up shit.. how's that for an answer?


While it does seem "strange", it is actaully a very elegant design. One of the advantages of such a design is that type size conversions are trivial. You can take a pointer to a 32bit int and treat it as a 16 or 8 bit integer pointer without doing any pointer arithmetic. Now this does seem trivial, like something you could handle in software or hardware. But what happens when you have an array of 32-bit int pointer, and you want to pass them to a method that expects an array of 16-bit int pointers. Without the intel byte ordering, you would have to go through and modify each pointer before sending the array to the method. However, on an intel system, just send the array on its way and everything is handled trivially.

Additionally, systems usually like to keep memory accesses aligned. On an intel byte ordered system, if you have an aligned 32 bit int pointer, and you convert it to a 8 bit int pointer, the resulting pointer is the same, and thus still aligned. Without intel byte ordering, once you make the conversion, your 8 bit int pointer is no longer aligned (unless the machine uses 1-byte alignment).


Finally, I do agree with you on several points, however you do need an attitude adjustment. You come off quite rude and immature. Even if you WERE the smartest person in the world, there would still be things you could learn from others. Try to be a bit more "cooperative" and bit less insulting.

Edited by - LordKronos on January 16, 2002 9:59:51 PM
Ron FrazierKronos Softwarewww.kronos-software.comMiko & Molly - Taking Puzzle Games to A Whole New Dimension
Fruny:

#1: ok, so actually torques will overlap quite a bit..

#3: yeah, actually i was thinking of a spinning top to visualize it. it''s still kinda cloudy how the the vector changes direction to make the top tilt on its axis. i realize having a vector rather than a matrix is more useful in some calculations, but a angular velocity matrix wouldn''t change over time.. this would be good? no?

#4: oh, hrm, i don''t remember where i saw this "tensor" stuff, nevermind..

#5: oops, i messed up again.. i meant angular momentum.. yes, moment of inertia is static for an object. so angular momentum = moment of intertia times angular velocity, angular velocity being the vector, intertia is a scalar.. I can see now how angular velocity being a vector helps here. any ideas how this can be applied to a matrix? hehe.. maybe i''m just crazy..

--bart



--bart
LordKronos:

well, i was rude cuz they said i was clueless.. they started it.. but as you can see, we''re not fighting anymore.. heh..

Magmai Kai Holmlor:

hrm, ok, that''s a good explanation.. i always did think that breaking things up into cartesian space was weird in some respect, but we are so linked to it, (though 3 dimensions?) that it''s inescapable?

anyhow, maybe quaternions aren''t so useless, i dunno.. what we really need to find is like what LordKronos was talking about. some way to interpolate orientations without that crazy math. too bad just linear blending doesn''t work very well. maybe there is some way to find angles between the axes of the orientation? it''s a thought..

--bart

This topic is closed to new replies.

Advertisement