Shymus Roffo Posted March 5, 2014 Share Posted March 5, 2014 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 1 Link to comment Share on other sites More sharing options...
Xiija Posted March 6, 2014 Share Posted March 6, 2014 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 More sharing options...
Shymus Roffo Posted March 6, 2014 Author Share Posted March 6, 2014 That seems to work, Thank you. Didn't think of that function llGetLocalRot(). I hate working with rotations but i need to learn them. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted March 6, 2014 Share Posted March 6, 2014 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"). 1 Link to comment Share on other sites More sharing options...
irihapeti Posted March 6, 2014 Share Posted March 6, 2014 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 More sharing options...
Ohjiro Watanabe Posted March 8, 2014 Share Posted March 8, 2014 There was someone that used to have in their signature, "if rotations were easy everything would be spinning". Still makes me chuckle. 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