$nav ===== Function: llSin ===== float llSin(float arg) Return the sine of the argument. The argument should be an angle in radians. ===== Parameters ===== === arg === Angle whose sine is to be found, in radians. ===== Return value ===== A $lty[float] with the sine of the argument. ===== Notes ===== * Inputs of $minf, $pinf and $nan result in $nan. * If the angle is otherwise not between approx. -9.22337e18 and 9.22337e18, the argument is returned unchanged. * Otherwise, the return value is always between -1 and 1. ===== Short examples ===== float F; F = llSin(1); // Sets F to approx. 0.841471, which is the sine of 1 radian. F = llSin(-1); // Sets F to approx. -0.841471, which is the sine of -1 radian. F = llSin(0); // Sets F to 0, which is the sine of 0. F = llSin(PI); // Sets F to approximately 0, which is the sine of PI. // It isn't exactly 0 because of rounding/calculation errors. F = llSin(1e20); // Sets F to 1e20 because 1e20 is returned unchanged. ===== Complete examples ===== $fn[llSin] is very frequently used together with $lfn[llCos], as $fn[llCos] gives the X component and $fn[llSin] the Y component of a unit 2D vector at the given angle. default { state_entry() { llOwnerSay("Calculate a vector at an angle. Please say the angle in chat."); llListen(0, "", llGetOwner(), ""); } listen(integer chan, string name, key id, string msg) { float angle = (float)msg * DEG_TO_RAD; llOwnerSay("Input angle: " + msg + "; resulting vector: (" + (string)llCos(angle) + ", " + (string)llSin(angle) + ")"); } } The opposite calculation, i.e. finding the angle of a 2D vector, can be performed with $lfn[llAtan2]. ===== See also ===== === Related trigonometric functions === * $lfn[llCos] calculates the cosine of the argument. * $lfn[llAsin] calculates the inverse sine of the argument. * $lfn[llAtan2] calculates the angle of a 2D vector. === Other trigonometric functions === * $lfn[llAcos] calculates the inverse cosine of the argument. * $lfn[llTan] calculates the tangent of the argument. === Related information === * $lty[float] type and associated caveats and limitations.