This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//note: degrees only | |
const lerp = (start,end,amt) => start+(end-start)*amt | |
const clamp = (num, min, max) => Math.min(Math.max(num, min), max); | |
const repeat = (t, m) => clamp(t - Math.floor(t / m) * m, 0, m); | |
function lerpTheta(a, b, t) { | |
const dt = repeat(b - a, 360); | |
return lerp(a, a + (dt > 180 ? dt - 360 : dt), t); | |
} |