float llAcos(float arg)
Return the inverse cosine of the argument, in radians. The inverse cosine (also known as arccosine) is the angle whose cosine is the given argument.
Number whose inverse cosine is to be found.
Float number with the angle in radians that is the inverse cosine of the argument.
arg
must be between -1 and 1, because the cosine of any angle can't be outside that range.float angle; angle = llAcos(1); // Sets angle to 0, because the cosine of 0 is 1. angle = llAcos(0); // Sets angle to PI_BY_TWO, because the cosine of PI/2 is 0. angle = llAcos(-1); // Sets angle to PI, because the cosine of PI is -1. angle = llAcos(0.31); // Sets angle to approximately 1.255603 (the cosine of that is 0.31) angle = llAcos(2); // Under Mono, sets angle to NaN (Not a Number), // because there's no number whose cosine is 2. // Crashes with a math error under LSO.
A rotation can be expressed by an axis and an angle. This example illustrates how to use llAcos to obtain the angle component of a rotation, assumed it's normalized (most LSL functions return normalized rotations). If the rotation is not guaranteed to be normalized, use llRot2Angle
instead.
default { state_entry() { rotation rot = llGetLocalRot(); llOwnerSay("The angle of rotation of this prim is " + (string)(2*llAcos(rot.s)) + " radians."); } }