Unofficial LSL Reference

[[functions:llasin]]


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

Function: llAsin

float llAsin(float arg)

Return the inverse sine of the argument, in radians. The inverse sine (also known as arcsine) is the angle whose sine is the given argument.

Parameters

arg

Number whose inverse sine is to be found.

Return value

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

Notes

  • The range of arg must be between -1 and 1, because the sine of any angle can't be outside that range.
  • The result is always between -PI_BY_TWO and [PI_BY_TWO, or NaN if the argument is out of the valid range.

Short examples

float angle;
angle = llAsin(1); // Sets angle to PI_BY_TWO, because the sine of 1 is PI_BY_TWO.
angle = llAsin(0); // Sets angle to 0, because the sine of 0 is 0.
angle = llAsin(-1); // Sets angle to -PI_BY_TWO, because the sine of -PI_BY_TWO is -1.
angle = llAsin(0.67); // Sets angle to approximately 0.734209 (the sine of that is 0.67)

angle = llAsin(2);  // Under Mono, sets angle to NaN (Not a Number)
                    // because there's no number whose sine is 2.
                    // Crashes with a math error under LSO.

Complete examples

The following example will output the pitch and roll angles of a prim, in degrees:

llAsin-example.lsl
default
{
    state_entry()
    {
        rotation rot = llGetLocalRot();
        vector forward = <1,0,0>*rot;
        vector right = <0,-1,0>*rot;

        float pitch = llAsin(forward.z);
        float roll = llAsin(right.z);

        llOwnerSay("Pitch=" + (string)(pitch * RAD_TO_DEG) + "°; roll=" + (string)(roll * RAD_TO_DEG) + "°");
    }
}

See also

  • llSin calculates the sine of the argument.
  • llAcos calculates the inverse cosine of the argument.
  • llCos calculates the cosine of the argument.
  • llAtan2 calculates the angle of a 2D vector.
  • llTan calculates the tangent of the argument.
  • Other math functions