53 MMechostr(MSKDEBUG,
"SO3MathsQuatToEulerXYZ\n");
56 int q = MTOP(MMget(m, 0));
63 int x = MMfetch(m, q, 0);
64 int y = MMfetch(m, q, 1);
65 int z = MMfetch(m, q, 2);
66 int w = MMfetch(m, q, 3);
68 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
74 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
82 quat.ToRotationMatrix(mat);
84 mat.ToEulerAnglesXYZ(yrad, xrad, zrad);
86 int tuple = MMmalloc(m, 3, TYPETAB);
92 MMstore(m, tuple, 0, FTOM(xrad.valueRadians()));
93 MMstore(m, tuple, 1, FTOM(yrad.valueRadians()));
94 MMstore(m, tuple, 2, FTOM(zrad.valueRadians()));
95 MMset(m, 0, PTOM(tuple));
112 MMechostr(MSKDEBUG,
"SO3MathsQuatToEulerXZY\n");
115 int q = MTOP(MMget(m, 0));
122 int x = MMfetch(m, q, 0);
123 int y = MMfetch(m, q, 1);
124 int z = MMfetch(m, q, 2);
125 int w = MMfetch(m, q, 3);
127 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
133 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
141 quat.ToRotationMatrix(mat);
143 mat.ToEulerAnglesXZY(yrad, xrad, zrad);
145 int tuple = MMmalloc(m, 3, TYPETAB);
151 MMstore(m, tuple, 0, FTOM(xrad.valueRadians()));
152 MMstore(m, tuple, 1, FTOM(yrad.valueRadians()));
153 MMstore(m, tuple, 2, FTOM(zrad.valueRadians()));
154 MMset(m, 0, PTOM(tuple));
171 MMechostr(MSKDEBUG,
"SO3MathsQuatToEulerYXZ\n");
174 int q = MTOP(MMget(m, 0));
181 int x = MMfetch(m, q, 0);
182 int y = MMfetch(m, q, 1);
183 int z = MMfetch(m, q, 2);
184 int w = MMfetch(m, q, 3);
186 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
192 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
200 quat.ToRotationMatrix(mat);
202 mat.ToEulerAnglesYXZ(yrad, xrad, zrad);
204 int tuple = MMmalloc(m, 3, TYPETAB);
210 MMstore(m, tuple, 0, FTOM(xrad.valueRadians()));
211 MMstore(m, tuple, 1, FTOM(yrad.valueRadians()));
212 MMstore(m, tuple, 2, FTOM(zrad.valueRadians()));
213 MMset(m, 0, PTOM(tuple));
230 MMechostr(MSKDEBUG,
"SO3MathsQuatToEulerYZX\n");
233 int q = MTOP(MMget(m, 0));
240 int x = MMfetch(m, q, 0);
241 int y = MMfetch(m, q, 1);
242 int z = MMfetch(m, q, 2);
243 int w = MMfetch(m, q, 3);
245 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
251 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
259 quat.ToRotationMatrix(mat);
260 mat.ToEulerAnglesYZX(yrad, xrad, zrad);
262 int tuple = MMmalloc(m, 3, TYPETAB);
268 MMstore(m, tuple, 0, FTOM(xrad.valueRadians()));
269 MMstore(m, tuple, 1, FTOM(yrad.valueRadians()));
270 MMstore(m, tuple, 2, FTOM(zrad.valueRadians()));
271 MMset(m, 0, PTOM(tuple));
287 MMechostr(MSKDEBUG,
"SO3MathsQuatToEulerZXY\n");
290 int q = MTOP(MMget(m, 0));
297 int x = MMfetch(m, q, 0);
298 int y = MMfetch(m, q, 1);
299 int z = MMfetch(m, q, 2);
300 int w = MMfetch(m, q, 3);
302 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
308 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
316 quat.ToRotationMatrix(mat);
318 mat.ToEulerAnglesZXY(yrad, xrad, zrad);
320 int tuple = MMmalloc(m, 3, TYPETAB);
326 MMstore(m, tuple, 0, FTOM(xrad.valueRadians()));
327 MMstore(m, tuple, 1, FTOM(yrad.valueRadians()));
328 MMstore(m, tuple, 2, FTOM(zrad.valueRadians()));
329 MMset(m, 0, PTOM(tuple));
346 MMechostr(MSKDEBUG,
"SO3MathsQuatToEulerZYX\n");
349 int q = MTOP(MMget(m, 0));
356 int x = MMfetch(m, q, 0);
357 int y = MMfetch(m, q, 1);
358 int z = MMfetch(m, q, 2);
359 int w = MMfetch(m, q, 3);
361 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
367 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
375 quat.ToRotationMatrix(mat);
377 mat.ToEulerAnglesZYX(yrad, xrad, zrad);
379 int tuple = MMmalloc(m, 3, TYPETAB);
385 MMstore(m, tuple, 0, FTOM(xrad.valueRadians()));
386 MMstore(m, tuple, 1, FTOM(yrad.valueRadians()));
387 MMstore(m, tuple, 2, FTOM(zrad.valueRadians()));
388 MMset(m, 0, PTOM(tuple));
405 MMechostr(MSKDEBUG,
"SO3MathsQuatToEulerDegreeXYZ\n");
408 int q = MTOP(MMget(m, 0));
415 int x = MMfetch(m, q, 0);
416 int y = MMfetch(m, q, 1);
417 int z = MMfetch(m, q, 2);
418 int w = MMfetch(m, q, 3);
420 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
426 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
434 quat.ToRotationMatrix(mat);
436 mat.ToEulerAnglesXYZ(yrad, xrad, zrad);
437 int tuple = MMmalloc(m, 3, TYPETAB);
443 MMstore(m, tuple, 0, FTOM(xrad.valueDegrees()));
444 MMstore(m, tuple, 1, FTOM(yrad.valueDegrees()));
445 MMstore(m, tuple, 2, FTOM(zrad.valueDegrees()));
446 MMset(m, 0, PTOM(tuple));
463 MMechostr(MSKDEBUG,
"SO3MathsQuatToEulerDegreeXZY\n");
466 int q = MTOP(MMget(m, 0));
473 int x = MMfetch(m, q, 0);
474 int y = MMfetch(m, q, 1);
475 int z = MMfetch(m, q, 2);
476 int w = MMfetch(m, q, 3);
478 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
484 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
491 quat.ToRotationMatrix(mat);
493 mat.ToEulerAnglesXZY(yrad, xrad, zrad);
494 int tuple = MMmalloc(m, 3, TYPETAB);
500 MMstore(m, tuple, 0, FTOM(xrad.valueDegrees()));
501 MMstore(m, tuple, 1, FTOM(yrad.valueDegrees()));
502 MMstore(m, tuple, 2, FTOM(zrad.valueDegrees()));
503 MMset(m, 0, PTOM(tuple));
520 MMechostr(MSKDEBUG,
"SO3MathsQuatToEulerDegreeYXZ\n");
523 int q = MTOP(MMget(m, 0));
530 int x = MMfetch(m, q, 0);
531 int y = MMfetch(m, q, 1);
532 int z = MMfetch(m, q, 2);
533 int w = MMfetch(m, q, 3);
535 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
541 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
549 quat.ToRotationMatrix(mat);
551 mat.ToEulerAnglesYXZ(yrad, xrad, zrad);
553 int tuple = MMmalloc(m, 3, TYPETAB);
559 MMstore(m, tuple, 0, FTOM(xrad.valueDegrees()));
560 MMstore(m, tuple, 1, FTOM(yrad.valueDegrees()));
561 MMstore(m, tuple, 2, FTOM(zrad.valueDegrees()));
562 MMset(m, 0, PTOM(tuple));
579 MMechostr(MSKDEBUG,
"SO3MathsQuatToEulerDegreeYZX\n");
582 int q = MTOP(MMget(m, 0));
589 int x = MMfetch(m, q, 0);
590 int y = MMfetch(m, q, 1);
591 int z = MMfetch(m, q, 2);
592 int w = MMfetch(m, q, 3);
594 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
600 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
608 quat.ToRotationMatrix(mat);
610 mat.ToEulerAnglesYZX(yrad, xrad, zrad);
612 int tuple = MMmalloc(m, 3, TYPETAB);
618 MMstore(m, tuple, 0, FTOM(xrad.valueDegrees()));
619 MMstore(m, tuple, 1, FTOM(yrad.valueDegrees()));
620 MMstore(m, tuple, 2, FTOM(zrad.valueDegrees()));
621 MMset(m, 0, PTOM(tuple));
638 MMechostr(MSKDEBUG,
"SO3MathsQuatToEulerDegreeZXY\n");
641 int q = MTOP(MMget(m, 0));
648 int x = MMfetch(m, q, 0);
649 int y = MMfetch(m, q, 1);
650 int z = MMfetch(m, q, 2);
651 int w = MMfetch(m, q, 3);
653 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
659 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
667 quat.ToRotationMatrix(mat);
669 mat.ToEulerAnglesZXY(yrad, xrad, zrad);
671 int tuple = MMmalloc(m, 3, TYPETAB);
677 MMstore(m, tuple, 0, FTOM(xrad.valueDegrees()));
678 MMstore(m, tuple, 1, FTOM(yrad.valueDegrees()));
679 MMstore(m, tuple, 2, FTOM(zrad.valueDegrees()));
680 MMset(m, 0, PTOM(tuple));
697 MMechostr(MSKDEBUG,
"SO3MathsQuatToEulerDegreeZYX\n");
700 int q = MTOP(MMget(m, 0));
707 int x = MMfetch(m, q, 0);
708 int y = MMfetch(m, q, 1);
709 int z = MMfetch(m, q, 2);
710 int w = MMfetch(m, q, 3);
712 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
718 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
726 quat.ToRotationMatrix(mat);
728 mat.ToEulerAnglesZYX(yrad, xrad, zrad);
730 int tuple = MMmalloc(m, 3, TYPETAB);
736 MMstore(m, tuple, 0, FTOM(xrad.valueDegrees()));
737 MMstore(m, tuple, 1, FTOM(yrad.valueDegrees()));
738 MMstore(m, tuple, 2, FTOM(zrad.valueDegrees()));
739 MMset(m, 0, PTOM(tuple));
756 MMechostr(MSKDEBUG,
"SO3MathsEulerXYZToQuat\n");
759 int vec = MTOP(MMget(m, 0));
766 int x = MMfetch(m, vec, 0);
767 int y = MMfetch(m, vec, 1);
768 int z = MMfetch(m, vec, 2);
770 if ((x == NIL) || (y == NIL) || (z == NIL))
776 Ogre::Radian xrad = Ogre::Radian(MTOF(x));
777 Ogre::Radian yrad = Ogre::Radian(MTOF(y));
778 Ogre::Radian zrad = Ogre::Radian(MTOF(z));
782 mat.FromEulerAnglesXYZ(yrad, xrad, zrad);
784 Ogre::Quaternion quat;
785 quat.FromRotationMatrix(mat);
788 int tuple = MMmalloc(m, 4, TYPETAB);
794 MMstore(m, tuple, 0, FTOM(quat.x));
795 MMstore(m, tuple, 1, FTOM(quat.y));
796 MMstore(m, tuple, 2, FTOM(quat.z));
797 MMstore(m, tuple, 3, FTOM(quat.w));
798 MMset(m, 0, PTOM(tuple));
815 MMechostr(MSKDEBUG,
"SO3MathsEulerXZYToQuat\n");
818 int vec = MTOP(MMget(m, 0));
825 int x = MMfetch(m, vec, 0);
826 int y = MMfetch(m, vec, 1);
827 int z = MMfetch(m, vec, 2);
829 if ((x == NIL) || (y == NIL) || (z == NIL))
835 Ogre::Radian xrad = Ogre::Radian(MTOF(x));
836 Ogre::Radian yrad = Ogre::Radian(MTOF(y));
837 Ogre::Radian zrad = Ogre::Radian(MTOF(z));
841 mat.FromEulerAnglesXZY(yrad, xrad, zrad);
843 Ogre::Quaternion quat;
844 quat.FromRotationMatrix(mat);
847 int tuple = MMmalloc(m, 4, TYPETAB);
853 MMstore(m, tuple, 0, FTOM(quat.x));
854 MMstore(m, tuple, 1, FTOM(quat.y));
855 MMstore(m, tuple, 2, FTOM(quat.z));
856 MMstore(m, tuple, 3, FTOM(quat.w));
857 MMset(m, 0, PTOM(tuple));
874 MMechostr(MSKDEBUG,
"SO3MathsEulerYXZToQuat\n");
877 int vec = MTOP(MMget(m, 0));
884 int x = MMfetch(m, vec, 0);
885 int y = MMfetch(m, vec, 1);
886 int z = MMfetch(m, vec, 2);
888 if ((x == NIL) || (y == NIL) || (z == NIL))
894 Ogre::Radian xrad = Ogre::Radian(MTOF(x));
895 Ogre::Radian yrad = Ogre::Radian(MTOF(y));
896 Ogre::Radian zrad = Ogre::Radian(MTOF(z));
900 mat.FromEulerAnglesYXZ(yrad, xrad, zrad);
902 Ogre::Quaternion quat;
903 quat.FromRotationMatrix(mat);
906 int tuple = MMmalloc(m, 4, TYPETAB);
912 MMstore(m, tuple, 0, FTOM(quat.x));
913 MMstore(m, tuple, 1, FTOM(quat.y));
914 MMstore(m, tuple, 2, FTOM(quat.z));
915 MMstore(m, tuple, 3, FTOM(quat.w));
916 MMset(m, 0, PTOM(tuple));
933 MMechostr(MSKDEBUG,
"SO3MathsEulerYZXToQuat\n");
936 int vec = MTOP(MMget(m, 0));
943 int x = MMfetch(m, vec, 0);
944 int y = MMfetch(m, vec, 1);
945 int z = MMfetch(m, vec, 2);
947 if ((x == NIL) || (y == NIL) || (z == NIL))
953 Ogre::Radian xrad = Ogre::Radian(MTOF(x));
954 Ogre::Radian yrad = Ogre::Radian(MTOF(y));
955 Ogre::Radian zrad = Ogre::Radian(MTOF(z));
959 mat.FromEulerAnglesYZX(yrad, xrad, zrad);
961 Ogre::Quaternion quat;
962 quat.FromRotationMatrix(mat);
965 int tuple = MMmalloc(m, 4, TYPETAB);
971 MMstore(m, tuple, 0, FTOM(quat.x));
972 MMstore(m, tuple, 1, FTOM(quat.y));
973 MMstore(m, tuple, 2, FTOM(quat.z));
974 MMstore(m, tuple, 3, FTOM(quat.w));
975 MMset(m, 0, PTOM(tuple));
992 MMechostr(MSKDEBUG,
"SO3MathsEulerZYXToQuat\n");
995 int vec = MTOP(MMget(m, 0));
1002 int x = MMfetch(m, vec, 0);
1003 int y = MMfetch(m, vec, 1);
1004 int z = MMfetch(m, vec, 2);
1006 if ((x == NIL) || (y == NIL) || (z == NIL))
1012 Ogre::Radian xrad = Ogre::Radian(MTOF(x));
1013 Ogre::Radian yrad = Ogre::Radian(MTOF(y));
1014 Ogre::Radian zrad = Ogre::Radian(MTOF(z));
1018 mat.FromEulerAnglesZYX(yrad, xrad, zrad);
1020 Ogre::Quaternion quat;
1021 quat.FromRotationMatrix(mat);
1024 int tuple = MMmalloc(m, 4, TYPETAB);
1030 MMstore(m, tuple, 0, FTOM(quat.x));
1031 MMstore(m, tuple, 1, FTOM(quat.y));
1032 MMstore(m, tuple, 2, FTOM(quat.z));
1033 MMstore(m, tuple, 3, FTOM(quat.w));
1034 MMset(m, 0, PTOM(tuple));
1051 MMechostr(MSKDEBUG,
"SO3MathsEulerZXYToQuat\n");
1054 int vec = MTOP(MMget(m, 0));
1061 int x = MMfetch(m, vec, 0);
1062 int y = MMfetch(m, vec, 1);
1063 int z = MMfetch(m, vec, 2);
1065 if ((x == NIL) || (y == NIL) || (z == NIL))
1071 Ogre::Radian xrad = Ogre::Radian(MTOF(x));
1072 Ogre::Radian yrad = Ogre::Radian(MTOF(y));
1073 Ogre::Radian zrad = Ogre::Radian(MTOF(z));
1077 mat.FromEulerAnglesZXY(yrad, xrad, zrad);
1079 Ogre::Quaternion quat;
1080 quat.FromRotationMatrix(mat);
1083 int tuple = MMmalloc(m, 4, TYPETAB);
1089 MMstore(m, tuple, 0, FTOM(quat.x));
1090 MMstore(m, tuple, 1, FTOM(quat.y));
1091 MMstore(m, tuple, 2, FTOM(quat.z));
1092 MMstore(m, tuple, 3, FTOM(quat.w));
1093 MMset(m, 0, PTOM(tuple));
1111 MMechostr(MSKDEBUG,
"SO3MathsQuatIsEqual\n");
1114 int q2 = MTOP(MMpull(m));
1115 int q1 = MTOP(MMget(m, 0));
1117 if (q1 == NIL || q2 == NIL)
1123 int x1 = MMfetch(m, q1, 0);
1124 int y1 = MMfetch(m, q1, 1);
1125 int z1 = MMfetch(m, q1, 2);
1126 int w1 = MMfetch(m, q1, 3);
1128 int x2 = MMfetch(m, q2, 0);
1129 int y2 = MMfetch(m, q2, 1);
1130 int z2 = MMfetch(m, q2, 2);
1131 int w2 = MMfetch(m, q2, 3);
1133 if ((x1 == NIL) || (y1 == NIL) || (z1 == NIL) || (w1 == NIL) || (x2 == NIL) || (y2 == NIL) || (z2 == NIL) || (w2 == NIL))
1139 Ogre::Quaternion quat1 = Ogre::Quaternion(MTOF(w1), MTOF(x1), MTOF(y1), MTOF(z1));
1140 Ogre::Quaternion quat2 = Ogre::Quaternion(MTOF(w2), MTOF(x2), MTOF(y2), MTOF(z2));
1142 MMset(m, 0, ITOM((quat1 == quat2 ? 1 : 0)));
1159 MMechostr(MSKDEBUG,
"SO3MathsQuatDiff\n");
1162 int q2 = MTOP(MMpull(m));
1163 int q1 = MTOP(MMget(m, 0));
1165 if (q1 == NIL || q2 == NIL)
1171 int x1 = MMfetch(m, q1, 0);
1172 int y1 = MMfetch(m, q1, 1);
1173 int z1 = MMfetch(m, q1, 2);
1174 int w1 = MMfetch(m, q1, 3);
1176 int x2 = MMfetch(m, q2, 0);
1177 int y2 = MMfetch(m, q2, 1);
1178 int z2 = MMfetch(m, q2, 2);
1179 int w2 = MMfetch(m, q2, 3);
1181 if ((x1 == NIL) || (y1 == NIL) || (z1 == NIL) || (w1 == NIL) || (x2 == NIL) || (y2 == NIL) || (z2 == NIL) || (w2 == NIL))
1187 Ogre::Quaternion quat1 = Ogre::Quaternion(MTOF(w1), MTOF(x1), MTOF(y1), MTOF(z1));
1188 Ogre::Quaternion quat2 = Ogre::Quaternion(MTOF(w2), MTOF(x2), MTOF(y2), MTOF(z2));
1190 Ogre::Quaternion quatResult = quat1 * quat2.Inverse();
1191 quatResult.normalise();
1193 int tuple = MMmalloc(m, 4, TYPETAB);
1199 MMstore(m, tuple, 0, FTOM(quatResult.x));
1200 MMstore(m, tuple, 1, FTOM(quatResult.y));
1201 MMstore(m, tuple, 2, FTOM(quatResult.z));
1202 MMstore(m, tuple, 3, FTOM(quatResult.w));
1203 MMset(m, 0, PTOM(tuple));
1221 MMechostr(MSKDEBUG,
"SO3MathsQuatSubstract\n");
1224 int q2 = MTOP(MMpull(m));
1225 int q1 = MTOP(MMget(m, 0));
1227 if (q1 == NIL || q2 == NIL)
1233 int x1 = MMfetch(m, q1, 0);
1234 int y1 = MMfetch(m, q1, 1);
1235 int z1 = MMfetch(m, q1, 2);
1236 int w1 = MMfetch(m, q1, 3);
1238 int x2 = MMfetch(m, q2, 0);
1239 int y2 = MMfetch(m, q2, 1);
1240 int z2 = MMfetch(m, q2, 2);
1241 int w2 = MMfetch(m, q2, 3);
1243 if ((x1 == NIL) || (y1 == NIL) || (z1 == NIL) || (w1 == NIL) || (x2 == NIL) || (y2 == NIL) || (z2 == NIL) || (w2 == NIL))
1249 Ogre::Quaternion quat1 = Ogre::Quaternion(MTOF(w1), MTOF(x1), MTOF(y1), MTOF(z1));
1251 Ogre::Quaternion quat2 = Ogre::Quaternion(MTOF(w2), MTOF(x2), MTOF(y2), MTOF(z2));
1253 Ogre::Quaternion quatResult = quat1.Inverse() * quat2;
1254 quatResult.normalise();
1256 int tuple = MMmalloc(m, 4, TYPETAB);
1262 MMstore(m, tuple, 0, FTOM(quatResult.x));
1263 MMstore(m, tuple, 1, FTOM(quatResult.y));
1264 MMstore(m, tuple, 2, FTOM(quatResult.z));
1265 MMstore(m, tuple, 3, FTOM(quatResult.w));
1266 MMset(m, 0, PTOM(tuple));
1284 MMechostr(MSKDEBUG,
"SO3MathsQuatAdd\n");
1287 int q2 = MTOP(MMpull(m));
1288 int q1 = MTOP(MMget(m, 0));
1290 if (q1 == NIL || q2 == NIL)
1296 int x1 = MMfetch(m, q1, 0);
1297 int y1 = MMfetch(m, q1, 1);
1298 int z1 = MMfetch(m, q1, 2);
1299 int w1 = MMfetch(m, q1, 3);
1301 int x2 = MMfetch(m, q2, 0);
1302 int y2 = MMfetch(m, q2, 1);
1303 int z2 = MMfetch(m, q2, 2);
1304 int w2 = MMfetch(m, q2, 3);
1306 if ((x1 == NIL) || (y1 == NIL) || (z1 == NIL) || (w1 == NIL) || (x2 == NIL) || (y2 == NIL) || (z2 == NIL) || (w2 == NIL))
1312 Ogre::Quaternion quat1 = Ogre::Quaternion(MTOF(w1), MTOF(x1), MTOF(y1), MTOF(z1));
1314 Ogre::Quaternion quat2 = Ogre::Quaternion(MTOF(w2), MTOF(x2), MTOF(y2), MTOF(z2));
1317 Ogre::Quaternion quatResult = quat1 * quat2;
1318 quatResult.normalise();
1320 int tuple = MMmalloc(m, 4, TYPETAB);
1327 MMstore(m, tuple, 0, FTOM(quatResult.x));
1328 MMstore(m, tuple, 1, FTOM(quatResult.y));
1329 MMstore(m, tuple, 2, FTOM(quatResult.z));
1330 MMstore(m, tuple, 3, FTOM(quatResult.w));
1331 MMset(m, 0, PTOM(tuple));
1351 MMechostr(MSKDEBUG,
"SO3MathsQuatInterpolate\n");
1354 int ishort = MTOI(MMpull(m));
1355 int coef = MMpull(m);
1356 int q2 = MTOP(MMpull(m));
1357 int q1 = MTOP(MMget(m, 0));
1359 if ((q1 == NIL) || (q2 == NIL) || (coef == NIL))
1365 bool bshort =
false;
1369 int x1 = MMfetch(m, q1, 0);
1370 int y1 = MMfetch(m, q1, 1);
1371 int z1 = MMfetch(m, q1, 2);
1372 int w1 = MMfetch(m, q1, 3);
1374 int x2 = MMfetch(m, q2, 0);
1375 int y2 = MMfetch(m, q2, 1);
1376 int z2 = MMfetch(m, q2, 2);
1377 int w2 = MMfetch(m, q2, 3);
1379 if ((x1 == NIL) || (y1 == NIL) || (z1 == NIL) || (w1 == NIL) || (x2 == NIL) || (y2 == NIL) || (z2 == NIL) || (w2 == NIL))
1385 Ogre::Quaternion quat1 = Ogre::Quaternion(MTOF(w1), MTOF(x1), MTOF(y1), MTOF(z1));
1387 Ogre::Quaternion quat2 = Ogre::Quaternion(MTOF(w2), MTOF(x2), MTOF(y2), MTOF(z2));
1390 Ogre::Quaternion quatResult = Ogre::Quaternion::Slerp((Ogre::Real)MTOF(coef), quat1, quat2, bshort);
1391 quatResult.normalise();
1393 int tuple = MMmalloc(m, 4, TYPETAB);
1400 MMstore(m, tuple, 0, FTOM(quatResult.x));
1401 MMstore(m, tuple, 1, FTOM(quatResult.y));
1402 MMstore(m, tuple, 2, FTOM(quatResult.z));
1403 MMstore(m, tuple, 3, FTOM(quatResult.w));
1404 MMset(m, 0, PTOM(tuple));
1421 MMechostr(MSKDEBUG,
"SO3MathsDegreeToRadian\n");
1424 int val = MMget(m, 0);
1431 Ogre::Degree deg = Ogre::Degree(MTOF(val));
1432 float rad = deg.valueRadians();
1434 MMset(m, 0, FTOM(rad));
1451 MMechostr(MSKDEBUG,
"SO3MathsRadianToDegree\n");
1454 int val = MMget(m, 0);
1461 Ogre::Radian rad = Ogre::Radian(MTOF(val));
1462 float deg = rad.valueDegrees();
1464 MMset(m, 0, FTOM(deg));
1482 MMechostr(MSKDEBUG,
"SO3MathsQuatGetRoll\n");
1485 int booleen = MTOI(MMpull(m));
1486 int q = MMget(m, 0);
1493 int x = MMfetch(m, MTOP(q), 0);
1494 int y = MMfetch(m, MTOP(q), 1);
1495 int z = MMfetch(m, MTOP(q), 2);
1496 int w = MMfetch(m, MTOP(q), 3);
1498 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
1504 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
1507 Ogre::Radian roll = quat.getRoll(booleen == 1 ?
true :
false);
1509 MMset(m, 0, FTOM(roll.valueRadians()));
1526 MMechostr(MSKDEBUG,
"SO3MathsQuatGetYaw\n");
1529 int booleen = MTOI(MMpull(m));
1530 int q = MMget(m, 0);
1537 int x = MMfetch(m, MTOP(q), 0);
1538 int y = MMfetch(m, MTOP(q), 1);
1539 int z = MMfetch(m, MTOP(q), 2);
1540 int w = MMfetch(m, MTOP(q), 3);
1542 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
1548 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
1551 Ogre::Radian yaw = quat.getYaw(booleen == 1 ?
true :
false);
1553 MMset(m, 0, FTOM(yaw.valueRadians()));
1570 MMechostr(MSKDEBUG,
"SO3MathsQuatGetPitch\n");
1573 int booleen = MTOI(MMpull(m));
1574 int q = MMget(m, 0);
1581 int x = MMfetch(m, MTOP(q), 0);
1582 int y = MMfetch(m, MTOP(q), 1);
1583 int z = MMfetch(m, MTOP(q), 2);
1584 int w = MMfetch(m, MTOP(q), 3);
1586 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
1592 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
1595 Ogre::Radian pitch = quat.getPitch(booleen == 1 ?
true :
false);
1597 MMset(m, 0, FTOM(pitch.valueRadians()));
1614 MMechostr(MSKDEBUG,
"SO3MathsQuatGetDegreeRoll\n");
1617 int booleen = MTOI(MMpull(m));
1618 int q = MMget(m, 0);
1625 int x = MMfetch(m, MTOP(q), 0);
1626 int y = MMfetch(m, MTOP(q), 1);
1627 int z = MMfetch(m, MTOP(q), 2);
1628 int w = MMfetch(m, MTOP(q), 3);
1630 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
1636 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
1639 Ogre::Radian roll = quat.getRoll(booleen == 1 ?
true :
false);
1641 MMset(m, 0, FTOM(roll.valueDegrees()));
1658 MMechostr(MSKDEBUG,
"SO3MathsQuatGetDegreeYaw\n");
1661 int booleen = MTOI(MMpull(m));
1662 int q = MMget(m, 0);
1669 int x = MMfetch(m, MTOP(q), 0);
1670 int y = MMfetch(m, MTOP(q), 1);
1671 int z = MMfetch(m, MTOP(q), 2);
1672 int w = MMfetch(m, MTOP(q), 3);
1674 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
1680 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
1683 Ogre::Radian yaw = quat.getYaw(booleen == 1 ?
true :
false);
1685 MMset(m, 0, FTOM(yaw.valueDegrees()));
1702 MMechostr(MSKDEBUG,
"SO3MathsQuatGetDegreePitch\n");
1705 int booleen = MTOI(MMpull(m));
1706 int q = MMget(m, 0);
1713 int x = MMfetch(m, MTOP(q), 0);
1714 int y = MMfetch(m, MTOP(q), 1);
1715 int z = MMfetch(m, MTOP(q), 2);
1716 int w = MMfetch(m, MTOP(q), 3);
1718 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
1724 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
1727 Ogre::Radian pitch = quat.getPitch(booleen == 1 ?
true :
false);
1729 MMset(m, 0, FTOM(pitch.valueDegrees()));
1745 MMechostr(MSKDEBUG,
"SO3MathsQuatToAxes\n");
1748 int q = MMget(m, 0);
1755 int x = MMfetch(m, MTOP(q), 0);
1756 int y = MMfetch(m, MTOP(q), 1);
1757 int z = MMfetch(m, MTOP(q), 2);
1758 int w = MMfetch(m, MTOP(q), 3);
1760 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
1766 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
1769 Ogre::Vector3 xAxis;
1770 Ogre::Vector3 yAxis;
1771 Ogre::Vector3 zAxis;
1773 quat.ToAxes(xAxis, yAxis, zAxis);
1776 int xtuple = MMmalloc(m, 3, TYPETAB);
1782 MMstore(m, xtuple, 0, FTOM(xAxis.x));
1783 MMstore(m, xtuple, 1, FTOM(xAxis.y));
1784 MMstore(m, xtuple, 2, FTOM(xAxis.z));
1785 MMpush(m, PTOM(xtuple));
1788 int ytuple = MMmalloc(m, 3, TYPETAB);
1794 MMstore(m, ytuple, 0, FTOM(yAxis.x));
1795 MMstore(m, ytuple, 1, FTOM(yAxis.y));
1796 MMstore(m, ytuple, 2, FTOM(yAxis.z));
1797 MMpush(m, PTOM(ytuple));
1800 int ztuple = MMmalloc(m, 3, TYPETAB);
1807 MMstore(m, ztuple, 0, FTOM(zAxis.x));
1808 MMstore(m, ztuple, 1, FTOM(zAxis.y));
1809 MMstore(m, ztuple, 2, FTOM(zAxis.z));
1810 MMpush(m, PTOM(ztuple));
1813 int result = MMmalloc(m, 3, TYPETAB);
1819 MMstore(m, result, 2, MMpull(m));
1820 MMstore(m, result, 1, MMpull(m));
1821 MMstore(m, result, 0, MMpull(m));
1822 MMset(m, 0, PTOM(result));
1838 MMechostr(MSKDEBUG,
"SO3MathsQuatFromAngle\n");
1841 int vec = MMget(m, 0);
1848 int x = MMfetch(m, MTOP(vec), 0);
1849 int y = MMfetch(m, MTOP(vec), 1);
1850 int z = MMfetch(m, MTOP(vec), 2);
1852 if ((x == NIL) || (y == NIL) || (z == NIL))
1858 Ogre::Quaternion quatX;
1859 Ogre::Quaternion quatY;
1860 Ogre::Quaternion quatZ;
1862 quatX.FromAngleAxis(Ogre::Radian(MTOF(x)), Ogre::Vector3(1, 0, 0));
1863 quatY.FromAngleAxis(Ogre::Radian(MTOF(y)), Ogre::Vector3(0, 1, 0));
1864 quatZ.FromAngleAxis(Ogre::Radian(MTOF(z)), Ogre::Vector3(0, 0, 1));
1866 Ogre::Quaternion quatResult;
1867 quatResult = quatX * quatY * quatZ;
1868 quatResult.normalise();
1870 int tuple = MMmalloc(m, 4, TYPETAB);
1876 MMstore(m, tuple, 0, FTOM((quatResult.x)));
1877 MMstore(m, tuple, 1, FTOM((quatResult.y)));
1878 MMstore(m, tuple, 2, FTOM((quatResult.z)));
1879 MMstore(m, tuple, 3, FTOM((quatResult.w)));
1880 MMset(m, 0, PTOM(tuple));
1896 MMechostr(MSKDEBUG,
"SO3MathsQuatFromDegreeAngle\n");
1899 int vec = MMget(m, 0);
1906 int x = MMfetch(m, MTOP(vec), 0);
1907 int y = MMfetch(m, MTOP(vec), 1);
1908 int z = MMfetch(m, MTOP(vec), 2);
1910 if ((x == NIL) || (y == NIL) || (z == NIL))
1916 Ogre::Quaternion quatX;
1917 Ogre::Quaternion quatY;
1918 Ogre::Quaternion quatZ;
1920 Ogre::Degree dx = (Ogre::Degree)MTOF(x);
1921 Ogre::Degree dy = (Ogre::Degree)MTOF(y);
1922 Ogre::Degree dz = (Ogre::Degree)MTOF(z);
1923 quatX.FromAngleAxis((Ogre::Radian)dx.valueRadians(), Ogre::Vector3(1, 0, 0));
1924 quatY.FromAngleAxis((Ogre::Radian)dy.valueRadians(), Ogre::Vector3(0, 1, 0));
1925 quatZ.FromAngleAxis((Ogre::Radian)dz.valueRadians(), Ogre::Vector3(0, 0, 1));
1927 Ogre::Quaternion quatResult;
1928 quatResult = quatX * quatY * quatZ;
1929 quatResult.normalise();
1931 int tuple = MMmalloc(m, 4, TYPETAB);
1937 MMstore(m, tuple, 0, FTOM((quatResult.x)));
1938 MMstore(m, tuple, 1, FTOM((quatResult.y)));
1939 MMstore(m, tuple, 2, FTOM((quatResult.z)));
1940 MMstore(m, tuple, 3, FTOM((quatResult.w)));
1941 MMset(m, 0, PTOM(tuple));
1959 MMechostr(MSKDEBUG,
"SO3MathsQuatFromAngleAxis\n");
1962 int vec = MMpull(m);
1963 int rad = MMget(m, 0);
1964 if ((vec == NIL) || (rad == NIL))
1970 int x = MMfetch(m, MTOP(vec), 0);
1971 int y = MMfetch(m, MTOP(vec), 1);
1972 int z = MMfetch(m, MTOP(vec), 2);
1974 if ((x == NIL) || (y == NIL) || (z == NIL))
1980 Ogre::Quaternion quatResult;
1981 Ogre::Vector3 axis(MTOF(x), MTOF(y), MTOF(z));
1982 quatResult.FromAngleAxis(Ogre::Radian(MTOF(rad)), axis);
1983 quatResult.normalise();
1985 int tuple = MMmalloc(m, 4, TYPETAB);
1991 MMstore(m, tuple, 0, FTOM((quatResult.x)));
1992 MMstore(m, tuple, 1, FTOM((quatResult.y)));
1993 MMstore(m, tuple, 2, FTOM((quatResult.z)));
1994 MMstore(m, tuple, 3, FTOM((quatResult.w)));
1995 MMset(m, 0, PTOM(tuple));
2011 MMechostr(MSKDEBUG,
"SO3MathsQuatFromAxes\n");
2014 int z = MTOP(MMpull(m));
2015 int y = MTOP(MMpull(m));
2016 int x = MTOP(MMget(m, 0));
2017 if (x == NIL || y == NIL || z == NIL)
2023 Ogre::Vector3 xAxis;
2024 xAxis.x = MTOF(MMfetch(m, x, 0));
2025 xAxis.y = MTOF(MMfetch(m, x, 1));
2026 xAxis.z = MTOF(MMfetch(m, x, 2));
2028 Ogre::Vector3 yAxis;
2029 yAxis.x = MTOF(MMfetch(m, y, 0));
2030 yAxis.y = MTOF(MMfetch(m, y, 1));
2031 yAxis.z = MTOF(MMfetch(m, y, 2));
2033 Ogre::Vector3 zAxis;
2034 zAxis.x = MTOF(MMfetch(m, z, 0));
2035 zAxis.y = MTOF(MMfetch(m, z, 1));
2036 zAxis.z = MTOF(MMfetch(m, z, 2));
2039 Ogre::Quaternion quat;
2041 quat.FromAxes(xAxis, yAxis, zAxis);
2044 int tuple = MMmalloc(m, 4, TYPETAB);
2050 MMstore(m, tuple, 0, FTOM((quat.x)));
2051 MMstore(m, tuple, 1, FTOM((quat.y)));
2052 MMstore(m, tuple, 2, FTOM((quat.z)));
2053 MMstore(m, tuple, 3, FTOM((quat.w)));
2054 MMset(m, 0, PTOM(tuple));
2071 MMechostr(MSKDEBUG,
"SO3MathsQuatGetXaxis\n");
2074 int q = MMget(m, 0);
2081 int x = MMfetch(m, MTOP(q), 0);
2082 int y = MMfetch(m, MTOP(q), 1);
2083 int z = MMfetch(m, MTOP(q), 2);
2084 int w = MMfetch(m, MTOP(q), 3);
2086 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
2092 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
2095 Ogre::Vector3 vec = quat.xAxis();
2097 int tuple = MMmalloc(m, 3, TYPETAB);
2103 MMstore(m, tuple, 0, FTOM((vec.x)));
2104 MMstore(m, tuple, 1, FTOM((vec.y)));
2105 MMstore(m, tuple, 2, FTOM((vec.z)));
2106 MMset(m, 0, PTOM(tuple));
2123 MMechostr(MSKDEBUG,
"SO3MathsQuatGetYaxis\n");
2126 int q = MTOP(MMget(m, 0));
2133 int x = MMfetch(m, q, 0);
2134 int y = MMfetch(m, q, 1);
2135 int z = MMfetch(m, q, 2);
2136 int w = MMfetch(m, q, 3);
2138 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
2144 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
2147 Ogre::Vector3 vec = quat.yAxis();
2149 int tuple = MMmalloc(m, 3, TYPETAB);
2155 MMstore(m, tuple, 0, FTOM((vec.x)));
2156 MMstore(m, tuple, 1, FTOM((vec.y)));
2157 MMstore(m, tuple, 2, FTOM((vec.z)));
2158 MMset(m, 0, PTOM(tuple));
2175 MMechostr(MSKDEBUG,
"SO3MathsQuatGetZaxis\n");
2178 int q = MTOP(MMget(m, 0));
2185 int x = MMfetch(m, q, 0);
2186 int y = MMfetch(m, q, 1);
2187 int z = MMfetch(m, q, 2);
2188 int w = MMfetch(m, q, 3);
2190 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
2196 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
2199 Ogre::Vector3 vec = quat.zAxis();
2201 int tuple = MMmalloc(m, 3, TYPETAB);
2207 MMstore(m, tuple, 0, FTOM((vec.x)));
2208 MMstore(m, tuple, 1, FTOM((vec.y)));
2209 MMstore(m, tuple, 2, FTOM((vec.z)));
2210 MMset(m, 0, PTOM(tuple));
2228 MMechostr(MSKDEBUG,
"SO3MathsQuatGetDirection\n");
2231 int v = MTOP(MMpull(m));
2232 int q = MTOP(MMget(m, 0));
2234 if (v == NIL || q == NIL)
2240 int vx = MMfetch(m, v, 0);
2241 int vy = MMfetch(m, v, 1);
2242 int vz = MMfetch(m, v, 2);
2244 if ((vx == NIL) || (vy == NIL) || (vz == NIL))
2250 Ogre::Vector3 vec = Ogre::Vector3(MTOF(vx), MTOF(vy), MTOF(vz));
2252 int qx = MMfetch(m, q, 0);
2253 int qy = MMfetch(m, q, 1);
2254 int qz = MMfetch(m, q, 2);
2255 int qw = MMfetch(m, q, 3);
2257 if ((qx == NIL) || (qy == NIL) || (qz == NIL) || (qw == NIL))
2263 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(qw), MTOF(qx), MTOF(qy), MTOF(qz));
2266 Ogre::Vector3 rvec = quat * vec;
2268 int tuple = MMmalloc(m, 3, TYPETAB);
2274 MMstore(m, tuple, 0, FTOM((rvec.x)));
2275 MMstore(m, tuple, 1, FTOM((rvec.y)));
2276 MMstore(m, tuple, 2, FTOM((rvec.z)));
2277 MMset(m, 0, PTOM(tuple));
2294 MMechostr(MSKDEBUG,
"SO3MathsClampValue\n");
2297 int valMax = MMpull(m);
2298 int valMin = MMpull(m);
2299 int val = MMget(m, 0);
2301 if ((val == NIL) || (valMin == NIL) || (valMax == NIL))
2307 float result = Ogre::Math::Clamp(MTOF(val), MTOF(valMin), MTOF(valMax));
2309 MMset(m, 0, FTOM(result));
2327 MMechostr(MSKDEBUG,
"SO3MathsGetRotationTo\n");
2330 int scolVector2 = MTOP(MMpull(m));
2331 int scolVector1 = MTOP(MMget(m, 0));
2332 if ((scolVector1 == NIL) || (scolVector2 == NIL))
2339 int xTemp = MMfetch(m, scolVector1, 0);
2340 int yTemp = MMfetch(m, scolVector1, 1);
2341 int zTemp = MMfetch(m, scolVector1, 2);
2349 Ogre::Vector3 sourceVector(MTOF(xTemp), MTOF(yTemp), MTOF(zTemp));
2352 xTemp = MMfetch(m, scolVector2, 0);
2353 yTemp = MMfetch(m, scolVector2, 1);
2354 zTemp = MMfetch(m, scolVector2, 2);
2362 Ogre::Vector3 destinationVector(MTOF(xTemp), MTOF(yTemp), MTOF(zTemp));
2365 Ogre::Quaternion quatResult = sourceVector.getRotationTo(destinationVector);
2366 quatResult.normalise();
2369 int tuple = MMmalloc(m, 4, TYPETAB);
2375 MMstore(m, tuple, 0, FTOM((quatResult.x)));
2376 MMstore(m, tuple, 1, FTOM((quatResult.y)));
2377 MMstore(m, tuple, 2, FTOM((quatResult.z)));
2378 MMstore(m, tuple, 3, FTOM((quatResult.w)));
2379 MMset(m, 0, PTOM(tuple));
2396 MMechostr(MSKDEBUG,
"SO3MathsGetRotationToAxis\n");
2399 int scolVector2 = MTOP(MMpull(m));
2400 int scolVector1 = MTOP(MMget(m, 0));
2401 if ((scolVector1 == NIL) || (scolVector2 == NIL))
2408 int xTemp = MMfetch(m, scolVector1, 0);
2409 int yTemp = MMfetch(m, scolVector1, 1);
2410 int zTemp = MMfetch(m, scolVector1, 2);
2418 Ogre::Vector3 src(MTOF(xTemp), MTOF(yTemp), MTOF(zTemp));
2421 xTemp = MMfetch(m, scolVector2, 0);
2422 yTemp = MMfetch(m, scolVector2, 1);
2423 zTemp = MMfetch(m, scolVector2, 2);
2431 Ogre::Vector3 axis(MTOF(xTemp), MTOF(yTemp), MTOF(zTemp));
2438 Ogre::Vector3 forward = src;
2439 forward.normalise();
2441 Ogre::Vector3 up = axis;
2442 up -= forward * forward.dotProduct(up);
2445 Ogre::Vector3 right = up.crossProduct(forward);
2446 Ogre::Quaternion quatResult;
2447 quatResult.w = sqrtf(1.0f + right.x + up.y + forward.z) * 0.5f;
2448 float w4_recip = 1.0f / (4.0f * quatResult.w);
2449 quatResult.x = (up.z - forward.y) * w4_recip;
2450 quatResult.y = (forward.x - right.z) * w4_recip;
2451 quatResult.z = (right.y - up.x) * w4_recip;
2454 int tuple = MMmalloc(m, 4, TYPETAB);
2460 MMstore(m, tuple, 0, FTOM((quatResult.x)));
2461 MMstore(m, tuple, 1, FTOM((quatResult.y)));
2462 MMstore(m, tuple, 2, FTOM((quatResult.z)));
2463 MMstore(m, tuple, 3, FTOM((quatResult.w)));
2464 MMset(m, 0, PTOM(tuple));
2485 MMechostr(MSKDEBUG,
"SO3MathsVectorDotProduct\n");
2488 int scolVector2 = MTOP(MMpull(m));
2489 int scolVector1 = MTOP(MMget(m, 0));
2490 if ((scolVector1 == NIL) || (scolVector2 == NIL))
2497 int xTemp = MMfetch(m, scolVector1, 0);
2498 int yTemp = MMfetch(m, scolVector1, 1);
2499 int zTemp = MMfetch(m, scolVector1, 2);
2507 Ogre::Vector3 referenceVector(MTOF(xTemp), MTOF(yTemp), MTOF(zTemp));
2510 xTemp = MMfetch(m, scolVector2, 0);
2511 yTemp = MMfetch(m, scolVector2, 1);
2512 zTemp = MMfetch(m, scolVector2, 2);
2520 Ogre::Vector3 destinationVector(MTOF(xTemp), MTOF(yTemp), MTOF(zTemp));
2523 Ogre::Real scalarProduct = referenceVector.dotProduct(destinationVector);
2526 MMset(m, 0, FTOM(scalarProduct));
2543 MMechostr(MSKDEBUG,
"SO3MathsQuatRotate\n");
2546 int v = MTOP(MMpull(m));
2547 int q = MTOP(MMget(m, 0));
2549 if (v == NIL || q == NIL)
2555 int vyaw = MMfetch(m, v, 0);
2556 int vpitch = MMfetch(m, v, 1);
2557 int vroll = MMfetch(m, v, 2);
2559 if ((vyaw == NIL) || (vpitch == NIL) || (vroll == NIL))
2565 int qx = MMfetch(m, q, 0);
2566 int qy = MMfetch(m, q, 1);
2567 int qz = MMfetch(m, q, 2);
2568 int qw = MMfetch(m, q, 3);
2570 if ((qx == NIL) || (qy == NIL) || (qz == NIL) || (qw == NIL))
2576 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(qw), MTOF(qx), MTOF(qy), MTOF(qz));
2579 euler.
rotate(Ogre::Radian(MTOF(vyaw)), Ogre::Radian(MTOF(vpitch)), Ogre::Radian(MTOF(vroll)));
2583 int tuple = MMmalloc(m, 4, TYPETAB);
2589 MMstore(m, tuple, 0, FTOM((quatResult.x)));
2590 MMstore(m, tuple, 1, FTOM((quatResult.y)));
2591 MMstore(m, tuple, 2, FTOM((quatResult.z)));
2592 MMstore(m, tuple, 3, FTOM((quatResult.w)));
2593 MMset(m, 0, PTOM(tuple));
2608 MMechostr(MSKDEBUG,
"SO3MathsQuatToEulerDegreePYR\n");
2611 int q = MTOP(MMget(m, 0));
2618 int x = MMfetch(m, q, 0);
2619 int y = MMfetch(m, q, 1);
2620 int z = MMfetch(m, q, 2);
2621 int w = MMfetch(m, q, 3);
2623 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
2629 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
2632 Ogre::Radian xrad = euler.
getPitch();
2633 Ogre::Radian yrad = euler.
getYaw();
2634 Ogre::Radian zrad = euler.
getRoll();
2636 int tuple = MMmalloc(m, 3, TYPETAB);
2642 MMstore(m, tuple, 0, FTOM(xrad.valueDegrees()));
2643 MMstore(m, tuple, 1, FTOM(yrad.valueDegrees()));
2644 MMstore(m, tuple, 2, FTOM(zrad.valueDegrees()));
2645 MMset(m, 0, PTOM(tuple));
2661 MMechostr(MSKDEBUG,
"SO3MathsQuatToEulerPYR\n");
2664 int q = MTOP(MMget(m, 0));
2671 int x = MMfetch(m, q, 0);
2672 int y = MMfetch(m, q, 1);
2673 int z = MMfetch(m, q, 2);
2674 int w = MMfetch(m, q, 3);
2676 if ((x == NIL) || (y == NIL) || (z == NIL) || (
w == NIL))
2682 Ogre::Quaternion quat = Ogre::Quaternion(MTOF(
w), MTOF(x), MTOF(y), MTOF(z));
2685 Ogre::Radian xrad = euler.
getPitch();
2686 Ogre::Radian yrad = euler.
getYaw();
2687 Ogre::Radian zrad = euler.
getRoll();
2689 int tuple = MMmalloc(m, 3, TYPETAB);
2695 MMstore(m, tuple, 0, FTOM(xrad.valueRadians()));
2696 MMstore(m, tuple, 1, FTOM(yrad.valueRadians()));
2697 MMstore(m, tuple, 2, FTOM(zrad.valueRadians()));
2698 MMset(m, 0, PTOM(tuple));
2714 MMechostr(MSKDEBUG,
"SO3MathsEulerPYRToQuat\n");
2717 int q = MTOP(MMget(m, 0));
2724 int p = MMfetch(m, q, 0);
2725 int y = MMfetch(m, q, 1);
2726 int r = MMfetch(m, q, 2);
2728 if ((p == NIL) || (y == NIL) || (r == NIL))
2737 int tuple = MMmalloc(m, 4, TYPETAB);
2743 MMstore(m, tuple, 0, FTOM(quat.x));
2744 MMstore(m, tuple, 1, FTOM(quat.y));
2745 MMstore(m, tuple, 2, FTOM(quat.z));
2746 MMstore(m, tuple, 3, FTOM(quat.w));
2747 MMset(m, 0, PTOM(tuple));
2772 {
"SO3MathsQuatDiff", 2,
"fun [[F F F F] [F F F F]] [F F F F]",
SO3MathsQuatDiff },
2774 {
"SO3MathsQuatAdd", 2,
"fun [[F F F F] [F F F F]] [F F F F]",
SO3MathsQuatAdd },
2783 {
"SO3MathsQuatToAxes", 1,
"fun [[F F F F]] [[F F F] [F F F] [F F F]]",
SO3MathsQuatToAxes },
2784 {
"SO3MathsQuatFromAxes", 3,
"fun [[F F F] [F F F] [F F F]] [F F F F]",
SO3MathsQuatFromAxes },
2797 {
"SO3MathsQuatRotate", 2,
"fun [[F F F F] [F F F]] [F F F F]",
SO3MathsQuatRotate },
int SCOLloadMaths(mmachine m, cbmachine w)
Load the SO3Engine Mathematical functions.
NativeDefinition natSO3Maths[]
int SCOLfreeMaths()
free the SO3Engine Lights function
MMechostr(MSKDEBUG, " > Start loading Plugin SO3Engine dll\n")
SCOL_EXPORT int cbmachine w
Class for Euler rotations.
Euler & rotate(const Ogre::Radian &y, const Ogre::Radian &p, const Ogre::Radian &r)
Apply all relative rotations at once.
Ogre::Radian getYaw() const
Get the Yaw angle.
Ogre::Quaternion toQuaternion()
Calculate the quaternion of the euler object.
Ogre::Radian getRoll() const
Get the Roll angle.
Ogre::Radian getPitch() const
Get the Pitch angle.
int SO3MathsQuatFromAngle(mmachine m)
SO3MathsQuatFromAngle : function to get Quaternion from X Y Z angle.
int SO3MathsEulerXZYToQuat(mmachine m)
SO3MathsEulerXZYToQuat : Scol function to transform euler angles (XZY) (radians) in a quaternion !...
int SO3MathsQuatToEulerYZX(mmachine m)
SO3MathsQuatToEulerYZX : Scol function to transform quaternion vector in euler angles (YZX) !...
int SO3MathsQuatIsEqual(mmachine m)
SO3MathsQuatIsEqual : Scol function test two quaternion equality.
int SO3MathsQuatToEulerDegreeXYZ(mmachine m)
SO3MathsQuatToEulerDegreeXYZ : Scol function to transform quaternion vector in euler angles (degree) ...
int SO3MathsQuatGetPitch(mmachine m)
SO3MathsQuatGetPitch : function to get the pitch value from quaternion.
int SO3MathsQuatToEulerYXZ(mmachine m)
SO3MathsQuatToEulerYXZ : Scol function to transform quaternion vector in euler angles (YXZ) !...
int SO3MathsQuatRotate(mmachine m)
SO3MathsQuatRotate : Scol function to rotate a quaternion.
int SO3MathsQuatToEulerDegreeZXY(mmachine m)
SO3MathsQuatToEulerDegreeZXY : Scol function to transform quaternion vector in euler angles (degree) ...
int SO3MathsQuatFromAxes(mmachine m)
SO3MathsQuatFromAxes : function to get Quaternion from axis.
int SO3MathsQuatDiff(mmachine m)
SO3MathsQuatDiff : Scol function to make the mathematical difference between two quaternions.
int SO3MathsRadianToDegree(mmachine m)
SO3MathsRadianToDegree : function to convert a value from radians to degrees.
int SO3MathsQuatGetDegreePitch(mmachine m)
SO3MathsQuatGetDegreePitch : function to get the pitch value in degree from quaternion.
int SO3MathsClampValue(mmachine m)
SO3MathsClampValue : function to clamp a value.
int SO3MathsQuatGetDegreeRoll(mmachine m)
SO3MathsQuatGetDegreeRoll : function to get the roll value in degree from quaternion.
int SO3MathsQuatGetDegreeYaw(mmachine m)
SO3MathsQuatGetDegreeYaw : function to get the yaw value in degree from quaternion.
int SO3MathsQuatToEulerZYX(mmachine m)
SO3MathsQuatToEulerZYX : Scol function to transform quaternion vector in euler angles (ZYX) !...
int SO3MathsQuatToEulerDegreeYXZ(mmachine m)
SO3MathsQuatToEulerDegreeYXZ : Scol function to transform quaternion vector in euler angles (degree) ...
int SO3MathsQuatSubstract(mmachine m)
SO3MathsQuatSubstract : Scol function to substract two quaternions.
int SO3MathsDegreeToRadian(mmachine m)
SO3MathsDegreeToRadian : function to convert a value from degrees to radians.
int SO3MathsQuatInterpolate(mmachine m)
SO3MathsQuatInterpolate : function to interpolate two quaternions.
int SO3MathsQuatGetZaxis(mmachine m)
SO3MathsQuatGetZaxis : function to get Z-axis from quaternion.
int SO3MathsQuatFromAngleAxis(mmachine m)
SO3MathsQuatFromAngleAxis : function to get Quaternion from angle axis.
int SO3MathsEulerXYZToQuat(mmachine m)
SO3MathsEulerXYZToQuat : Scol function to transform euler angles (XYZ) (radians) in a quaternion !...
int SO3MathsEulerZXYToQuat(mmachine m)
SO3MathsEulerZXYToQuat : Scol function to transform euler angles (ZXY) (radians) in a quaternion !...
int SO3MathsEulerPYRToQuat(mmachine m)
SO3MathsEulerPYRToQuat : Scol function to transform quaternion vector in euler angles (degree) (YZX)
int SO3MathsQuatToEulerXYZ(mmachine m)
Main include.
int SO3MathsQuatGetRoll(mmachine m)
SO3MathsQuatGetRoll : function to get the roll value from quaternion.
int SO3MathsQuatToEulerPYR(mmachine m)
SO3MathsQuatToEulerPYR : Scol function to transform quaternion vector in euler angles (Pitch Yaw Roll...
int SO3MathsQuatGetYaxis(mmachine m)
SO3MathsQuatGetYaxis : function to get Y-axis from quaternion.
int SO3MathsQuatToEulerDegreeYZX(mmachine m)
SO3MathsQuatToEulerDegreeYZX : Scol function to transform quaternion vector in euler angles (degree) ...
int SO3MathsEulerYZXToQuat(mmachine m)
SO3MathsEulerYZXToQuat : Scol function to transform euler angles (YZX) (radians) in a quaternion !...
int SO3MathsGetRotationToAxis(mmachine m)
SO3MathsGetRotationToAxis : Scol function to get the shortest arc quaternion to rotate the source vec...
int SO3MathsQuatToEulerDegreeXZY(mmachine m)
SO3MathsQuatToEulerDegreeXZY : Scol function to transform quaternion vector in euler angles (degree) ...
int SO3MathsQuatFromDegreeAngle(mmachine m)
SO3MathsQuatFromDegreeAngle : function to get Quaternion from X Y Z angle in degree.
int SO3MathsQuatToEulerDegreePYR(mmachine m)
SO3MathsQuatToEulerDegreePYR : Scol function to transform quaternion vector in euler angles (degree) ...
int SO3MathsQuatGetXaxis(mmachine m)
SO3MathsQuatGetXaxis : function to get X-axis from quaternion.
int SO3MathsQuatGetYaw(mmachine m)
SO3MathsQuatGetYaw : function to get the yaw value from quaternion.
int SO3MathsEulerYXZToQuat(mmachine m)
SO3MathsEulerYXZToQuat : Scol function to transform euler angles (YXZ) (radians) in a quaternion !...
int SO3MathsQuatGetDirection(mmachine m)
SO3MathsQuatGetDirection : function to get the direction from quaternion.
int SO3MathsQuatToEulerDegreeZYX(mmachine m)
SO3MathsQuatToEulerDegreeZYX : Scol function to transform quaternion vector in euler angles (degree) ...
int SO3MathsQuatToEulerXZY(mmachine m)
SO3MathsQuatToEulerXZY : Scol function to transform quaternion vector in euler angles (XZY) !...
int SO3MathsGetRotationTo(mmachine m)
SO3MathsGetRotationTo : Scol function to get the shortest arc quaternion to rotate the source vector ...
int SO3MathsQuatAdd(mmachine m)
SO3MathsQuatAdd : Scol function to add two quaternions.
int SO3MathsVectorDotProduct(mmachine m)
SO3MathsVectorDotProduct : Calculates the dot (scalar) product of this vector with another.
int SO3MathsQuatToEulerZXY(mmachine m)
SO3MathsQuatToEulerZXY : Scol function to transform quaternion vector in euler angles (ZXY) !...
int SO3MathsQuatToAxes(mmachine m)
SO3MathsQuatToAxes : function to project quaternion to axis values.
int SO3MathsEulerZYXToQuat(mmachine m)
SO3MathsEulerZYXToQuat : Scol function to transform euler angles (ZYX) (radians) in a quaternion !...