move a non-physical object
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
11-28-2008 10:04
I am having a brainstorm and, as usual, rotations are the cause of my confusion.
How do I tell a prim to move, using non-physical movement, 1 meter on its local (as opposed to the sim's) axis? That is, always move 1 meter in whatever direction (for example) side 2 is facing?
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
11-28-2008 10:08
Consider what happens when you multiply a vector (eg, <0,0,1>  by a rotation (eg, llGetRot()). Experiment.
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
11-28-2008 11:32
Thank you.. I guess the root of my confusion is that I can't quite grasp what multiplying a vector by a rotation is doing.
I mean, when I multiply something by 2, I end up with twice what I started with, and when I multiply it by 0.5, I've got half.
I don''t, though, understand what I am actually doing when I multiply <171.02190, 189.95840, 25.61560> by <0.00000, 0.00000, 0.30902, 0.95106>. The result appears to be <26.70486, 254.20370, 25.61560>, but I have no idea what that last set of figures indicates..
|
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
|
11-28-2008 12:45
From: Innula Zenovka Thank you.. I guess the root of my confusion is that I can't quite grasp what multiplying a vector by a rotation is doing.
I mean, when I multiply something by 2, I end up with twice what I started with, and when I multiply it by 0.5, I've got half.
I don''t, though, understand what I am actually doing when I multiply <171.02190, 189.95840, 25.61560> by <0.00000, 0.00000, 0.30902, 0.95106>. The result appears to be <26.70486, 254.20370, 25.61560>, but I have no idea what that last set of figures indicates.. Don't look at the numbers, just understand that you're taking the vector and rotating it around the global axes by the chosen rotation.
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
11-28-2008 13:28
slight clarification (becuase vectors can represent different things) consider a vector representing the local referenced point you want to move to, like say, 2 meters, object west <-2, 0, 0,> works great, it's a point 2m away in the proper direction IF you're aligned to the world so to correct it you apply the objects rotation to the point to swing it around the object... lets say your objects north/away is facing world east... applying a rotation to a vector, spins that vector around as if it were a stick, giving you a new vector facing, but the same magnitude(distance/length from the center) <vectorWest2> * <quatRotateClockwiseFromTop90deg> = <vectorNorth2> = <0, 2, 0> if you need a global point, simply add the objects global position to the above result. some more useful bits here http://wiki.secondlife.com/wiki/Rotation
_____________________
| | . "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... | - 
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
11-28-2008 14:34
From: Innula Zenovka I am having a brainstorm and, as usual, rotations are the cause of my confusion.
How do I tell a prim to move, using non-physical movement, 1 meter on its local (as opposed to the sim's) axis? That is, always move 1 meter in whatever direction (for example) side 2 is facing? It is not so complicated  llSetPos( llGetPos() + llRot2Fwd( llGetRot())) ; // move prim plus one meter on it's X-axis llSetPos( llGetPos() + llRot2Left( llGetRot())) ; // move prim plus one meter on it's Y-axis llSetPos( llGetPos() + llRot2Up( llGetRot())) ; // move prim plus one meter on it's Z-axis llSetPos( llGetPos() - llRot2Fwd( llGetRot())) ; // move prim minus one meter on it's X-axis llSetPos( llGetPos() - llRot2Left( llGetRot())) ; // move prim minus one meter on it's Y-axis llSetPos( llGetPos() - llRot2Up( llGetRot())) ; // move prim minus one meter on it's Z-axis
_____________________
From Studio Dora
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
11-29-2008 06:28
Thank you all for your help. While I certainly don't fully understand how this all works, I think I am slowly but surely getting there, with the help of this forum and the wiki.
I think the root of my confusion has been -- and still is, to an extent, despite Void's very helpful explanation -- what exactly I'm doing when I use a script to move a prim to a particular point.
Assuming I am not using llRot2Fwd and so on (for which I am eternally grateful to Dora for telling me about), am I correct in thinking that when I multiply a vector by a local rotation, I'm, in effect, saying "turn and face the point in space, relative to you, indicated by that vector"? And if I'm using a global rotation, I'm saying "turn and face the point on the sim indicated by that vector".
That is, the stuff about llGetRot and llGetLocalRot is telling it to calculate what rotations round its various axes it must describe in order to face the right way. And then, when I've got it facing the way I want, I move it there?
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
11-29-2008 07:28
From: Innula Zenovka Assuming I am not using llRot2Fwd and so on (for which I am eternally grateful to Dora for telling me about), am I correct in thinking that when I multiply a vector by a local rotation, I'm, in effect, saying "turn and face the point in space, relative to you, indicated by that vector"? And if I'm using a global rotation, I'm saying "turn and face the point on the sim indicated by that vector". No, local rotation means "turn this prim in the linkset to point to the point in space relative to the root prim of the linkset (object)". After you know the rotation you want, you take the vector you want to move (relative to the prim or the linkset) and rotate that vector by the rotation. So if you want to move relative to your "up", you take your vector <0,0,1> and rotate *it* relative to llGetRot(), and that gives you a new vector that points in your local vertical, relative to the sim. If you multiply that by the distance you want to move, you'll move "up" that far.
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
11-29-2008 09:04
Bah. For these purposes, don't even think of them as "rotations". Think of them as "transformations". A prim's llGetRot() is a transformation from the prim's local coordinate system to the global region coordinate system. You aren't "rotating" the vector physically. You are just expressing it in different terms. Think of each prim as having a set of little axes, all pointed according to how that prim is oriented. Taking a step along that prim's local x-axis is equivalent to taking a step equal to '<1,0,0>*llGetRot()' (or 'llRot2Fwd(llGetRot())'; same thing really) in region coordinates. You can even see a prim's local coordinate system by choosing "Local" in the edit window before selecting it for editing.
|