Unofficial LSL Reference

[[functions:lltan]]


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: llTan

float llTan(float arg)

Return the trigonometric tangent of the argument. The argument should be an angle in radians.

Parameters

arg

Angle whose tangent is to be found, in radians.

Return value

A float with the tangent of the argument.

Notes

  • Inputs of -Infinity, Infinity and NaN result in NaN.
  • If the angle is otherwise not between -9.22337e18 and 9.22337e18, the argument is returned unchanged.

Short examples

float F;
F = llTan(1); // Sets F to approx. 1.557408, which is the tangent of 1 radian.
F = llTan(-1); // Sets F to approx. -1.557408, because that's the tangent of -1 radian.
F = llTan(0); // Sets F to 0, because that's the tangent of 0.
F = llTan(PI); // Sets F to approximately 0, which is the tangent of PI.
               // It isn't exactly 0 because of rounding/calculation errors.
F = llTan(1e20);  // Sets F to 1e20 because 1e20 is returned unchanged.

Complete examples

The tangent gives you the slope of an angle, that is, how much you advance vertically per each unit you advance horizontally.

llTan-example.lsl
default
{
    state_entry()
    {
        llOwnerSay("Calculate the slope given the 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("For an input angle of " + msg + ", you climb "
                   + (string)llTan(angle) + " m per each horizontal m");
    }
}

See also

  • llSin calculates the sine of the argument.
  • llCos calculates the tangent of the argument.
  • llAtan2 calculates the angle of a 2D vector.

Other trigonometric functions

  • llAsin calculates the inverse sine of the argument.
  • llAcos calculates the inverse cosine of the argument.
  • float type and associated caveats and limitations.