Jump to content

Relative rotations


GloriaGlitter
 Share

You are about to reply to a thread that has been inactive for 552 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I wonder if someone might have some experience working with rotations to share as it has been sending me round the bend trying to figure this one out:

I have three objects - a rezzer objectwhich includes a script to rezz two other objects contained in the inventory of the rezzer object- one is a platform and the other is a box.

If I set the rezzer at rotation <0,0,0> and rezz the two other objects, the platform rezzes so that the rezzer object is in the centre and the box object is offset about 4 meters to the left of the rezzer.  

 llRezObject("Platform", llGetPos(), <0.0,0.0,0.0>, llGetRot(), 0);

 llRezObject("Box", llGetPos() + <-4.0,0.0,0.0>, <0.0,0.0,0.0>, llGetRot(), 0);

If I then rotate the rezzer, say by 45 degrees, and rez the two objects, the platform correctly rotates in line with the rezzer as it is centred, but the Box stays where it is but rotates around its own z axis.

What I really want is the box to move in an arc so it stays in the same relative position.

I know I need to somehow take account of the rezzer rotation and apply a calculation to the x and y values in the offset vector of <-4.0, 0.0.,0.0>.   

If I move the box physically using edit to the place where I want it to go to, I can see that I need to apply approx <1.22, 2.85, 0> to the offset to give a new offset of <-2.78, 2.85, 0>.

Have gone through the wiki on things related to rotations but couldn't see anything that seemed to answrer my question which is:  How do I generate the new x,y offset from the changed rotation value of the rezzer object?

Thanks.

Link to comment
Share on other sites

@GloriaGlitter..

9 minutes ago, Wulfie Reanimator said:

It's not real multiplication, but that's not important.

It's matrix algebra, which is not too hard to pick up.  For the most part, however, you don't even need to have much familiarity with matrix algebra.  The fundamental operations we use in SL are outlined pretty well at https://wiki.secondlife.com/wiki/Rotation .  As with a lot of things we have to do with scripting, though, the real challenge is not the mechanics as much as being able to visualize the physical geometry we are trying to model.  That's where many scripters get turned around.  ;) 

  • Like 1
Link to comment
Share on other sites

4 hours ago, Rolig Loon said:

Any linear transformation can be represented by matrixes, so yes, technically quaternionic algebra can be thought of as a matrix algebra, but I think it's more useful to think of it as its own thing. The main reason Vector*Quaternion isn't a real multiplication IMO is that the actual computation evaluates to Q*V*(Q^-1):

rotation NormRot(rotation Q)
{   float MagQ = 1/llSqrt(Q.x*Q.x + Q.y*Q.y +Q.z*Q.z + Q.s*Q.s);
    return  <Q.x*MagQ, Q.y*MagQ, Q.z*MagQ, Q.s*MagQ>;
}
default
{   state_entry()
    {   vector V = <llFrand(1.0),llFrand(1.0),llFrand(1.0)>;
        rotation R = NormRot(<llFrand(1.0),llFrand(1.0),llFrand(1.0),llFrand(1.0)>);

        vector   X = V*R;
        rotation Y = (ZERO_ROTATION/R)*<V.x,V.y,V.z,0>*R; // linden rotations are backwards.
        // X and Y should be the same.
        llOwnerSay(llList2CSV([X,Y]));
    }
}

but that's just semantics. . .

  • Thanks 1
Link to comment
Share on other sites

3 hours ago, Quistess Alpha said:
        vector   X = V*R;
        rotation Y = (ZERO_ROTATION/R)*<V.x,V.y,V.z,0>*R; // linden rotations are backwards.

Since I can't try your script (not in-world) and maths scare me, is the ultimate goal to show that these two are equivalent?

D'oh! I could not read the next line due to the color!

 // X and Y should be the same.

Never mind, but I left my post so you'd have proof someone read your script and tried to understand it!

Thanks for the maths lesson!

  • Thanks 1
Link to comment
Share on other sites

Many thanks for quick responses to my intial question.  The vector offset multiplied by the llGetRot was the solution to my issue.  I had thought it was going to be a lot scarier than that having read the Rotation wiki with degrees to radians, quaternions and euler calculations - phew.

Cheers

  • Thanks 1
Link to comment
Share on other sites

42 minutes ago, GloriaGlitter said:

Many thanks for quick responses to my intial question.  The vector offset multiplied by the llGetRot was the solution to my issue.  I had thought it was going to be a lot scarier than that having read the Rotation wiki with degrees to radians, quaternions and euler calculations - phew.

Cheers

That dude Euler really needs a..day off!

  • Haha 1
Link to comment
Share on other sites

9 hours ago, Quistess Alpha said:

but that's just semantics. . .

... and in the end, whatever semantic context helps you make sense of the physical operations is fair game.  ;)  One of the joys of mathematics is discovering that you can get the same answers to most problems by using tools that don't look at all the same.  It's like finding that you can open a paint can with a screwdriver, a chisel, or even a claw hammer.

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 552 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...