public static F64Quat FromYawPitchRoll(F64 yaw_y, F64 pitch_x, F64 roll_z) { // Roll first, about axis the object is facing, then // pitch upward, then yaw to face into the new heading F64 half_roll = F64.Div2(roll_z); F64 sr = F64.SinFastest(half_roll); F64 cr = F64.CosFastest(half_roll); F64 half_pitch = F64.Div2(pitch_x); F64 sp = F64.SinFastest(half_pitch); F64 cp = F64.CosFastest(half_pitch); F64 half_yaw = F64.Div2(yaw_y); F64 sy = F64.SinFastest(half_yaw); F64 cy = F64.CosFastest(half_yaw); return(new F64Quat( cy * sp * cr + sy * cp * sr, sy * cp * cr - cy * sp * sr, cy * cp * sr - sy * sp * cr, cy * cp * cr + sy * sp * sr)); }
public static F64Quat FromAxisAngle(F64Vec3 axis, F64 angle) { F64 half_angle = F64.Div2(angle); return(new F64Quat(axis * F64.SinFastest(half_angle), F64.CosFastest(half_angle))); }