Practically finished Large Lady
This commit is contained in:
@@ -9,3 +9,19 @@ export const map = (
|
||||
x2: number,
|
||||
y2: number,
|
||||
) => (value - x1) * (y2 - x2) / (y1 - x1) + x2;
|
||||
|
||||
export function lerpAngle(a: number, b: number, t: number) {
|
||||
let diff = b - a;
|
||||
// Wrap difference to [-PI, PI]
|
||||
while (diff < -Math.PI) diff += 2 * Math.PI;
|
||||
while (diff > Math.PI) diff -= 2 * Math.PI;
|
||||
return a + diff * t;
|
||||
}
|
||||
|
||||
export function averageAngles(angle1: number, angle2: number) {
|
||||
// Convert angles to unit vectors
|
||||
const x = Math.cos(angle1) + Math.cos(angle2);
|
||||
const y = Math.sin(angle1) + Math.sin(angle2);
|
||||
// Compute the angle of the resulting vector
|
||||
return Math.atan2(y, x);
|
||||
}
|
||||
|
Reference in New Issue
Block a user