Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Book Cover Rotation Calculations

Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
06-17-2007 06:37
I HATE ROTATIONS!!!!!!!!! AAAAAAAAAAAAAAAAUGH!!!!


okay, i have two book covers, front and back. when the book opens, the spine rotates 90 degrees (i got THAT part working), then the covers are supposed to open 90 degrees. i have tried every variation and iteration of this calculation to get the back cover to open 90 degrees. it opens 45, -45, 90 degrees the WRONG way (ie: stays closed), 180 degrees, 135 degrees. it just WONT DO THE RIGHT ONE!!!



turn = llEuler2Rot(<0.0, 0.0, PI_BY_TWO/2.0>); and negative
turn = llEuler2Rot(<0.0, 0.0, PI_BY_TWO>); and negative
turn = llGetLocalRot() * llEuler2Rot(<0.0, 0.0, -90.0*DEG_TO_RAD>); and 45 and -45 and 135....

and with the local rot on the left and local rot on the right, and using rads and using deg to rad, and dividing by the root rot and NOT dividing by the root rot.


speaking of formulae.... isnt PI 360 degrees? so PI_BY_TWO is 180? isn't it? or is it? gah.


okay, so, in very SIMPLE terms. what is the formula to get an object to rotate 90 degrees COUNTERCLOCKWISE from its current position on the Z axis (and also, to rotatate the same, but CLOCKWISE)?


thank you. my brain thanks you.
_____________________
Why Johnny Can't Rotate:
http://forums.secondlife.com/showthread.php?t=94705
Bam Bu
Registered User
Join date: 20 Aug 2006
Posts: 8
06-17-2007 07:57
from http://en.wikipedia.org/wiki/Radian
The radian is a unit of plane angle, equal to 180/π degrees, or about 57.2958 degrees.

So pi would be 180 deg.
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
06-22-2007 04:27
okay.

pi is 180 TWO pi is 360.


that still doesnt help me rotate my book cover, though. ::sigh::
Ged Larsen
thwarted by quaternions
Join date: 4 Dec 2006
Posts: 294
06-22-2007 05:20
sometimes what helps is to have the script when touched do a:

llOwnerSay ( (string)llGetRot() );
or
llOwnerSay ( (string)llRot2Euler(llGetRot()) );

... and then manually move your prims to "roughly" the desired locations, touching them, and then just jotting down the rotations that you want to hard-code into your script.

One challenge, though, is correcting for the starting rotation, which usually involves using a rot / llGetRootRot() or something.
_____________________
- LoopRez, flexi prim skirt generating tool
- LinkRez, a necklace chain generator
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
06-23-2007 07:09
um...

i really want to calculate the new positions on the fly. so the book can be set at any angle, slapped on a hud, worn in a hand, sitting on a desk.... and it still opens and closes. is that too much to ask?? ;)


okay, i have this (based on improved door script by Ezhar Fairlight):

Rot90CW(rotation RR)
{
rotation rStart = llGetLocalRot();
rotation delta = llEuler2Rot(<0, 0, -1*PI_BY_TWO>);
rotation rEnd = delta * rStart;
llSetLocalRot(rEnd/RR);
}

Rot90CCW(rotation RR)
{
rotation rStart = llGetLocalRot();
rotation delta = llEuler2Rot(<0, 0, PI_BY_TWO>);
rotation rEnd = delta * rStart;
llSetLocalRot(rEnd/RR);
}



this is in the child; i am dutifully setting the local rot divided by the root rot (which is sent to the child prim on each open/close request).

now, this works wonderfully for the root (minus the /RR part, of course.) i click to open, it Rots 90 degrees CW i click to close, it Rots 90 degrees CCW. no matter which way i turn it. yay!

now when i stick it in a bloody child prim.... ::sigh::
im getting different results each click. sometimes it goes 90 degrees, sometimes 180 degrees, and not always in the right direction.

i get the same results whether i do delta * rStart or rStart * delta. (which according to my hazy understanding of rotations shouldn't be the same.)


okay, against ALL logic, i took out the /RR part. now it works. i don't know why or how.


I HATE ROTATIONS!!!
Ged Larsen
thwarted by quaternions
Join date: 4 Dec 2006
Posts: 294
06-23-2007 07:52
From: Bloodsong Termagant
... llSetLocalRot(rEnd/RR); ...

okay, against ALL logic, i took out the /RR part. now it works. i don't know why or how.


I HATE ROTATIONS!!!


That actually makes perfect sense. Since you are setting a LOCAL rot, you would NOT want to do the "root rot correction factor" of "/RR"
_____________________
- LoopRez, flexi prim skirt generating tool
- LinkRez, a necklace chain generator