Here you can find the source of lerpa(double a1, double a2, double t)
public static double lerpa(double a1, double a2, double t)
//package com.java2s; //License from project: Apache License public class Main { /**//from ww w . java2 s.co m * Linearly interpolates between two angles, taking the shortest path around the circle. * This assumes that both angles are in [-pi, +pi]. */ public static double lerpa(double a1, double a2, double t) { double ma1 = mirrorAngle(a1), ma2 = mirrorAngle(a2); double d = Math.abs(a2 - a1), md = Math.abs(ma1 - ma2); return (d <= md) ? lerp(a1, a2, t) : mirrorAngle(lerp(ma1, ma2, t)); } /** * Returns the mirror angle of the specified angle (assumed to be in [-pi, +pi]). The angle is * mirrored around the PI/2 if it is positive, and -PI/2 if it is negative. One can visualize * this as mirroring around the "y-axis". */ public static double mirrorAngle(double a) { return (a > 0f ? Math.PI : -Math.PI) - a; } /** * Linearly interpolates between v1 and v2 by the parameter t. */ public static double lerp(double v1, double v2, double t) { return v1 + t * (v2 - v1); } }