Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llSetRot()

Nexus Nash
Undercover Linden
Join date: 18 Dec 2002
Posts: 1,084
03-22-2003 23:39
For some reason when ever I set this as 0.9 the degs are only 84 instead of 90... if I set 1.80 the degs are 114 instead of 180.... and so on... is there anyway to get an exact value? like setting 1.80 so it is 180? I find it becomes exponential when you come closer to 180 degs... Does anyone have a solution to this?
_____________________
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
03-23-2003 01:51
edit i had a reply concerning that fact that the theta in the rotation was in radians, but it occurs to me that that isn't what is really going on.

nexus, could you post the exact line of code?
_____________________
i've got nothing. ;)
Nexus Nash
Undercover Linden
Join date: 18 Dec 2002
Posts: 1,084
03-23-2003 10:22
From what I remeber... until I get on tonight I can't post it... so i'll try to build the code again. This si for the minute hand of a clock.... is it in Radiants? becuase I thought 1.8 was 180 degs... anyways.. here the code.

rotation rot;

state_entry
{
llListen(0,"",llGetOwner(),"";);
}
listen(..... string message)
{
string minutes = (integer)message

if (message < 30)
{
rot.x = -((minutes * 1.8) / 30))
llSetRot(rot);
}
.....



}
after the llSetRot there is more code... but it's an if structure that makes the :30 to :59 protion of the time.... even with this little part if "message = 15" the rotation in Degs.. will only be -84 instead of -90.
_____________________
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
03-23-2003 10:45
see this excelent thread:
/invalid_link.html

so what you probably want is something like (note, written before coffee, so use with caution):
CODE

float minutes = 39.0; /* it is the 39th minute of the hour, say */
float minPerHour = 60.0; /* this may be different if you do not live on Earth */
float angle;
rotation rot;

angle = minutes / minPerHour * TWO_PI; /* angle in radians */

rot = < llSin(angle / 2.0) , 0, 0, llCos(angle /2.0)>;
llSetRot(rot);


This is for an absolute rotation about x. For rotation about y or z swap the llSin term with one of the 0 terms. For rotation about an arbitrary axis, consult your local mathematician.
Nexus Nash
Undercover Linden
Join date: 18 Dec 2002
Posts: 1,084
03-23-2003 10:56
From: someone
Originally posted by Wednesday Grimm ^
CODE

rot = < llSin(angle / 2.0) , 0, 0, llCos(angle /2.0)>;



I don't grasp the bold part... what is it?
_____________________
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
03-23-2003 11:06
From: someone
Originally posted by Nexus Nash
I don't grasp the bold part... what is it?

From: someone
Originally posted by Andrew Linden in the thread linked above
Quaternions can be hard to grasp[...]


It's just math, rotations in 3 dimensions are complicated and require 4 terms to specify. Given the way the rotations are specified in SL, it works out that the 4th term is that llCos statement. (This is a fancy way of me saying "I don't really know";).
Nexus Nash
Undercover Linden
Join date: 18 Dec 2002
Posts: 1,084
03-23-2003 11:10
Ok this is after reading the Linden thread...
CODE

rotation llEuler2Rot (vector vec);

Returns the rotation represented by Euler Angle vec.

These are especially useful if you want to rotate an object by a know amount, say 90 degrees (or PI/2 radians), around a specific axis (say the z, or up axis).

newrot = llGetRot() * llEuler2Rot(<0,0,PI> );


so if I need to make it say... 15th minute I can simply use 2/PI (radiants) and llEuler2Rot(<PI/2,0,0>;) so if I want everyminute I can do...

CODE

rotation rot;

state_entry
{
llListen(0,"",llGetOwner(),"");
}
listen(..... string message)
{
string minutes = (integer)message

if (message < 30)
{
rot = llEuler2Rot(<0,0,value of the deg in RADs like 15th
minute is PI/2 and 10th minut is PI/3... 20TH minute is 2PI/3 am I one the right track?
>
llSetRot(-rot);
}
}

justa question.... I would have to make a
CODE

rot = llEuler2Rot(<minutes*PI/30,0,0>)
llSetRot(-rot);


_____________________