/** * Returns the (shortest) difference between two angles, assuming that both angles are in * [-pi, +pi]. */ public static float angularDifference (float a1, float a2) { float ma1 = mirrorAngle(a1), ma2 = mirrorAngle(a2); float diff = a1 - a2, mdiff = ma2 - ma1; return (Math.abs(diff) < Math.abs(mdiff)) ? diff : mdiff; }
/** * Returns the (shortest) difference between two angles, assuming that both angles are in * [-pi, +pi]. */ public static float angularDifference (float a1, float a2) { float ma1 = mirrorAngle(a1), ma2 = mirrorAngle(a2); float diff = a1 - a2, mdiff = ma2 - ma1; return (Math.abs(diff) < Math.abs(mdiff)) ? diff : mdiff; }
/** * Returns the (shortest) distance between two angles, assuming that both angles are in * [-pi, +pi]. */ public static float angularDistance (float a1, float a2) { float ma1 = mirrorAngle(a1), ma2 = mirrorAngle(a2); return Math.min(Math.abs(a1 - a2), Math.abs(ma1 - ma2)); }
/** * Returns the (shortest) distance between two angles, assuming that both angles are in * [-pi, +pi]. */ public static float angularDistance (float a1, float a2) { float ma1 = mirrorAngle(a1), ma2 = mirrorAngle(a2); return Math.min(Math.abs(a1 - a2), Math.abs(ma1 - ma2)); }
/** * Linearly interpolates between two angles, taking the shortest path around the circle. * This assumes that both angles are in [-pi, +pi]. */ public static float lerpa (float a1, float a2, float t) { float ma1 = mirrorAngle(a1), ma2 = mirrorAngle(a2); float d = Math.abs(a2 - a1), md = Math.abs(ma1 - ma2); return (d <= md) ? lerp(a1, a2, t) : mirrorAngle(lerp(ma1, ma2, t)); }
/** * Linearly interpolates between two angles, taking the shortest path around the circle. * This assumes that both angles are in [-pi, +pi]. */ public static float lerpa (float a1, float a2, float t) { float ma1 = mirrorAngle(a1), ma2 = mirrorAngle(a2); float d = Math.abs(a2 - a1), md = Math.abs(ma1 - ma2); return (d <= md) ? lerp(a1, a2, t) : mirrorAngle(lerp(ma1, ma2, t)); }