Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotation and vector in vehicles

Ryder Spearmann
Early Adopter
Join date: 1 May 2006
Posts: 216
06-05-2009 22:43
Hi all...

have an odd thing to deal with...

I need to change a vector by way of a rotation.

I have a vehicle, physical, that I want to change pitch using a rotation... and I want to change the thrust with llSetForce() to match that rotation.

the thing is... I am just not sure how to make set force work with, lets say... a 10 degree change in Y rotation...

help!?

-rs-
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-05-2009 23:12
if you use local axis all you should have to do is turn the object, and the force will line up behind it.
_____________________
|
| . "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...
| -
Kayaker Magic
low carbonated footprint
Join date: 11 Sep 2008
Posts: 109
06-05-2009 23:24
Since you know what the rotation of the vehicle is, just take your scalar speed and rotate it into a vector. The following line assumes the front of your vehicle is the local X axis:

Vector v=<speed,0,0>*llGetRot(); //rotate a +X vector to point in the new direction

Or if you know the previous force and that the nose pitched 10 degrees, you could do this:

Vector newforce=oldforce*llEuler2Rot(<0,10.,0>*DEG_TO_RAD);
Ryder Spearmann
Early Adopter
Join date: 1 May 2006
Posts: 216
06-06-2009 08:22
Kayker... thanks so much...
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-06-2009 15:13
llSetForce( <1, 0, 0>, TRUE );

that will send your vehicle forward on it's local +X axis, regardless of region orientation, if you're facing north you'll go north, south, south, etc.
_____________________
|
| . "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...
| -
Ryder Spearmann
Early Adopter
Join date: 1 May 2006
Posts: 216
06-07-2009 09:37
I do have some additional questions...

in the case of llGetOmega.... the wiki does not say if the rotation returned is based on local coords. I want to assume it is... but for my physical object, it is acting like it is in regional reference...

Also, llGetRot and llGetLocalRot are acting the same for my physical object... again pointing to the region.

Is this correct?
Ryder Spearmann
Early Adopter
Join date: 1 May 2006
Posts: 216
06-07-2009 09:50
Next... assuming that I have discovered that GetRot and GetOmega think in regional terms for physical objects... how can I translate a desire to have, say, a local pitch (y axis) of 10 degrees... but express that in REGIONAL terms?

Thanks!