Jump to content

Rotation Troubles x.x


Shymus Roffo
 Share

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

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

Recommended Posts

I am trying to make a light switch to practice my rotation skills as i am not good with them. I am having troubles with problems with the object if it is rotated a certain way.

 

flipSwitch(integer n) {
    vector vrot = llRot2Euler(llGetRot());
    if(n) vrot += <-30 * DEG_TO_RAD,0,0>;
    else vrot += <30 * DEG_TO_RAD,0,0>;
    llSetRot(llEuler2Rot(vrot));
}

integer on = FALSE;
default {
    touch_start(integer n) {
        flipSwitch(on = !on);
    }
}

 

If the object is rotated on Z axis then the rotations will start to act all weird and won't rotate like a switch properly.

Also if you can point me to a place to learn rotations easily, it would help! :P

  • Like 1
Link to comment
Share on other sites

this is from some rotation guru..Dora mebbe?..

rotation Rot;default{    state_entry()    {  Rot = llEuler2Rot(<30.0, 0.0, 0.0>*DEG_TO_RAD);    }    touch_start(integer total_number)    {   llSetRot(Rot*llGetLocalRot());        Rot=ZERO_ROTATION/Rot; //invert the rotation     }}

 a few rotation links...

Dora's - http://wiki.secondlife.com/wiki/User:Dora_Gustafson/llAxes2Rot_right_and_wrong

Grandma Bates - http://www.sluniverse.com/php/vb/tutorials/62235-basic-introduction-rotations.html

Link to comment
Share on other sites

Rotations become a lot easier once you stop trying to understand the mathematics behind them and, instead, concentrate on learning a few simple rules and how to apply them.

The main point of confusion, I think, is that the * operator, when applied to rotations, doesn't mean "multiply."   It means "translate by," and -- unlike multiplications -- the order does matter.   The simplest way -- I think -- to understand it is to see llSetRot(rot * llGetRot()) (or * llGetLocalRot() or whatever) as meaning "Use the axes you see in the editor with the local ruler turned on".   In contrast, "llSetRot(llGetRot()*rot) means "use the axes you see with the world ruler turned on").

  • Like 1
Link to comment
Share on other sites


shymus Roffo wrote:

... I hate working with rotations but i need to learn them.

one of things that we can struggle with in the beginning is understanding direction in cube space and how we think about it

the solution that Xiija mention is far more elegant. If tho look at how you been thinking about it, bc your codes, then consider the mod:

 

flipSwitch(integer dir) {        rotation rot =        llEuler2Rot(<0.0, 30.0 * (float)dir, 0.0> * DEG_TO_RAD) *        llGetLocalRot();           llSetLocalRot(rot);}integer on = -1;default {    touch_start(integer num_detected)     {        flipSwitch(on = -on); // flip between -1 and 1    }}

 

Link to comment
Share on other sites

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