Table of Contents

Start Functions Events Constants Types Language Articles

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

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