Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

My head hurts (or 'I Hate Rotations')

Newfie Pendragon
Crusty and proud of it
Join date: 19 Dec 2003
Posts: 1,025
10-08-2004 06:50
As I mentioned in a recent thread about poseballs (found here) I had decided to dust off my partially-completed poseball positioning helper scripts and finally complete them. I've gotten an initial version that works accurately - as long as I never ever ever rotate the prim (or the target) around any axis other than vertical (z?). If I try to rotate either case, the sit position starts to drift - not a whole lot, but definitely enough to be noticable and to screw up the positioning.

Let me repeat - this only happens whenever the rotation is not <0, 0, 0, s>, where s can be any value. If the x, y or z is changed, the position starts drifting ever so slightly, even if I try to mathematically remove the prim's rotation from the positioning. The avatar will always sit correctly, as long as the rotation includes sitting vertically.

As much as it equates to a short putter around the parking lot, this is driving me nuts! Any tips/ideas/suggestions?


- Newfie Pendragon
Jake Cellardoor
CHM builder
Join date: 27 Mar 2003
Posts: 528
10-08-2004 10:52
From: Newfie Pendragon
Let me repeat - this only happens whenever the rotation is not <0, 0, 0, s>, where s can be any value. If the x, y or z is changed, the position starts drifting ever so slightly, even if I try to mathematically remove the prim's rotation from the positioning.


In a quaternion of form <0, 0, 0, s>, s MUST equal 1 for it to be a valid rotation. If you are specifying other values for s, LSL is probably clamping the value to 1.

It may be that once you start changing the x, y, or z values, LSL no longer knows which value it should fix in order to make it a valid rotation. (After all, how could it know your intentions?)
Newfie Pendragon
Crusty and proud of it
Join date: 19 Dec 2003
Posts: 1,025
10-08-2004 11:01
From: Jake Cellardoor
In a quaternion of form <0, 0, 0, s>, s MUST equal 1 for it to be a valid rotation. If you are specifying other values for s, LSL is probably clamping the value to 1.

It may be that once you start changing the x, y, or z values, LSL no longer knows which value it should fix in order to make it a valid rotation. (After all, how could it know your intentions?)


My apologies, the <0, 0, 0, s> may have been a red herring - I included it to try to explain a little what was happening (in other words, it's possible I goofed with the value). What I meant to underscore was that the drift did not happen whenever the rotation was occurring around the vertical - only when the rotation was away from the vertical.


- Newfie Pendragon
Sarah Marlowe
Registered User
Join date: 20 Apr 2005
Posts: 12
I had the same problem, and have solved it!
05-08-2005 20:02
Hi, I'm new to scripting, and didn't expect to be posting just yet, but I had exactly the same problem, but I solved it as follows:

Firstly, to get a rotation value that actually works, I used the llEuler2Rot method: i.e

rotation rot = llEuler2Rot(<0,PI_BY_TWO,0>;);

It took me a while to work out that I needed to use degrees instead of radians - as soon as I started to used PI_BY_TWO instead of 90, I started getting somewhere!

I hope this helps!

- SM
Ace Cassidy
Resident Bohemian
Join date: 5 Apr 2004
Posts: 1,228
05-08-2005 21:22
From: Jake Cellardoor
In a quaternion of form <0, 0, 0, s>, s MUST equal 1 for it to be a valid rotation.


This is NOT true!

The "s" component is not restricted to the value 1.0. If this were the case, LSL would simply use 3-component vectors to represent rotations.

- Ace
_____________________
"Free your mind, and your ass will follow" - George Clinton
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
05-08-2005 23:00
Please see my responses in this thread. I don't feel I need repeat them.
_____________________
---
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
05-08-2005 23:02
From: Ace Cassidy
This is NOT true!

The "s" component is not restricted to the value 1.0. If this were the case, LSL would simply use 3-component vectors to represent rotations.

- Ace

Oh, and concerning this... the resulting rotation must be normalized (that is, "equal to 1";) in a subset of quaternions known as ternions. That has little to do with what the S component equals, as you've noticed - it's a matter of what the whole kit and kaboodle is.

Second Life commonly uses normalized quaternions, AKA ternions, for efficiency. Quaternions that aren't normalized will work fine, though.
_____________________
---
Eckhart Dillon
Registered User
Join date: 4 Jan 2004
Posts: 22
Some things you should know about rotations.
05-15-2005 09:46
llRot2Euler gives you the radians not degrees.

you can make them degrees by multiplying by RAD_TO_DEG

float degrees = radian * RAD_TO_DEG.

you can convert a vector that uses degrees into radians to make a rotation by using DEG_TO_RAD.

rotation rot = llEuler2Rot(<360,360,360> * DEG_TO_RAD);