setFromEuler method
Implementation
Quaternion setFromEuler(Euler euler, [bool update = false]) {
final x = euler.x;
final y = euler.y;
final z = euler.z;
final order = euler.order;
// http://www.mathworks.com/matlabcentral/fileexchange/
// 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
// content/SpinCalc.m
final c1 = math.cos(x / 2);
final c2 = math.cos(y / 2);
final c3 = math.cos(z / 2);
final s1 = math.sin(x / 2);
final s2 = math.sin(y / 2);
final s3 = math.sin(z / 2);
switch (order) {
case RotationOrders.xyz:
_x = s1 * c2 * c3 + c1 * s2 * s3;
_y = c1 * s2 * c3 - s1 * c2 * s3;
_z = c1 * c2 * s3 + s1 * s2 * c3;
_w = c1 * c2 * c3 - s1 * s2 * s3;
break;
case RotationOrders.yxz:
_x = s1 * c2 * c3 + c1 * s2 * s3;
_y = c1 * s2 * c3 - s1 * c2 * s3;
_z = c1 * c2 * s3 - s1 * s2 * c3;
_w = c1 * c2 * c3 + s1 * s2 * s3;
break;
case RotationOrders.zxy:
_x = s1 * c2 * c3 - c1 * s2 * s3;
_y = c1 * s2 * c3 + s1 * c2 * s3;
_z = c1 * c2 * s3 + s1 * s2 * c3;
_w = c1 * c2 * c3 - s1 * s2 * s3;
break;
case RotationOrders.zyx:
_x = s1 * c2 * c3 - c1 * s2 * s3;
_y = c1 * s2 * c3 + s1 * c2 * s3;
_z = c1 * c2 * s3 - s1 * s2 * c3;
_w = c1 * c2 * c3 + s1 * s2 * s3;
break;
case RotationOrders.yzx:
_x = s1 * c2 * c3 + c1 * s2 * s3;
_y = c1 * s2 * c3 + s1 * c2 * s3;
_z = c1 * c2 * s3 - s1 * s2 * c3;
_w = c1 * c2 * c3 - s1 * s2 * s3;
break;
case RotationOrders.xzy:
_x = s1 * c2 * c3 - c1 * s2 * s3;
_y = c1 * s2 * c3 - s1 * c2 * s3;
_z = c1 * c2 * s3 + s1 * s2 * c3;
_w = c1 * c2 * c3 + s1 * s2 * s3;
break;
default:
throw('THREE.Quaternion: .setFromEuler() encountered an unknown order: $order');
}
if (update) onChangeCallback();
return this;
}