/// <summary> /// Converts a direction vector to an angle, where angle is -PI to +PI. /// </summary> /// <param name="vec">Vector to get the angle from.</param> /// <returns>Angle of the vector.</returns> public static Angle ToAngle(this Vector2 vec) { return(Math.Atan2(vec.Y, vec.X)); }
/// <summary> /// Constructs an instance of an angle from an (un)normalized direction vector. /// </summary> /// <param name="dir"></param> public Angle(Vector2 dir) { dir = dir.Normalized; Theta = Math.Atan2(dir.Y, dir.X); }