Quaternions
|
|
Landing Normandy
Proposing 4968
Join date: 28 Nov 2005
Posts: 240
|
09-27-2006 10:26
OK, for gods sake, can anyone explain about quaternions that doesn't require an abnormal amount of concentration? Simple problem; I have a door that is supposed to open up, it's a trap door of sorts. The original prim was rotated on the Z at 180. Now, here's the really simple bit that everyone else seems to over complicate: When you click it, it opens, when clicked again it closes... now, what do I put in here under Z to get it to stay at 180degrees? llSetPrimitiveParams([PRIM_POSITION, <31, 120.5, 75>, PRIM_ROTATION, <X,Y,Z,S>]); Another simillar line rotates the door open and moves it to where it needs to be, the damn thing just won't stay rotated on Z correctly. All I want to know is this 1) What is 90deg in Quaternions 2) What is 180deg in Quaternions 3) What is 270deg in Quaternions Nothing more, nothing less. I couldn't possibly care less about how they work, I just need to know how to get the prim to not rotate around Z every damn time I click it. And if anyone goes on about how great Quats are I actually think my head will explode. I don't care! Now, if you can ignore my rather aggresive attitude and help I would be very appreciative... my attitude has come from reading all these posts about converting and why we use Quats... ARGH!
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
09-27-2006 10:30
Quaternions are evil. Don't try to write out rotations yourself, is my advice. Instead, use functions like llEuler2Rot to give rotation variables values, and multiply them together where necessary. http://rpgstats.com/wiki/index.php?title=Rotation#Combining_Rotations
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Landing Normandy
Proposing 4968
Join date: 28 Nov 2005
Posts: 240
|
09-27-2006 10:59
OK, I noticed a patern when playing with the figures. If I did this: <0,0,1,1> it does the same as <0,0,2,2> so in the end I did something really unpretty and did <0,0,10000,0.00001> which actually, after rounding up as best as SL can, equals 180deg on the Z. Only problem is that the door on the other side opened by 'PI_BY_TWO' and the S value would make this appear as if nothing. So I did 'PI_BY_TWO * 10000' which, by some stroke of luck, opened exactly how I wanted it to.
Just for the record, the inability to code in degrees as well as quats is a major fault on the part of LL and should be rectified. Why should everyone need to know advanced maths to figure out how to rotate anything when everyone and everything else works in degrees... at least keep some amount of similarity... if one part of SL accepts degrees, it all should. And converters would be just as well used silently as well so we didn't have to code in the conversion ourselves
|
|
Landing Normandy
Proposing 4968
Join date: 28 Nov 2005
Posts: 240
|
09-27-2006 11:18
OK, now I've actually got the real numbers I want:
Closed and just rotated around 180deg on the Z:
<0,0,1,-0>
Open, still at 180deg on the Z but also opened by PI_BY_TWO to match the opposing door would be:
<0.00000, 0.84363, -0.53693, 0.00000>
Obviously!
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
09-27-2006 11:37
I have - perfectly honestly - never put a literal quaternion value in any script that I have ever written. Which is quite a few. I *always* use llEuler2Rot, or llRotBetween, or one of the other helper functions. It's usually dynamic anyway and if I have any fixed values that I'm going to need routinely, I set them in a global variable during state_entry.
For example, ejecting cartridges, they need to be turned 90 degrees around the Y-axis from the rotation of the gun, so I have TURN = llEuler2Rot(<0.0, PI_BY_TWO, 0.0>; in state_entry, and then rez them with rotation TURN * llGetRot().
Rotations could be expressed in twenty-dimensional pink unicorn matrices for all I'd notice.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
09-27-2006 14:25
I don't remember them all, but some I do.
90º around x is <0.707, 0.0, 0.0, 0.707>, -90º around y is <0.0, -0.707. 0.0. 0.707> IIRC.
You can always put in a script to say llGetRot() when touched, set your prim and use that
|
|
Landing Normandy
Proposing 4968
Join date: 28 Nov 2005
Posts: 240
|
09-27-2006 14:48
From: Eloise Pasteur You can always put in a script to say llGetRot() when touched, set your prim and use that Now that's an easy way of doing it, why didn't someone come up with that one earlier... next time someone asks, make that the answer... Q: "How to I convert degrees to quaternions?" A: "Move your prim to the desired angles and put a script in it that says llGetRot() when touched" Simple eh? I love it, thanks!
|
|
Francis Chung
This sentence no verb.
Join date: 22 Sep 2003
Posts: 918
|
09-27-2006 16:15
Ordinal is right - there's not a whole lot to be gained by finding a geometric interpretation of how a quaternion can be used to encode a rotation. I posted once about what you need to know about rotations to use them effectively in SL (post #7) /54/3b/50692/1.htmlIf you insist on staring at quaternions, you should know that quaternions are always normalized when they're interpreted as rotations. Intuitively, you can see that quaternions offer 4 degrees of freedom, while all rotations are expressible with 3 degrees of freedom.
_____________________
-- ~If you lived here, you would be home by now~
|