Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

rotation division borked?

Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
10-29-2007 15:28
the following code rotates an object counter-clockwise on multiple calls...
roatation bob = llEuler2Rot( <.0, .0, 90.> * DEG_TO_RAD );
llSetRot( bob * llGetLocalRot() );
yields rot.z = 0, -90, -180, 90, 0

ok all good,
the following code SHOULD rotate clockwise.... but DOESN'T on multiple calls....

roatation bob = llEuler2Rot( <.0, .0, 90.> * DEG_TO_RAD );
llSetRot( bob / llGetLocalRot() );
yields rot.z = 0, 90, 0, 90, 0

as you can see it flips back and forth as if it were being swapped with the previous call... what's going on here?
_____________________
|
| . "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...
| -
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
10-29-2007 16:01
With rotations, you always try to find a way that works, you never try to understand why all the other ways don't work. At least, that's my mantra :)

Try:

rotation bob = llEuler2Rot( <.0, .0, -90.> * DEG_TO_RAD );

-90 = 90 degrees in the other direction, so that might work. *shrug* Who knows. It's rotations :)
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
10-29-2007 16:11
try this:

llSetRot( llGetLocalRot() / bob);
_____________________
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
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
10-29-2007 16:18
I always believed the tooltip syntax for the rotation stuff in the LSL editor should simply say "You will not understand this."
_____________________
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
10-30-2007 01:28
From: Jesse Barnett
try this:

llSetRot( llGetLocalRot() / bob);


that'd be great jesse, except one little thing... I need it to be the local x-axis which means it must be it the rev order....

//I know that

llSetRot ( bob / llGetLocalRot() );

//is the same as

bob.s *= -1;
llSetRot ( bob * llGetLocalRot() );

but I've used this before, and at one point, I KNOW that division worked properly...

this also borks some movement by rotation scripts since they expect a right hand turn (clockwise) not a huge left hand turn.... which can be seen visually

EDIT: jira issue is here
however as noted in the issue, Division for local axis does NOT work that way... but works (properly?) as I described in the OP, however Global Division does NOT follow this pattern (as jesse noted) so I've reopend the issue, to get either a clarification, or a consistency check.... it may be related to the other issue (which I can find) regarding a borked implementation of rotations in either llSetPrimitiveParams or llSetLinkPrimitiveParams
_____________________
|
| . "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...
| -
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
10-30-2007 02:20
Ignore me if it's not this, but... *tacks it on*
http://jira.secondlife.com/browse/SVC-93
_____________________
Django Yifu
Beat Island Gaffer
Join date: 7 May 2007
Posts: 189
10-30-2007 06:51
This got me while ago to the extent that I put out a plea for people to go make a vote on it in JIRA.

Here's my thread with some info I found useful.

/54/9b/217272/1.html
_____________________
Tread softly upon the Earth for you walk on my face.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
10-30-2007 07:23
I linked it, because it may be related to the discrepency between global and local rotations.

and thanks Day Oh, that WAS the issue I was looking for
_____________________
|
| . "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...
| -
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
10-30-2007 09:11
SVC-93 isn't what's biting you here unless you're doing the llSetRot() in a child prim.

Void, what's going wrong here is that you've got a mistaken understanding of what rotation division does. Rotation division "unrotates"... but what you actually want to do is rotate in the other direction. Those are two subtly different things. I just woke up, so I can't bring to mind a good way of explaining the difference.

You're right in that multiplying in the order of bob * llGetLocalRot() rotates the amount of bob with respect to the object's local axes. To rotate in the other direction around the local axes, you need to just multiply on the left with a rotation that's the negative of the original rotation, like Ziggy suggests... something like this:

rotation bob = llEuler2Rot( <.0, .0, -90> * DEG_TO_RAD );
llSetRot( bob * llGetLocalRot() );

Now, there's another problem here; you're llSetRot()ing something calculated using llGetLocalRot(). That's almost bound not to be what you want. If this is in a child prim, look at SVC-93 to see how to work around the bug. If it's in a root prim or a single prim, use llGetRot(), which, in that case, will be identical to llGetLocalRot()
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
10-30-2007 11:50
Edit: Nevermind. The way Lex wrote above works the same way, and is rather simpler to understand. There shouldn't be really any trouble using it in either a root prim or a child prim; llSetLocalRot(llEuler2Rot(<whatever amount here>;) * llGetLocalRot()) will rotate the prim around <whatever amount here> around its local axes as needed. All you need to do is change the direction of the angles in the vector to change which direction it's rotating in. Changing the operation from * to / does not do the same thing.

The main reason this is so confusing to everyone is because * and / operations give the same *results* as when you simply rotate by a positive or negative angle, respectively - but this is only true when you're computing global rotations, since the global axis never changes. However, since the local axis can change, you have to get used to the idea that you can either rotate by a positive or negative angle, but / is 'unrotating,' which is not the same.
_____________________
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
10-31-2007 06:02
From: Lex Neva
SVC-93 isn't what's biting you here unless you're doing the llSetRot() in a child prim.

Void, what's going wrong here is that you've got a mistaken understanding of what rotation division does. Rotation division "unrotates"... but what you actually want to do is rotate in the other direction. Those are two subtly different things. I just woke up, so I can't bring to mind a good way of explaining the difference.

oh once I read SVC-033 I realized that, per your description, but because local and global division (change / global vs global / change) seem to behave differently, I thought there might be a link in how it was implemented, someone with better math skills can check the correlation..... there needs to be a "MAY relate to" option

From: someone
You're right in that multiplying in the order of bob * llGetLocalRot() rotates the amount of bob with respect to the object's local axes. To rotate in the other direction around the local axes, you need to just multiply on the left with a rotation that's the negative of the original rotation, like Ziggy suggests... something like this:

rotation bob = llEuler2Rot( <.0, .0, -90> * DEG_TO_RAD );
llSetRot( bob * llGetLocalRot() );

actually I found this to be a very elegant solution...
bob.s *= -1;
llSetRot( bob * llGetLocalRot() );

paired they make a perfect reflection on each call, separate, it's an inverse rotation (which as noted also works by inverting the original vector, but that's resource heavy)

From: someone
Now, there's another problem here; you're llSetRot()ing something calculated using llGetLocalRot(). That's almost bound not to be what you want. If this is in a child prim, look at SVC-93 to see how to work around the bug. If it's in a root prim or a single prim, use llGetRot(), which, in that case, will be identical to llGetLocalRot()


THAT was for compatibility across linked or unlinked single prims, because llGetLocal Rot does behave the same as llGetRot in a root prim, it makes for a nice clean way to keep rotations in relation to local axis w/o coding 2 different versions for linked or unlinked
_____________________
|
| . "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...
| -
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
10-31-2007 08:42
From: Void Singer

THAT was for compatibility across linked or unlinked single prims, because llGetLocal Rot does behave the same as llGetRot in a root prim, it makes for a nice clean way to keep rotations in relation to local axis w/o coding 2 different versions for linked or unlinked


In that case, tyken's right: use llSetLocalRot(), not llSetRot(). That'll work in root and child prims.