darctan2

Calculates arctan(y/x) and returns an angle in the correct quadrant.

Syntax:

GML Code Example

darctan2(y, x);


Argument Description
y The y coordinate to calculate.
x The x coordinate to calculate.


Returns: Real


Description

This function returns the inverse tangent of an angle y/x, where y = Opposite side of triangle and x = Adjacent side of triangle. Unlike darctan(x) the function darctan2(y, x) is valid for all angles and so may be used to convert a vector to an angle without risking division by zero, and it also returns a result in the correct quadrant.

NOTE: The value returned is in degrees, not radians.


Example:

GML Code Example

val = darctan2(1, 1);

This will set "val" to the correct angle.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here