Jump to content

Question on Rotations - Mirror


Wandering Soulstar
 Share

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

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

Recommended Posts

Hi All,

Rotations and the math behind them are my bane in LSL .. just cannot get my head around them. What I am trying to do is mirror the rotation of a prim.. i.e. If Prim A is rotated at 45 degrees on the x axis, I want to set Prim B's x axis rotation to 225 degrees. Is it as simple as:

myRot.x = mirrorRot.x + (180 * DEG_TO_RAD);

.. or is there more to it?

Edited by Wandering Soulstar
Link to comment
Share on other sites

15 minutes ago, Wandering Soulstar said:

Hi All,

Rotations and the math behind them are my bane in LSL .. just cannot get my head around them. What I am trying to do is mirror the rotation of a prim.. i.e. If Prim A is rotated at 45 degrees on the x axis, I want to set Prim B's x axis rotation to 225 degrees. Is it as simple as:


myRot.x = mirrorRot.x + (180 * DEG_TO_RAD);

.. or is there more to it?

Well yo need the first rotation then adjust the second. something like this 

rotation sumRot     =     llGetRot(); 

rotation rot        =     sumRot * llEuler2Rot(<0.0,0.0,PI>);

Link to comment
Share on other sites

2 minutes ago, Wandering Soulstar said:

@steph Arnott  .. left out the collecting of the rots .. just assume they are already in myRot and mirrorRot  🙂

So, if I understand the example .. this would result rot having a 180 degree change in it's z axis? i.e. depending on which axis it is I put PI in the desired axis position in the vector?

The axis you need to set, I just used Z axis.

Edited by steph Arnott
  • Thanks 1
Link to comment
Share on other sites

The problem with "myRot.x" is that rotations ("quaternions") have 4 components, <x y z w>, and changing just one of those isn't going to do what you expect.

As long as you convert your rotation to a regular vector first (llRot2Euler), you'll be able to do it just like you were trying to. (Just remember to convert back with llEuler2Rot.)

Side-note: "180 * DEG_TO_RAD" is the same as PI.

Edited by Wulfie Reanimator
Link to comment
Share on other sites

4 minutes ago, Wulfie Reanimator said:

The problem with "myRot.x" is that rotations ("quaternions") have 4 components, <x y z w>, and changing just one of those isn't going to do what you expect.

As long as you convert your rotation to a regular vector first (llRot2Euler), you'll be able to do it just like you were trying to. (Just remember to convert back with llEuler2Rot.)

Side-note: "180 * DEG_TO_RAD" is the same as PI.

Actually no they do not have four components, there are six.

Link to comment
Share on other sites

5 minutes ago, steph Arnott said:

Try learning euler three dimensional mathmatics. The correct short hand notation is X, Y, Z, S. S being the the face of the sphere.

Your talking about the six transformational degrees of freedom I think. The 3 x translational and 3 x rotational and if I remember correctly thats only a thing in duel quaternions. They are talking about how we represent it in LSL aka the rotational variable containing four float components 

Link to comment
Share on other sites

Just now, chibiusa Ling said:

Your talking about the six transformational degrees of freedom I think. The 3 x translational and 3 x rotational and if I remember correctly thats only a thing in duel quaternions. They are talking about how we represent it in LSL aka the rotational variable containing four float components 

I gave the solution.

Link to comment
Share on other sites

  • 1 month later...

All .. just was finally debugging inworld an realised I had, by the example given, not fully explained what I am trying to do. The previous answers around EulertoRot and back helped .. but I realised that I need to calculate the actual value I need to add .. it is not 180 as I gave in the example.

What I want to do is mirror an angle ... this means if base x is 300 .. mirror x is 60; if base x is 330 .. mirror x is 30.; etc ....

Does anyone know of a formula to be able to calculate this? I only want to change the selected axis rotation ...

Edited by Wandering Soulstar
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1911 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...