You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.
float llAtan2(float y, float x)
Return the angle of the 2D vector given by x and y. Note that the arguments are in reverse order: the first is y, the second is x.
The y component of the 2D vector.
The x component of the 2D vector.
Float number with the angle of the vector.
llAtan2(1, 2)
is the angle of the vector (1, 2) expressed with this convention.float angle; angle = llAtan2(0, 1); // Sets angle to 0 because that's the angle of the vector (1, 0). angle = llAtan2(-3, 0); // Sets angle to -PI_BY_TWO, because that's the angle of the vector (0, -3). angle = llAtan2(1.3, 2.3); // Sets angle to approx. 0.514451 as that's the angle of the vector (2.3, 1.3) angle = llAtan2(0, 0); // Sets angle to 0. angle = llAtan2(0, -1); // Sets angle to PI, because that's the angle of the vector (-1, 0). angle = llAtan2(-0.0, -2); // Sets angle to -PI. angle = llAtan2((float)"NaN", 0); // Sets angle to NaN (Not a Number) because one input is NaN.
The following example will output the heading of a prim, in degrees:
default { state_entry() { vector fwd = <1,0,0>*llGetLocalRot(); float heading = llAtan2(fwd.y, fwd.x); llOwnerSay("Heading=" + (string)(heading * RAD_TO_DEG) + "°"); } }
llTan
calculates the tangent of the argument.llAsin
calculates the inverse sine of the argument.llSin
calculates the sine of the argument.llAcos
calculates the inverse cosine of the argument.llCos
calculates the cosine of the argument.llAngleBetween
calculates the angle between two rotations.llRot2Angle
takes the angle part of a rotation.math
functions.