fromEuler method
Sets the components of this quaternion from the given euler angle (YXZ order).
Implementation
Quaternion fromEuler(double x, double y, double z ) {
// from 3D Math Primer for Graphics and Game Development
// 8.7.5 Converting Euler Angles to a Quaternion
// assuming YXZ (head/pitch/bank or yaw/pitch/roll) order
final c1 = math.cos( y / 2 );
final c2 = math.cos( x / 2 );
final c3 = math.cos( z / 2 );
final s1 = math.sin( y / 2 );
final s2 = math.sin( x / 2 );
final s3 = math.sin( z / 2 );
w = c1 * c2 * c3 + s1 * s2 * s3;
this.x = c1 * s2 * c3 + s1 * c2 * s3;
this.y = s1 * c2 * c3 - c1 * s2 * s3;
this.z = c1 * c2 * s3 - s1 * s2 * c3;
return this;
}