Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Moving and Rotating

Jack Hathor
Registered User
Join date: 13 Jul 2004
Posts: 10
12-26-2005 11:32
Hi,

I really could use some help on the following;

I have 2 objects, from both i know the position and rotation.

Now 1 object moves to another place, new position and new rotation are known.

How do i get the 2nd object to be in a position and rotation that it reflects the original relation between the 2.

Thanks in advance,
Jack Hathor
Lightwave Valkyrie
Registered User
Join date: 30 Jan 2004
Posts: 666
12-26-2005 13:03
like a follower script?
-LW
Jack Hathor
Registered User
Join date: 13 Jul 2004
Posts: 10
more then a followerscript
12-26-2005 13:25
I want this script to be precise,

Concider the following please, dealing with 2 objects from which one moves away.

// The old setting .....
vector OldPos1 = <x,x,x>; // the coordinates dont really matter, the idea is
rotation OldRot1 = <x,x,x,x>; // there is some kind of relationship between them
vector OldPos2 = <x,x,x>; // in position and rotation
rotation OldRot2 = <x,x,x,x>;

// The new setting ....
vector NewPos1 = <y,y,y>; // The new position and rotation for the 1st object
rotation NewRot1 = <y,y,y,y>; // are known

// And now the questions ...... What should be the next formulas ?
vector NewPos2 = NewPos1 + (OldPos2 - OldPos1); // think i got that right (?)
vector NewRot2 = NewRot1 * (OldRot2 / OldRot1); // and that sure isnt right ..

Hope you can make something out of this,
Jack,
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
Relative position
12-27-2005 02:32
I believe that you would calculate the relative position and rotation in first case by subtracting those of the second objects from the those of the first. When object one has moved, you would add the results of the previous calculation to object one new position and rotation to obtain those for object two.
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
12-27-2005 02:42
CODE
newpos2 = newpos1 + ( ( (oldpos2 - oldpos1) / oldrot1 ) * newrot1 );
newrot2 = ( oldrot2 / oldrot1 ) * newrot1;

I think this is right, but I wouldn't bet my life on it.
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG