From 2d29a6a7be5b1cbede45666d5df961f635c9c437 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 29 Mar 2013 17:24:51 +1100 Subject: [PATCH] AP_Math: added Vector2f.angle() useful for calculating the vector in polar coordinates --- libraries/AP_Math/vector2.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/AP_Math/vector2.h b/libraries/AP_Math/vector2.h index 0514f492a7..68d4f98c84 100644 --- a/libraries/AP_Math/vector2.h +++ b/libraries/AP_Math/vector2.h @@ -170,6 +170,12 @@ struct Vector2 return (T)acosf((v1*v2) / (v1.length()*v2.length())); } + // computes the angle in radians between the origin and this vector + T angle(void) + { + return (T)atan2f(y, x); + } + // computes the angle between this vector and another vector T angle(const Vector2 &v2) {