UNPKG

@phaserjs/phaser

Version:
14 lines (13 loc) 705 B
import { Quaternion } from "./Quaternion"; export function QuatRotationYawPitchRoll(yaw, pitch, roll, out = new Quaternion()) { const halfRoll = roll * 0.5; const halfPitch = pitch * 0.5; const halfYaw = yaw * 0.5; const sinRoll = Math.sin(halfRoll); const cosRoll = Math.cos(halfRoll); const sinPitch = Math.sin(halfPitch); const cosPitch = Math.cos(halfPitch); const sinYaw = Math.sin(halfYaw); const cosYaw = Math.cos(halfYaw); return out.set(cosYaw * sinPitch * cosRoll + sinYaw * cosPitch * sinRoll, sinYaw * cosPitch * cosRoll - cosYaw * sinPitch * sinRoll, cosYaw * cosPitch * sinRoll - sinYaw * sinPitch * cosRoll, cosYaw * cosPitch * cosRoll + sinYaw * sinPitch * sinRoll); }