MCPcopy Create free account
hub / github.com/microsoft/SandDance / _fromRotationMatrix

Method _fromRotationMatrix

docs/app/js/sanddance-app.js:75778–75849  ·  view source on GitHub ↗
(m, order = Euler.DefaultOrder)

Source from the content-addressed store, hash-verified

75776 }
75777 }
75778 _fromRotationMatrix(m, order = Euler.DefaultOrder) {
75779 const m11 = m[0], m12 = m[4], m13 = m[8];
75780 const m21 = m[1], m22 = m[5], m23 = m[9];
75781 const m31 = m[2], m32 = m[6], m33 = m[10];
75782 order = order || this[3];
75783 switch(order){
75784 case Euler.XYZ:
75785 this[1] = Math.asin((0, _common.clamp)(m13, -1, 1));
75786 if (Math.abs(m13) < ALMOST_ONE) {
75787 this[0] = Math.atan2(-m23, m33);
75788 this[2] = Math.atan2(-m12, m11);
75789 } else {
75790 this[0] = Math.atan2(m32, m22);
75791 this[2] = 0;
75792 }
75793 break;
75794 case Euler.YXZ:
75795 this[0] = Math.asin(-(0, _common.clamp)(m23, -1, 1));
75796 if (Math.abs(m23) < ALMOST_ONE) {
75797 this[1] = Math.atan2(m13, m33);
75798 this[2] = Math.atan2(m21, m22);
75799 } else {
75800 this[1] = Math.atan2(-m31, m11);
75801 this[2] = 0;
75802 }
75803 break;
75804 case Euler.ZXY:
75805 this[0] = Math.asin((0, _common.clamp)(m32, -1, 1));
75806 if (Math.abs(m32) < ALMOST_ONE) {
75807 this[1] = Math.atan2(-m31, m33);
75808 this[2] = Math.atan2(-m12, m22);
75809 } else {
75810 this[1] = 0;
75811 this[2] = Math.atan2(m21, m11);
75812 }
75813 break;
75814 case Euler.ZYX:
75815 this[1] = Math.asin(-(0, _common.clamp)(m31, -1, 1));
75816 if (Math.abs(m31) < ALMOST_ONE) {
75817 this[0] = Math.atan2(m32, m33);
75818 this[2] = Math.atan2(m21, m11);
75819 } else {
75820 this[0] = 0;
75821 this[2] = Math.atan2(-m12, m22);
75822 }
75823 break;
75824 case Euler.YZX:
75825 this[2] = Math.asin((0, _common.clamp)(m21, -1, 1));
75826 if (Math.abs(m21) < ALMOST_ONE) {
75827 this[0] = Math.atan2(-m23, m22);
75828 this[1] = Math.atan2(-m31, m11);
75829 } else {
75830 this[0] = 0;
75831 this[1] = Math.atan2(m13, m33);
75832 }
75833 break;
75834 case Euler.XZY:
75835 this[2] = Math.asin(-(0, _common.clamp)(m12, -1, 1));

Callers 1

fromRotationMatrixMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected