Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Grabbing one axes?

Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
11-13-2009 06:13
Hi.

I want to just get the last two rotation parameters from a rotation and use them on the fly, how can I specifically get the last two, or individually rather than having to get all 4?


Thanks.
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
11-13-2009 07:30
You can get the parts of a rotation or vector using x, y, z, s suffixes. This only works if you first assign them to variables, it doesn't work with a literal constant or on-the-fly result.

So, for vector v

you'll have v.x, v.y and v.z

And, for rotation r

you'll have r.x, r.y, r.z, r.s
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
11-13-2009 07:33
CODE

rotation MyRot = llGetRot();
integer MyRotx = MyRot.x;
integer MyRoty = MyRot.y;
integer MyRotz = MyRot.z;
integer MyRots = MyRot.s;


You can always get the separate components of a rotation this way. However, manipulating them separately will lead to unpredictable results. Rotations are quaternions, so the x,y,z,s components cannot be interpreted directly as rotations around specific axes. If that's your purpose, you need to do something like this:

CODE

rotation x_45 = llEuler2Rot( <45 * DEG_TO_RAD, 0, 0> ); // Rotating 45 degrees around the X axis
rotation new_rot = llGetRot() * x_45;
llSetRot(new_rot);


See http://wiki.secondlife.com/wiki/User:Void_Singer/Rotations
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Nyx Alsop
Registered User
Join date: 14 Dec 2008
Posts: 252
11-13-2009 08:39
Puuuuuuuuuuufect.
Narcof Hax
Store Owner
Join date: 27 Aug 2008
Posts: 20
11-14-2009 04:55
Is there any way to use this with an object that is turning, in relation to the way the object is facing, so that it always rotates to the left (i.e. to simulate resting when being switched off)?
_____________________
Owner of ~*MG*~ Designs - http://slurl.com/secondlife/Pongsonhwa/113/243/596
jeaniesing Trilling
Loves to animate & script
Join date: 21 Oct 2006
Posts: 61
11-14-2009 07:44
if you go llRot2Euler you get a vector rather than a quaternion.... so then you have control over the axes the way we lesser humans think

default
{

touch_start(integer total_number)
{
vector newrot = (llRot2Euler(llGetRot())*RAD_TO_DEG)+<0,0,30>;
llSetRot(llEuler2Rot(newrot*DEG_TO_RAD));
}
}

but if you mean "turning" via llTargetOmega, then no... as (potentially) everyone sees a different side of the turning object based on their viewer....
_____________________
Pinastri/113/171/30
Narcof Hax
Store Owner
Join date: 27 Aug 2008
Posts: 20
11-14-2009 14:56
No, not using llTargetOmega I mean it could end up facing pretty much any random direction at the point where it gets laid to rest, so what I have been trying to do is get it to lay down to it's own left side by a certain amount of angle at the point when it gets switched off, the problem is I am having problems trying to figure out at any given time what rotation represents that rotation to its left side relative to the direction it happens to be facing.


From: jeaniesing Trilling
if you go llRot2Euler you get a vector rather than a quaternion.... so then you have control over the axes the way we lesser humans think

default
{

touch_start(integer total_number)
{
vector newrot = (llRot2Euler(llGetRot())*RAD_TO_DEG)+<0,0,30>;
llSetRot(llEuler2Rot(newrot*DEG_TO_RAD));
}
}

but if you mean "turning" via llTargetOmega, then no... as (potentially) everyone sees a different side of the turning object based on their viewer....


That really helped me with something else though - thanks!
_____________________
Owner of ~*MG*~ Designs - http://slurl.com/secondlife/Pongsonhwa/113/243/596