Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotation - how is your rocket science?

Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
10-27-2008 02:22
Rotation is a total furffy for me.

I have a line:

PRIM_TEXTURE, 2, "Volume 5", <0.075,0.390,0>, <0.315,0.290,0>, -90

Obviously -90 is not going to give me -90 degrees - How do I get it?

I have read the wiki page but even more confused after doing so.

Thanks
Urrong Urnst
Registered User
Join date: 12 Jul 2008
Posts: 49
10-27-2008 02:38
to change degrees to quarternions (rotation) u have to first change it to radians and then to rot. The code would look like:
rotation rot = llEuler2Rot(<0, 0, -90> * DEG_TO_RAD);
Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
10-27-2008 02:41
errr - if you say so - thanks I'll muck around with it
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
10-27-2008 02:53
From: Tarak Voss
Rotation is a total furffy for me.

I have a line:

PRIM_TEXTURE, 2, "Volume 5", <0.075,0.390,0>, <0.315,0.290,0>, -90

Obviously -90 is not going to give me -90 degrees - How do I get it?

I have read the wiki page but even more confused after doing so.

Thanks

And the context please!
This is merely a string of parameters and I am not going to guess for what:(
A piece of advice:
1.All angles in LSL are in radians, except in those functions that convert from degrees to radians.
2.A rotation is not an angle(not degrees and not radians) but "quaternion" composed of 4 numbers each in the range: [-1.0;1.0].
_____________________
From Studio Dora
Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
10-27-2008 03:06
The context is :

llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, PRIM_SIZE, <1.009, 0.702, 0.160>, PRIM_TEXTURE, 2, "Volume 5", <0.075,0.390,0>, <0.315,0.290,0>, ??????]);

I am setting prim paramters and one of the textures needs to be rotated -90degrees.
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
10-27-2008 03:40
In that context, you just need to convert degrees to radians... no quaternions or vectors needed. Here's what you'd need:

-90 * DEG_TO_RAD


So your complete call would be:

lSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, PRIM_SIZE, <1.009, 0.702, 0.160>, PRIM_TEXTURE, 2, "Volume 5", <0.075,0.390,0>, <0.315,0.290,0>, -90 * DEG_TO_RAD]);
Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
10-27-2008 04:23
You are a God's send - thankyou
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
10-27-2008 05:55
From: Tarak Voss


I have read the wiki page but even more confused after doing so.

Thanks

OK, Professor Ponzu will pontificate...

As already pointed out, the -90 is an angle in degrees. The Editor uses degrees. But scripts use "radians" which is sort of like converting from dollars to Euros.

Radians = degrees * DEG_TO_RAD.

It turned out you didn't really need rotations, but I will explain anyway, for future generations to appreciate and admire 8-)

In the editor, we use three numbers, in degrees, to describe a rotation. These three numbers are called an "Euler" (famous dead mathematician). For example, <10, 20, 30> (like you could put in the rotation windows in the Build Editor).

This means 1) rotate 30 degrees around the Z-axis, then 20 degrees around the Y axis, then 10 degrees around the X axis. This of a jet airplane. This would be 30 degrees to the left, 20 degrees down, and then 10 degrees of bank.

However, in LSL, we don't use Euler's directly. We use a data type called a "rotation". So, to set the rotation of our plane, we might need to convert the Euler to a rotation, like this.

rotation r = llEuler2Rot( <10,20,30>*DEG_TO_RAD );

llSetRot( r );
_____________________
So many monkeys, so little Shakespeare.
Tarak Voss
Meanderer
Join date: 14 Oct 2006
Posts: 330
10-27-2008 06:04
chuckle
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
10-27-2008 08:50
and since you now know that it's in radians, you can actually use the built in constants....

PI = 180deg
PI_BY_TWO = 90deg
TWO_PI = 360deg (useless for this, but helpful elsewhere)
_____________________
|
| . "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...
| -