You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.
This shows you the differences between two versions of the page.
functions:llacos [2014-01-03 10:18 SLT] sei created |
functions:llacos [2015-09-22 11:59 SLT] (current) sei Style |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | $nav | ||
===== Function: llAcos ===== | ===== Function: llAcos ===== | ||
Line 5: | Line 6: | ||
</code> | </code> | ||
- | Return the inverse cosine of the argument, in radians. The inverse cosine is the angle whose cosine is the given argument. | + | 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. |
===== Parameters ===== | ===== Parameters ===== | ||
Line 12: | Line 13: | ||
Number whose inverse cosine is to be found. | Number whose inverse cosine is to be found. | ||
- | ===== Result ===== | + | ===== Return value ===== |
- | [[types/Float]] number with the inverse cosine of the argument. | + | $lty[Float] number with the angle in radians that is the inverse cosine of the argument. |
===== Notes ===== | ===== Notes ===== | ||
- | * The range must be between -1 and 1, because the cosine of any angle can't be outside that range. | + | * The range of $prm[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 $lct[PI], or $nan if the argument is out of the valid range. | ||
===== Short examples ===== | ===== Short examples ===== | ||
Line 28: | Line 30: | ||
angle = llAcos(-1); // Sets angle to PI, because the cosine of PI is -1. | 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(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. | + | |
+ | 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. | ||
</code> | </code> | ||
- | ===== See also ===== | + | ===== Complete examples ===== |
- | === Related trigonometric functions === | + | A $lty[rotation] can be expressed by an axis and an angle. This example illustrates how to use $fn[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 $lfn[llRot2Angle] instead. |
- | * [[llCos]] | + | |
+ | <file lsl2 llAcos-example.lsl> | ||
+ | default | ||
+ | { | ||
+ | state_entry() | ||
+ | { | ||
+ | rotation rot = llGetLocalRot(); | ||
+ | llOwnerSay("The angle of rotation of this prim is " + (string)(2*llAcos(rot.s)) + " radians."); | ||
+ | } | ||
+ | } | ||
+ | </file> | ||
+ | |||
+ | ===== See also ===== | ||
- | === Other trigonometric functions === | + | * $lfn[llCos] calculates the cosine of the argument. |
- | * [[llAsin]] | + | * $lfn[llAsin] calculates the inverse sine of the argument. |
- | * [[llSin]] | + | * $lfn[llSin] calculates the sine of the argument. |
- | * [[llAtan2]] | + | * $lfn[llAtan2] calculates the angle of a 2D vector. |
- | * [[llTan]] | + | * $lfn[llTan] calculates the tangent of the argument. |
+ | * Other $lfn[math/] functions. | ||