using UnityEngine;

public class ExtraMath {

    /**
     * Normalize an angle to the -PI -> PI range.
     */
    public static float NormalizeAngle (float angle) {
        float PI = Mathf.PI;
        if(angle >= 0) {
            return (angle + PI) % (2 * PI) - PI;
        } else {
            return -((-angle + PI) % (2 * PI) - PI);
        }
    }

    /**
     * Rotate a vector 90° to the right
     */
    public static Vector2 RotateRight(Vector2 v) {
        return new Vector2(v.y, -v.x);
    }
}