$nav
===== 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 =====
$lty[Float] number with the angle in radians that is the inverse sine of the argument.
===== Notes =====
* The range of $prm[arg] must be between -1 and 1, because the sine of any angle can't be outside that range.
* The result is always between -$lct[PI_BY_TWO] and $ct[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:
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 =====
* $lfn[llSin] calculates the sine of the argument.
* $lfn[llAcos] calculates the inverse cosine of the argument.
* $lfn[llCos] calculates the cosine of the argument.
* $lfn[llAtan2] calculates the angle of a 2D vector.
* $lfn[llTan] calculates the tangent of the argument.
* Other $lfn[math/] functions