Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotating by a constant amout with UpdateSitTarget

Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
09-09-2009 10:49
I'm making something based on the adaptation of the ChangeableSitPosScript -- /15/97/184550/1.html#post1513917 -- and having problems when I turn left or right. I would have expected
CODE
 currentRot = llGetRot() + (currentRot * llEuler2Rot(< 0, 0, -10 > * DEG_TO_RAD)); 
to rotate me by a constant amount each time, but it doesn't.

I'm trying to change my rotation with a menu, and my code now looks like
CODE
   else if(message=="left turn")
{
llOwnerSay("currentRot is "+(string)currentRot+", or "+(string)(llRot2Euler(currentRot)*RAD_TO_DEG));
currentRot = llGetRot()+ (currentRot * llEuler2Rot(< 0, 0, -10 > * DEG_TO_RAD));
llOwnerSay("changing it to "+(string)currentRot+", or "+(string)(llRot2Euler(currentRot)*RAD_TO_DEG));
}

What it says to me, when I repeatedly click it, is
From: someone
[10:45] change sit target v 3: currentRot is < 0.00000, 0.00000, 0.00000, 1.00000 >, or < -0.00000, 0.00000, -0.00000 >
[10:45] change sit target v 3: changing it to < 0.00000, 0.00000, -0.08716, 1.99620 >, or < 0.00000, 0.00000, -5.00000 >
[10:45] change sit target v 3: currentRot is < 0.00000, 0.00000, -0.04363, 0.99905 >, or < 0.00000, 0.00000, -5.00083 >
[10:45] change sit target v 3: changing it to < 0.00000, 0.00000, -0.13053, 1.99144 >, or < 0.00000, 0.00000, -7.50041 >
[10:45] change sit target v 3: currentRot is < 0.00000, 0.00000, -0.06542, 0.99786 >, or < 0.00000, 0.00000, -7.50160 >
[10:45] change sit target v 3: changing it to < 0.00000, 0.00000, -0.15214, 1.98836 >, or < 0.00000, 0.00000, -8.75080 >
[10:45] change sit target v 3: currentRot is < 0.00000, 0.00000, -0.07631, 0.99708 >, or < 0.00000, 0.00000, -8.75316 >
[10:45] change sit target v 3: changing it to < 0.00000, 0.00000, -0.16292, 1.98664 >, or < 0.00000, 0.00000, -9.37658 >
[10:45] change sit target v 3: currentRot is < 0.00000, 0.00000, -0.08174, 0.99665 >, or < 0.00000, 0.00000, -9.37757 >
[10:45] change sit target v 3: changing it to < 0.00000, 0.00000, -0.16830, 1.98574 >, or < 0.00000, 0.00000, -9.68878 >

How can I get it to change by a constant amount rather than decrease each time I try to turn myself?
EF Klaar
Registered User
Join date: 11 Jun 2007
Posts: 330
09-09-2009 11:01
From: Argent Stonecutter
The rotation of the avatar reported to the sim is off by up to 30 degrees in either direction from what any user (including the avatar itself) sees.
Might this comment in reply to an old post of mine be relevant here?
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
09-09-2009 11:06
From: Innula Zenovka
I would have expected
CODE
 currentRot = llGetRot() + (currentRot * llEuler2Rot(< 0, 0, -10 > * DEG_TO_RAD)); 
to rotate me by a constant amount each time, but it doesn't.
You can't add rotations like that, i.e. using a "+"
To add a rotation use: "*"
To subtract a rotation use: "/"
see:
http://www.lslwiki.net/lslwiki/wakka.php?wakka=rotation
Although it isn't clear to me what you want I would suggest you try:
CODE

currentRot = llGetRot() * llEuler2Rot(< 0, 0, -10 > * DEG_TO_RAD);
_____________________
From Studio Dora
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
09-09-2009 13:21
Thank you, Dora. That does exactly what I wanted.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
09-09-2009 13:37
and because of the way that rotations work it's almost always better to "add" using multiplication... if you need to "subtract" I recommend using the following structure

(ZERO_ROTATION / rot_change) * rot_base

or

rot_change.s *= -1;
rot_change * rot_base.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
09-09-2009 15:34
From: Void Singer
and because of the way that rotations work it's almost always better to "add" using multiplication... if you need to "subtract" I recommend using the following structure

(ZERO_ROTATION / rot_change) * rot_base

or

rot_change.s *= -1;
rot_change * rot_base.


How come?

Is there some issue with the unrotate "/" operator? Normally, I find it works just fine.

P * A = Q
Q / A = P