Unofficial LSL Reference

[[functions:llacos]]


Unofficial LSL reference

User Tools

Login

You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.

Login

Forgotten your password? Get a new one: Set new password

This is an old revision of the document!


Function: llAcos

float llAcos(float arg)

Return the inverse cosine of the argument, in radians. The inverse cosine is the angle whose cosine is the given argument.

Parameters

arg

Number whose inverse cosine is to be found.

Result

Float number with the angle in radians that is the inverse cosine of the argument.

Notes

  • The range of arg must be between -1 and 1, because the cosine of any angle can't be outside that range.
  • The result is always between 0 and PI, or NaN (Not a Number) if the argument is out of range.

Short examples

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);  // Sets angle to NaN (Not a Number) because there's no number whose cosine is 2.

Complete examples

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.

llAcos-example.lsl
default
{
    state_entry()
    {
        rotation rot = llGetLocalRot();
        llOwnerSay("The angle of rotation of this prim is " + (string)(2*llAcos(rot.s)) + " radians.");
    }
}

See also

Other trigonometric functions