Jump to content
Wandering Soulstar

Question on Rotations - Mirror

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

Share this post


Link to post
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>);

Share this post


Link to post
Share on other sites

@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?

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Just now, Kyrah Abattoir said:

In what universe?

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

Share this post


Link to post
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 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
3 minutes ago, Wandering Soulstar said:

Spot on (and staring me right in the face) @KT Kingsley  Thanks!!!!

What i gave you will rotatate the second object 180 degrees to the first. Which is what you asked. The first object could 50 degrees the code will produce a value for the second of 230 degrees on the Z.

Share this post


Link to post
Share on other sites
1 minute ago, Wandering Soulstar said:

@steph Arnott I know you gave me exactly what I asked for .. I had just not described my problem fully or properly, so all my fault.

Are you rezzing an object rotated?

 

Share this post


Link to post
Share on other sites

@steph Arnott No what I am doing is setting a prim to mirror the angle of another prim, as in the two sides of a  roof for example. The previous code snippets helped, and what I was missing was the formula to get the 'mirror' value .. which KT kindly pointed out to me .. so all good now!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...