/// <summary> /// Returns the angle with the vector p2 in degrees; /// </summary> /// <param name="p1">The first point.</param> /// <param name="p2">The second point.</param> /// <returns></returns> public static float ELAngleBetween(this Vector2 p1, Vector2 p2) { var theta = p1.Polar() - p2.Polar(); if (theta < 0) { theta = theta + 360; } if (theta > 180) { theta = 360 - theta; } return theta; }
/// <summary> /// Returns the angle between two vectors. /// </summary> /// <param name="vector2">Extended SharpDX Vector2</param> /// <param name="toVector2">SharpDX Vector2</param> /// <returns>Angle between two vectors in float-units</returns> public static float AngleBetween(this Vector2 vector2, Vector2 toVector2) { var theta = vector2.Polar() - toVector2.Polar(); if (theta < 0) { theta = theta + 360; } if (theta > 180) { theta = 360 - theta; } return theta; }