You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.
This is an old revision of the document!
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.
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) * RAD_TO_DEG; llOwnerSay("Heading=" + (string)heading + "°"); } }