Wandering Soulstar Posted February 4, 2019 Share Posted February 4, 2019 (edited) 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 February 4, 2019 by Wandering Soulstar Link to comment Share on other sites More sharing options...
steph Arnott Posted February 4, 2019 Share Posted February 4, 2019 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 More sharing options...
Wandering Soulstar Posted February 4, 2019 Author Share Posted February 4, 2019 @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? Link to comment Share on other sites More sharing options...
steph Arnott Posted February 4, 2019 Share Posted February 4, 2019 (edited) 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 February 4, 2019 by steph Arnott 1 Link to comment Share on other sites More sharing options...
Wandering Soulstar Posted February 4, 2019 Author Share Posted February 4, 2019 Brilliant! Thanks Steph! 1 Link to comment Share on other sites More sharing options...
Wulfie Reanimator Posted February 4, 2019 Share Posted February 4, 2019 (edited) 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 February 4, 2019 by Wulfie Reanimator Link to comment Share on other sites More sharing options...
Wandering Soulstar Posted February 4, 2019 Author Share Posted February 4, 2019 or just do it as Steph suggested?? 1 Link to comment Share on other sites More sharing options...
steph Arnott Posted February 4, 2019 Share Posted February 4, 2019 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 More sharing options...
Estelle Pienaar Posted February 5, 2019 Share Posted February 5, 2019 (edited) Edited my post once more as I maybe shouldn't make judgements without knowing the situation in detail. Edited February 5, 2019 by Estelle Pienaar 1 Link to comment Share on other sites More sharing options...
Kyrah Abattoir Posted February 6, 2019 Share Posted February 6, 2019 On 2/4/2019 at 3:34 PM, steph Arnott said: Actually no they do not have four components, there are six. In what universe? Link to comment Share on other sites More sharing options...
steph Arnott Posted February 6, 2019 Share Posted February 6, 2019 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. Link to comment Share on other sites More sharing options...
chibiusa Ling Posted February 6, 2019 Share Posted February 6, 2019 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 More sharing options...
steph Arnott Posted February 6, 2019 Share Posted February 6, 2019 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 More sharing options...
Wandering Soulstar Posted March 18, 2019 Author Share Posted March 18, 2019 (edited) 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 March 18, 2019 by Wandering Soulstar Link to comment Share on other sites More sharing options...
KT Kingsley Posted March 18, 2019 Share Posted March 18, 2019 From a quick glance at your examples, the formula you want is mirror_x = 360.0 - base_x. 1 Link to comment Share on other sites More sharing options...
Wandering Soulstar Posted March 18, 2019 Author Share Posted March 18, 2019 Spot on (and staring me right in the face) @KT Kingsley Thanks!!!! Link to comment Share on other sites More sharing options...
steph Arnott Posted March 18, 2019 Share Posted March 18, 2019 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. Link to comment Share on other sites More sharing options...
Wandering Soulstar Posted March 18, 2019 Author Share Posted March 18, 2019 @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. Link to comment Share on other sites More sharing options...
steph Arnott Posted March 18, 2019 Share Posted March 18, 2019 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? Link to comment Share on other sites More sharing options...
Wandering Soulstar Posted March 18, 2019 Author Share Posted March 18, 2019 @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! Link to comment Share on other sites More sharing options...
Recommended Posts
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