Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotation around own axis?

Miffy Fluffy
Registered User
Join date: 27 Feb 2006
Posts: 25
01-05-2009 01:08
I want to rotate a single prim around one of it's own axis (not around a world axis).
Just like rotation works when setting the Ruler mode to Local.

I've found algoritms to do this but these are complex and would require lots of code for a basic rotation. Is there a simple way to do this? I tried llAxisAngle2Rot but I don't understand how I can calculate a local X, Y or Z axis from llGetRot().
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
01-05-2009 01:25
Spin like in llTargetOmega() or rotate like in llSetRot()?
Anyway I don't understand the question.
As I recall: a single prim's axis are global no matter how you turn it and any rotation will refer to those axis, no?
Maybe what you need is to add a rotation to an existing orientation:
rotation R = < 0.0, 0.0, 1.0, 0.0 >; // rotation for 180 deg around the Z axis (as an example )
llSetRot( llGetRot()*R ); // add rotation to an existing one
( please note that the operator is a '*' and not a '+')
_____________________
From Studio Dora
Virrginia Tombola
Equestrienne
Join date: 10 Nov 2006
Posts: 938
01-05-2009 07:17
Unless you need it as part of the linkset, you could just use TargetOmega:
http://rpgstats.com/wiki/index.php?title=LlTargetOmega
_____________________


Horses, Carriages, Modern and Historical Riding apparel. Ride a demo horse, play whist, or just loiter. I'm fair used to loiterers.

http://slurl.com/secondlife/Caledon%20Eyre/48%20/183/23/
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-05-2009 08:29
This is a simple question guys:

local x-axis: llRot2Fwd(llGetRot())
local y-axis: llRot2Left(llGetRot())
local z-axis: llRot2Up(llGetRot())
Miffy Fluffy
Registered User
Join date: 27 Feb 2006
Posts: 25
01-06-2009 06:51
From: Hewee Zetkin
This is a simple question guys:

local x-axis: llRot2Fwd(llGetRot())
local y-axis: llRot2Left(llGetRot())
local z-axis: llRot2Up(llGetRot())


Thanks! That's it, for others that need this, here's how to use it to rotate around these local axis:

llSetRot( llGetRot() * llAxisAngle2Rot( llRot2Fwd(llGetRot()),(float)angle) );
llSetRot( llGetRot() * llAxisAngle2Rot( llRot2Left(llGetRot()),(float)angle) );
llSetRot( llGetRot() * llAxisAngle2Rot( llRot2Up(llGetRot()),(float)angle) );
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
01-06-2009 13:18
You should also be able to do:

llSetRot(llEuler2Rot(DEG_TO_RAD * <angle around x, angle around y, angle around z>;) * llGetRot());
_____________________
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-06-2009 17:37
From: Tyken Hightower
You should also be able to do:

llSetRot(llEuler2Rot(DEG_TO_RAD * <angle around x, angle around y, angle around z>;) * llGetRot());

Yep. That too if you plan to use llSetRot() instead of something like llTargetOmega() or llApplyRotationalImpulse() or something like that.