Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

math question

Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-06-2008 07:13
not really a script question, but a math question about a script function that's commonly used for placing objects. llGetPos()*llGetRot() or any other position multiplied or divided by a rotation. i'm no math magician, but i've been wondering about this for a few days, what is teh calculation it actually makes? positions have 3 float values in it's vector, while rotations have 4. so why does it work? is it an actual math formula, or is it just some bizarre virtual world thing? and who figured it out anyways?
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
10-06-2008 08:03
The operation for (vector) * (rotation) rotates the vector to a different frame, basically. I understand how to make quaternions do anything I want in-world, but I'm not at the point where I'd force myself to understand their workings or operations.. You can even interpolate rotations in SL without knowing how quaternion operations work, so it's reeeally not worth it. :cool:

Also, note that Wikipedia is probably the least learning-friendly place to find information about anything math-related, but here! http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation
_____________________
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
10-06-2008 08:14
William Rowan Hamilton is the source of our rotation fun, and he was around long before virtual worlds! The rotation is represented by something called a "unit quaternion", which is basically a 4-dimensional number. (The intricacies get into some of the ethereal realms of mathematics, but it's an extension of imaginary numbers, i.e. the square root of -1, which is sometimes covered briefly in high-school level maths).

Technically, a quaternion represents translation (or movement) in 4 dimensional space, which, when limited to our 3 dimensional perception, becomes a nice stable rotation.

Long-story short, quaternions work. :) There is actually a special operation that goes on under-the-surface to multiply a vector by a quaternion, which you can see under the section called "Performance comparisons with other rotation methods" of the Wikipedia article. It's not quite as simple as it looks when you just say "vector * rotation", but it's not too bad, and is in fact a bit easier in the long-run than some of the more "traditional" methods, such as Euler angles and so forth.


For more general info about the background of quaternions, checkout:

http://en.wikipedia.org/wiki/Quaternion
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-06-2008 08:22
Some nerdish but fun reading on why there are 4 directions in a rotation you can search for gimbal lock.

This one is an interesting read about what happened during the Apollo 11 mission when thy were approaching gimbal lock and the astronaut broached the subject of sending them a 4th gimbal:

http://www.hq.nasa.gov/alsj/gimbals.html
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
10-06-2008 09:02
the '*' in this case is not really multiplication in the usual sense. You can think of it as meaning "apply the rotation".

Like you, I wondered. I have pretty strong math. But when I googled and wikied about quaternions, the stuff I found was mostly too theoretical to be useful to me in Sl. I think quaternions are one of those wonderful examples of how pure math turns out to be useful in a surprising way years later.
_____________________
So many monkeys, so little Shakespeare.