User talk:Brattle Resident

From Second Life Wiki
Revision as of 15:17, 14 July 2014 by Sei Lisa (talk | contribs) (getCurrentAngle performance and code memory)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

getCurrentAngle performance and code memory

Your method works but it's a bit overkill and doesn't perform very well (in my experience, llRot2Axis and llRot2Angle are slowish). Here's an alternative:

<lsl> float getCurrentAngle() {

   vector fwd = <1,0,0> * llGetRootRotation();
   return llAtan2(fwd.x, fwd.y);

} </lsl>

I get a speedup of about 2.4x (i.e. more than double) with respect to your method. Note that the <1,0,0> trick is important for performance. Replacing <1,0,0>*rot with llRot2Fwd(rot) the speedup is just about 1.3x. As for memory, it also takes less. --Sei Lisa 15:17, 14 July 2014 (PDT)