Vec2.AngleBetween
static float AngleBetween(Vec2 a, Vec2 b)
Calculates a signed angle between two vectors in degrees! Sign will be positive if B is counter-clockwise (left) of A, and negative if B is clockwise (right) of A. Vectors do not need to be normalized. NOTE: Since this will return a positive or negative angle, order of parameters matters!
Vec2 a | The first, initial vector, A. Does not need to be normalized. |
Vec2 b | The second vector, B, that we’re finding the angle to. Does not need to be normalized. |
RETURNS: float | a signed angle between two vectors in degrees! Sign will be positive if B is counter-clockwise (left) of A, and negative if B is clockwise (right) of A. |
Examples
Vec2 directionA = new Vec2( 1, 1);
Vec2 directionB = new Vec2(-1, 1);
float angle90 = Vec2.AngleBetween(directionA, directionB);
directionA = new Vec2(1, 1);
directionB = new Vec2(0,-2);
float angleNegative135 = Vec2.AngleBetween(directionA, directionB);
Found an issue with these docs, or have some additional questions? Create an Issue on Github!