89 {
OVR_ASSERT(abs(x) != abs(y) && abs(y) != abs(z) && abs(z) != abs(x));}
178 static const float Pi;
182 static const float E;
202 static const double Pi;
206 static const double E;
233 if (val > T(1))
return T(0);
235 else return acos(val);
243 else return asin(val);
247 inline int isnan(
double x) {
return _isnan(x); };
270 :
x((T)src.
x),
y((T)src.
y) { }
305 (a.y < b.y) ? a.y : b.y); }
307 (a.y > b.y) ? a.y : b.y); }
312 return (fabs(b.x-
x) < tolerance) && (fabs(b.y-
y) < tolerance);
333 T result =
Acos((this->
Dot(b))/sqrt(div));
377 return b * (
Dot(b) / l2 );
403 :
x((T)src.
x),
y((T)src.
y),
z((T)src.
z) { }
433 x *= rcp;
y *= rcp;
z *= rcp;
439 (a.
y < b.
y) ? a.
y : b.
y,
440 (a.
z < b.
z) ? a.
z : b.
z);
445 (a.
y > b.
y) ? a.
y : b.
y,
446 (a.
z > b.
z) ? a.
z : b.
z);
452 return (fabs(b.
x-
x) < tolerance) &&
453 (fabs(b.
y-
y) < tolerance) &&
454 (fabs(b.
z-
z) < tolerance);
501 T result =
Acos((this->
Dot(b))/sqrt(div));
546 return b * (
Dot(b) / l2 );
592 :
w((T)src.
w),
h((T)src.
h) { }
625 (a.h < b.h) ? a.h : b.h); }
627 (a.h > b.h) ? a.h : b.h); }
655 Rect(T x1, T y1, T w1, T h1) :
x(x1),
y(y1),
w(w1),
h(h1) { }
676 {
return (
x == vp.
x) && (
y == vp.
y) && (
w == vp.
w) && (
h == vp.
h); }
701 Quat(T x_, T y_, T z_, T w_) :
x(x_),
y(y_),
z(z_),
w(w_) { }
703 :
x((T)src.
x),
y((T)src.
y),
z((T)src.
z),
w((T)src.
w) { }
726 x = 0;
y = 0;
z = 0;
w = 1;
731 T sinHalfAngle = sin(angle * T(0.5));
733 w = cos(angle * T(0.5));
734 x = unitAxis.
x * sinHalfAngle;
735 y = unitAxis.
y * sinHalfAngle;
736 z = unitAxis.
z * sinHalfAngle;
742 T sinHalfAngle = s * d *sin(angle * T(0.5));
744 v[0] = v[1] = v[2] = T(0);
747 w = cos(angle * T(0.5));
758 *angle = 2 *
Acos(
w);
762 *axis = *axis * (-1);
775 T trace = m.
M[0][0] + m.
M[1][1] + m.
M[2][2];
782 T s = sqrt(trace + T(1)) * T(2);
784 x = (m.
M[2][1] - m.
M[1][2]) / s;
785 y = (m.
M[0][2] - m.
M[2][0]) / s;
786 z = (m.
M[1][0] - m.
M[0][1]) / s;
788 else if ((m.
M[0][0] > m.
M[1][1])&&(m.
M[0][0] > m.
M[2][2]))
790 T s = sqrt(T(1) + m.
M[0][0] - m.
M[1][1] - m.
M[2][2]) * T(2);
791 w = (m.
M[2][1] - m.
M[1][2]) / s;
793 y = (m.
M[0][1] + m.
M[1][0]) / s;
794 z = (m.
M[2][0] + m.
M[0][2]) / s;
796 else if (m.
M[1][1] > m.
M[2][2])
798 T s = sqrt(T(1) + m.
M[1][1] - m.
M[0][0] - m.
M[2][2]) * T(2);
799 w = (m.
M[0][2] - m.
M[2][0]) / s;
800 x = (m.
M[0][1] + m.
M[1][0]) / s;
802 z = (m.
M[1][2] + m.
M[2][1]) / s;
806 T s = sqrt(T(1) + m.
M[2][2] - m.
M[0][0] - m.
M[1][1]) * T(2);
807 w = (m.
M[1][0] - m.
M[0][1]) / s;
808 x = (m.
M[0][2] + m.
M[2][0]) / s;
809 y = (m.
M[1][2] + m.
M[2][1]) / s;
817 T trace = m.
M[0][0] + m.
M[1][1] + m.
M[2][2];
824 T s = sqrt(trace + T(1)) * T(2);
826 x = (m.
M[2][1] - m.
M[1][2]) / s;
827 y = (m.
M[0][2] - m.
M[2][0]) / s;
828 z = (m.
M[1][0] - m.
M[0][1]) / s;
830 else if ((m.
M[0][0] > m.
M[1][1])&&(m.
M[0][0] > m.
M[2][2]))
832 T s = sqrt(T(1) + m.
M[0][0] - m.
M[1][1] - m.
M[2][2]) * T(2);
833 w = (m.
M[2][1] - m.
M[1][2]) / s;
835 y = (m.
M[0][1] + m.
M[1][0]) / s;
836 z = (m.
M[2][0] + m.
M[0][2]) / s;
838 else if (m.
M[1][1] > m.
M[2][2])
840 T s = sqrt(T(1) + m.
M[1][1] - m.
M[0][0] - m.
M[2][2]) * T(2);
841 w = (m.
M[0][2] - m.
M[2][0]) / s;
842 x = (m.
M[0][1] + m.
M[1][0]) / s;
844 z = (m.
M[1][2] + m.
M[2][1]) / s;
848 T s = sqrt(T(1) + m.
M[2][2] - m.
M[0][0] - m.
M[1][1]) * T(2);
849 w = (m.
M[1][0] - m.
M[0][1]) / s;
850 x = (m.
M[0][2] + m.
M[2][0]) / s;
851 y = (m.
M[1][2] + m.
M[2][1]) / s;
882 T d1 = (*
this - q).
Length();
883 T d2 = (*
this + q).
Length();
884 return (d1 < d2) ? d1 : d2;
891 return (d1 < d2) ? d1 : d2;
896 return x * q.
x +
y * q.
y +
z * q.
z +
w * q.
w;
928 w * b.
y -
x * b.
z +
y * b.
w +
z * b.
x,
929 w * b.
z +
x * b.
y -
y * b.
x +
z * b.
w,
930 w * b.
w -
x * b.
x -
y * b.
y -
z * b.
z); }
939 return Quat(v, a * p);
945 T sign = (
Dot(other) >= 0) ? 1 : -1;
946 return (*
this * sign * a + other * (1-a)).
Normalized();
976 template <Axis A1, Axis A2, Axis A3, RotateDirection D, HandedSystem S>
981 T Q[3] = {
x,
y,
z };
990 if (((A1 + 1) % 3 == A2) && ((A2 + 1) % 3 == A3))
993 T s2 = psign * T(2) * (psign*w*Q[A2] + Q[A1]*Q[A3]);
999 *c = S*D*atan2(T(2)*(psign*Q[A1]*Q[A2] + w*Q[A3]),
1000 ww + Q22 - Q11 - Q33 );
1006 *c = S*D*atan2(T(2)*(psign*Q[A1]*Q[A2] + w*Q[A3]),
1007 ww + Q22 - Q11 - Q33);
1011 *a = -S*D*atan2(T(-2)*(w*Q[A1] - psign*Q[A2]*Q[A3]),
1012 ww + Q33 - Q11 - Q22);
1014 *c = S*D*atan2(T(2)*(w*Q[A3] - psign*Q[A1]*Q[A2]),
1015 ww + Q11 - Q22 - Q33);
1020 template <Axis A1, Axis A2, Axis A3, RotateDirection D>
1022 { GetEulerAngles<A1, A2, A3, D, Handed_R>(a, b, c); }
1024 template <Axis A1, Axis A2, Axis A3>
1026 { GetEulerAngles<A1, A2, A3, Rotate_CCW, Handed_R>(a, b, c); }
1037 template <Axis A1, Axis A2, RotateDirection D, HandedSystem S>
1045 int m = 3 - A1 - A2;
1048 T Q11 = Q[A1]*Q[A1];
1049 T Q22 = Q[A2]*Q[A2];
1053 if ((A1 + 1) % 3 == A2)
1058 T c2 = ww + Q11 - Q22 - Qmm;
1063 *c = S*D*atan2( T(2)*(w*Q[A1] - psign*Q[A2]*Q[m]),
1064 ww + Q22 - Q11 - Qmm);
1070 *c = S*D*atan2( T(2)*(w*Q[A1] - psign*Q[A2]*Q[m]),
1071 ww + Q22 - Q11 - Qmm);
1075 *a = S*D*atan2( psign*w*Q[m] + Q[A1]*Q[A2],
1076 w*Q[A2] -psign*Q[A1]*Q[m]);
1078 *c = S*D*atan2( -psign*w*Q[m] + Q[A1]*Q[A2],
1079 w*Q[A2] + psign*Q[A1]*Q[m]);
1144 result.
Pose = (*this) * poseState.
Pose;
1211 T m21, T m22, T m23, T m24,
1212 T m31, T m32, T m33, T m34,
1213 T m41, T m42, T m43, T m44)
1215 M[0][0] = m11;
M[0][1] = m12;
M[0][2] = m13;
M[0][3] = m14;
1216 M[1][0] = m21;
M[1][1] = m22;
M[1][2] = m23;
M[1][3] = m24;
1217 M[2][0] = m31;
M[2][1] = m32;
M[2][2] = m33;
M[2][3] = m34;
1218 M[3][0] = m41;
M[3][1] = m42;
M[3][2] = m43;
M[3][3] = m44;
1222 T m21, T m22, T m23,
1223 T m31, T m32, T m33)
1225 M[0][0] = m11;
M[0][1] = m12;
M[0][2] = m13;
M[0][3] = 0;
1226 M[1][0] = m21;
M[1][1] = m22;
M[1][2] = m23;
M[1][3] = 0;
1227 M[2][0] = m31;
M[2][1] = m32;
M[2][2] = m33;
M[2][3] = 0;
1228 M[3][0] = 0;
M[3][1] = 0;
M[3][2] = 0;
M[3][3] = 1;
1238 M[0][0] = ww + xx - yy - zz;
M[0][1] = 2 * (q.
x*q.
y - q.
w*q.
z);
M[0][2] = 2 * (q.
x*q.
z + q.
w*q.
y);
M[0][3] = 0;
1239 M[1][0] = 2 * (q.
x*q.
y + q.
w*q.
z);
M[1][1] = ww - xx + yy - zz;
M[1][2] = 2 * (q.
y*q.
z - q.
w*q.
x);
M[1][3] = 0;
1240 M[2][0] = 2 * (q.
x*q.
z - q.
w*q.
y);
M[2][1] = 2 * (q.
y*q.
z + q.
w*q.
x);
M[2][2] = ww - xx - yy + zz;
M[2][3] = 0;
1241 M[3][0] = 0;
M[3][1] = 0;
M[3][2] = 0;
M[3][3] = 1;
1254 for (
int i = 0; i < 4; i++)
1255 for (
int j = 0; j < 4; j++)
1256 M[i][j] = (T)src.M[i][j];
1277 for (
int r=0;
r<4;
r++)
1278 for (
int c=0; c<4; c++)
1285 for (
int r=0;
r<4;
r++)
1286 for (
int c=0; c<4; c++)
1288 result.
M[
r][c] = (T)atof(src);
1289 while (src && *src !=
' ')
1291 while (src && *src ==
' ')
1301 M[0][0] =
M[1][1] =
M[2][2] =
M[3][3] = 1;
1302 M[0][1] =
M[1][0] =
M[2][3] =
M[3][1] = 0;
1303 M[0][2] =
M[1][2] =
M[2][0] =
M[3][2] = 0;
1304 M[0][3] =
M[1][3] =
M[2][1] =
M[3][0] = 0;
1309 bool isEqual =
true;
1310 for (
int i = 0; i < 4; i++)
1311 for (
int j = 0; j < 4; j++)
1312 isEqual &= (
M[i][j] == b.
M[i][j]);
1326 for (
int i = 0; i < 4; i++)
1327 for (
int j = 0; j < 4; j++)
1328 M[i][j] += b.
M[i][j];
1341 for (
int i = 0; i < 4; i++)
1342 for (
int j = 0; j < 4; j++)
1343 M[i][j] -= b.
M[i][j];
1353 d->
M[i][0] = a.
M[i][0] * b.
M[0][0] + a.
M[i][1] * b.
M[1][0] + a.
M[i][2] * b.
M[2][0] + a.
M[i][3] * b.
M[3][0];
1354 d->
M[i][1] = a.
M[i][0] * b.
M[0][1] + a.
M[i][1] * b.
M[1][1] + a.
M[i][2] * b.
M[2][1] + a.
M[i][3] * b.
M[3][1];
1355 d->
M[i][2] = a.
M[i][0] * b.
M[0][2] + a.
M[i][1] * b.
M[1][2] + a.
M[i][2] * b.
M[2][2] + a.
M[i][3] * b.
M[3][2];
1356 d->
M[i][3] = a.
M[i][0] * b.
M[0][3] + a.
M[i][1] * b.
M[1][3] + a.
M[i][2] * b.
M[2][3] + a.
M[i][3] * b.
M[3][3];
1383 for (
int i = 0; i < 4; i++)
1384 for (
int j = 0; j < 4; j++)
1399 for (
int i = 0; i < 4; i++)
1400 for (
int j = 0; j < 4; j++)
1408 M[1][0] * v.
x +
M[1][1] * v.
y +
M[1][2] * v.
z +
M[1][3],
1409 M[2][0] * v.
x +
M[2][1] * v.
y +
M[2][2] * v.
z +
M[2][3]);
1414 return Matrix4(
M[0][0],
M[1][0],
M[2][0],
M[3][0],
1415 M[0][1],
M[1][1],
M[2][1],
M[3][1],
1416 M[0][2],
M[1][2],
M[2][2],
M[3][2],
1417 M[0][3],
M[1][3],
M[2][3],
M[3][3]);
1428 return M[rows[0]][cols[0]] * (
M[rows[1]][cols[1]] *
M[rows[2]][cols[2]] -
M[rows[1]][cols[2]] *
M[rows[2]][cols[1]])
1429 -
M[rows[0]][cols[1]] * (
M[rows[1]][cols[0]] *
M[rows[2]][cols[2]] -
M[rows[1]][cols[2]] *
M[rows[2]][cols[0]])
1430 +
M[rows[0]][cols[2]] * (
M[rows[1]][cols[0]] *
M[rows[2]][cols[1]] -
M[rows[1]][cols[1]] *
M[rows[2]][cols[0]]);
1435 const UPInt indices[4][3] = {{1,2,3},{0,2,3},{0,1,3},{0,1,2}};
1436 return ((I+J)&1) ? -
SubDet(indices[I],indices[J]) :
SubDet(indices[I],indices[J]);
1470 rinv.
M[3][0] = rinv.
M[3][1] = rinv.
M[3][2] = 0.0f;
1490 template <Axis A1, Axis A2, Axis A3, RotateDirection D, HandedSystem S>
1496 if (((A1 + 1) % 3 == A2) && ((A2 + 1) % 3 == A3))
1499 T pm = psign*
M[A1][A3];
1504 *c = S*D*atan2( psign*M[A2][A1], M[A2][A2] );
1510 *c = S*D*atan2( psign*M[A2][A1], M[A2][A2] );
1514 *a = S*D*atan2( -psign*M[A2][A3], M[A3][A3] );
1516 *c = S*D*atan2( -psign*M[A1][A2], M[A1][A1] );
1528 template <Axis A1, Axis A2, RotateDirection D, HandedSystem S>
1534 int m = 3 - A1 - A2;
1537 if ((A1 + 1) % 3 == A2)
1545 *c = S*D*atan2( -psign*
M[A2][m],
M[A2][A2]);
1551 *c = S*D*atan2( -psign*
M[A2][m],
M[A2][A2]);
1555 *a = S*D*atan2(
M[A2][A1],-psign*
M[m][A1]);
1557 *c = S*D*atan2(
M[A1][A2],psign*
M[A1][m]);
1571 inv[0] = inv[abs(to.
XAxis)] = 0;
1572 inv[abs(to.
YAxis)] = 1;
1573 inv[abs(to.
ZAxis)] = 2;
1580 m.
M[inv[abs(from.
XAxis)]][0] = T(from.
XAxis/toArray[inv[abs(from.
XAxis)]]);
1581 m.
M[inv[abs(from.
YAxis)]][1] = T(from.
YAxis/toArray[inv[abs(from.
YAxis)]]);
1582 m.
M[inv[abs(from.
ZAxis)]][2] = T(from.
ZAxis/toArray[inv[abs(from.
ZAxis)]]);
1653 T d = fabs(
M[0][0] - m2.
M[0][0]) + fabs(
M[0][1] - m2.
M[0][1]);
1654 d += fabs(
M[0][2] - m2.
M[0][2]) + fabs(
M[0][3] - m2.
M[0][3]);
1655 d += fabs(
M[1][0] - m2.
M[1][0]) + fabs(
M[1][1] - m2.
M[1][1]);
1656 d += fabs(
M[1][2] - m2.
M[1][2]) + fabs(
M[1][3] - m2.
M[1][3]);
1657 d += fabs(
M[2][0] - m2.
M[2][0]) + fabs(
M[2][1] - m2.
M[2][1]);
1658 d += fabs(
M[2][2] - m2.
M[2][2]) + fabs(
M[2][3] - m2.
M[2][3]);
1659 d += fabs(
M[3][0] - m2.
M[3][0]) + fabs(
M[3][1] - m2.
M[3][1]);
1660 d += fabs(
M[3][2] - m2.
M[3][2]) + fabs(
M[3][3] - m2.
M[3][3]);
1668 T sina = s * d *sin(angle);
1669 T cosa = cos(angle);
1682 return Matrix4(cosa, -sina, 0,
1698 T sina = sin(angle);
1699 T cosa = cos(angle);
1714 T sina = sin(angle);
1715 T cosa = cos(angle);
1730 T sina = sin(angle);
1731 T cosa = cos(angle);
1732 return Matrix4(cosa, -sina, 0,
1748 y.
x, y.
y, y.
z, -(y.
Dot(eye)),
1749 z.
x, z.
y, z.
z, -(z.
Dot(eye)),
1764 y.
x, y.
y, y.
z, -(y.
Dot(eye)),
1765 z.
x, z.
y, z.
z, -(z.
Dot(eye)),
1782 T tanHalfFov = tan(yfov * 0.5f);
1784 m.
M[0][0] = 1 / (aspect * tanHalfFov);
1785 m.
M[1][1] = 1 / tanHalfFov;
1786 m.
M[2][2] = zfar / (zfar - znear);
1788 m.
M[2][3] = (zfar * znear) / (znear - zfar);
1806 T tanHalfFov = tan(yfov * 0.5f);
1808 m.
M[0][0] = 1.0 / (aspect * tanHalfFov);
1809 m.
M[1][1] = 1.0 / tanHalfFov;
1810 m.
M[2][2] = zfar / (znear - zfar);
1813 m.
M[2][3] = (zfar * znear) / (znear - zfar);
1857 template<
typename T>
1880 T m21, T m22, T m23,
1881 T m31, T m32, T m33)
1883 M[0][0] = m11;
M[0][1] = m12;
M[0][2] = m13;
1884 M[1][0] = m21;
M[1][1] = m22;
M[1][2] = m23;
1885 M[2][0] = m31;
M[2][1] = m32;
M[2][2] = m33;
1904 const T tx = q.
x+q.
x, ty = q.
y+q.
y, tz = q.
z+q.
z;
1905 const T twx = q.
w*tx, twy = q.
w*ty, twz = q.
w*tz;
1906 const T txx = q.
x*tx, txy = q.
x*ty, txz = q.
x*tz;
1907 const T tyy = q.
y*ty, tyz = q.
y*tz, tzz = q.
z*tz;
1908 M[0][0] = T(1) - (tyy + tzz);
M[0][1] = txy - twz;
M[0][2] = txz + twy;
1909 M[1][0] = txy + twz;
M[1][1] = T(1) - (txx + tzz);
M[1][2] = tyz - twx;
1910 M[2][0] = txz - twy;
M[2][1] = tyz + twx;
M[2][2] = T(1) - (txx + tyy);
1915 M[0][0] =
M[1][1] =
M[2][2] = s;
1916 M[0][1] =
M[0][2] =
M[1][0] =
M[1][2] =
M[2][0] =
M[2][1] = 0;
1929 for (
int i = 0; i < 3; i++)
1930 for (
int j = 0; j < 3; j++)
1931 M[i][j] = (T)src.M[i][j];
1952 for (
int r=0;
r<3;
r++)
1953 for (
int c=0; c<3; c++)
1960 for (
int r=0;
r<3;
r++)
1961 for (
int c=0; c<3; c++)
1963 result.
M[
r][c] = (T)atof(src);
1964 while (src && *src !=
' ')
1966 while (src && *src ==
' ')
1976 M[0][0] =
M[1][1] =
M[2][2] = 1;
1977 M[0][1] =
M[1][0] =
M[2][0] = 0;
1978 M[0][2] =
M[1][2] =
M[2][1] = 0;
1983 bool isEqual =
true;
1984 for (
int i = 0; i < 3; i++)
1985 for (
int j = 0; j < 3; j++)
1986 isEqual &= (
M[i][j] == b.
M[i][j]);
2000 for (
int i = 0; i < 3; i++)
2001 for (
int j = 0; j < 3; j++)
2002 M[i][j] += b.
M[i][j];
2008 for (
int i = 0; i < 3; i++)
2009 for (
int j = 0; j < 3; j++)
2010 M[i][j] = b.
M[i][j];
2016 for (
int i = 0; i < 3; i++)
2017 for (
int j = 0; j < 3; j++)
2039 for (
int i = 0; i < 3; i++)
2040 for (
int j = 0; j < 3; j++)
2041 M[i][j] -= b.
M[i][j];
2051 d->
M[i][0] = a.
M[i][0] * b.
M[0][0] + a.
M[i][1] * b.
M[1][0] + a.
M[i][2] * b.
M[2][0];
2052 d->
M[i][1] = a.
M[i][0] * b.
M[0][1] + a.
M[i][1] * b.
M[1][1] + a.
M[i][2] * b.
M[2][1];
2053 d->
M[i][2] = a.
M[i][0] * b.
M[0][2] + a.
M[i][1] * b.
M[1][2] + a.
M[i][2] * b.
M[2][2];
2080 for (
int i = 0; i < 3; i++)
2081 for (
int j = 0; j < 3; j++)
2089 result.
x =
M[0][0]*b.
x +
M[0][1]*b.
y +
M[0][2]*b.
z;
2090 result.
y =
M[1][0]*b.
x +
M[1][1]*b.
y +
M[1][2]*b.
z;
2091 result.
z =
M[2][0]*b.
x +
M[2][1]*b.
y +
M[2][2]*b.
z;
2105 for (
int i = 0; i < 3; i++)
2106 for (
int j = 0; j < 3; j++)
2114 M[1][0] * v.
x +
M[1][1] * v.
y +
M[1][2] * v.
z,
2115 M[2][0] * v.
x +
M[2][1] * v.
y +
M[2][2] * v.
z);
2121 M[0][1],
M[1][1],
M[2][1],
2122 M[0][2],
M[1][2],
M[2][2]);
2133 return M[rows[0]][cols[0]] * (
M[rows[1]][cols[1]] *
M[rows[2]][cols[2]] -
M[rows[1]][cols[2]] *
M[rows[2]][cols[1]])
2134 -
M[rows[0]][cols[1]] * (
M[rows[1]][cols[0]] *
M[rows[2]][cols[2]] -
M[rows[1]][cols[2]] *
M[rows[2]][cols[0]])
2135 +
M[rows[0]][cols[2]] * (
M[rows[1]][cols[0]] *
M[rows[2]][cols[1]] -
M[rows[1]][cols[1]] *
M[rows[2]][cols[0]]);
2141 M[0][0] += a.
x*b.
x;
M[0][1] += a.
x*b.
y;
M[0][2] += a.
x*b.
z;
2142 M[1][0] += a.
y*b.
x;
M[1][1] += a.
y*b.
y;
M[1][2] += a.
y*b.
z;
2143 M[2][0] += a.
z*b.
x;
M[2][1] += a.
z*b.
y;
M[2][2] += a.
z*b.
z;
2149 M[0][0] -= a.
x*b.
x;
M[0][1] -= a.
x*b.
y;
M[0][2] -= a.
x*b.
z;
2150 M[1][0] -= a.
y*b.
x;
M[1][1] -= a.
y*b.
y;
M[1][2] -= a.
y*b.
z;
2151 M[2][0] -= a.
z*b.
x;
M[2][1] -= a.
z*b.
y;
M[2][2] -= a.
z*b.
z;
2169 d = m.
M[0][0] * (m.
M[1][1]*m.
M[2][2] - m.
M[1][2] * m.
M[2][1]);
2170 d -= m.
M[0][1] * (m.
M[1][0]*m.
M[2][2] - m.
M[1][2] * m.
M[2][0]);
2171 d += m.
M[0][2] * (m.
M[1][0]*m.
M[2][1] - m.
M[1][1] * m.
M[2][0]);
2185 a.
M[0][0] = s * (m.
M[1][1] * m.
M[2][2] - m.
M[1][2] * m.
M[2][1]);
2186 a.
M[1][0] = s * (m.
M[1][2] * m.
M[2][0] - m.
M[1][0] * m.
M[2][2]);
2187 a.
M[2][0] = s * (m.
M[1][0] * m.
M[2][1] - m.
M[1][1] * m.
M[2][0]);
2189 a.
M[0][1] = s * (m.
M[0][2] * m.
M[2][1] - m.
M[0][1] * m.
M[2][2]);
2190 a.
M[1][1] = s * (m.
M[0][0] * m.
M[2][2] - m.
M[0][2] * m.
M[2][0]);
2191 a.
M[2][1] = s * (m.
M[0][1] * m.
M[2][0] - m.
M[0][0] * m.
M[2][1]);
2193 a.
M[0][2] = s * (m.
M[0][1] * m.
M[1][2] - m.
M[0][2] * m.
M[1][1]);
2194 a.
M[1][2] = s * (m.
M[0][2] * m.
M[1][0] - m.
M[0][0] * m.
M[1][2]);
2195 a.
M[2][2] = s * (m.
M[0][0] * m.
M[1][1] - m.
M[0][1] * m.
M[1][0]);
2207 template<
typename T>
2222 v[0] =
v[3] =
v[5] = s;
2223 v[1] =
v[2] =
v[4] = 0;
2226 inline explicit SymMat3(T a00, T a01, T a02, T a11, T a12, T a22)
2228 v[0] = a00;
v[1] = a01;
v[2] = a02;
2229 v[3] = a11;
v[4] = a12;
2233 static inline int Index(
unsigned int i,
unsigned int j)
2235 return (i <= j) ? (3*i - i*(i+1)/2 + j) : (3*j - j*(j+1)/2 + i);
2242 template<
typename U>
2245 return SymMat3<U>(
static_cast<U
>(
v[0]), static_cast<U>(
v[1]),
static_cast<U
>(
v[2]),
2246 static_cast<U>(
v[3]),
static_cast<U
>(
v[4]), static_cast<U>(
v[5]));
2302 d->
v[0] = a.
v[0] * b.
v[0];
2303 d->
v[1] = a.
v[0] * b.
v[1] + a.
v[1] * b.
v[3];
2304 d->
v[2] = a.
v[0] * b.
v[2] + a.
v[1] * b.
v[4];
2306 d->
v[3] = a.
v[3] * b.
v[3];
2307 d->
v[4] = a.
v[3] * b.
v[4] + a.
v[4] * b.
v[5];
2309 d->
v[5] = a.
v[5] * b.
v[5];
2319 d = m(0,0) * (m(1,1)*m(2,2) - m(1,2) * m(2,1));
2320 d -= m(0,1) * (m(1,0)*m(2,2) - m(1,2) * m(2,0));
2321 d += m(0,2) * (m(1,0)*m(2,1) - m(1,1) * m(2,0));
2335 a(0,0) = s * (m(1,1) * m(2,2) - m(1,2) * m(2,1));
2337 a(0,1) = s * (m(0,2) * m(2,1) - m(0,1) * m(2,2));
2338 a(1,1) = s * (m(0,0) * m(2,2) - m(0,2) * m(2,0));
2340 a(0,2) = s * (m(0,1) * m(1,2) - m(0,2) * m(1,1));
2341 a(1,2) = s * (m(0,2) * m(1,0) - m(0,0) * m(1,2));
2342 a(2,2) = s * (m(0,0) * m(1,1) - m(0,1) * m(1,0));
2352 v[0] = a.
x*a.
x;
v[1] = a.
x*a.
y;
v[2] = a.
x*a.
z;
2353 v[3] = a.
y*a.
y;
v[4] = a.
y*a.
z;
2360 v[0] += a.
x*a.
x;
v[1] += a.
x*a.
y;
v[2] += a.
x*a.
z;
2361 v[3] += a.
y*a.
y;
v[4] += a.
y*a.
z;
2368 v[0] -= a.
x*a.
x;
v[1] -= a.
x*a.
y;
v[2] -= a.
x*a.
z;
2369 v[3] -= a.
y*a.
y;
v[4] -= a.
y*a.
z;
2377 template<
typename T>
2380 #define AJB_ARBC(r,c) (a(r,0)*b(0,c)+a(r,1)*b(1,c)+a(r,2)*b(2,c))
2388 template<
typename T>
2391 #define AJB_ARBC(r,c) (a(r,0)*b(0,c)+a(r,1)*b(1,c)+a(r,2)*b(2,c))
2422 int Sign()
const {
if (
a == 0)
return 0;
else return (
a > 0) ? 1 : -1; }
2502 return (
N.Dot(p)) +
D;
2518 return (this->
D == rhs.
D && this->N == rhs.
N);
T Distance(const Quat &q) const
Angle & operator-=(const Angle &b)
void Rank1Sub(const Vector3< T > &a, const Vector3< T > &b)
Size & operator-=(const Size &b)
Matrix4 operator/(T s) const
static const double PiOver2
Matrix3 & operator*=(const Matrix3 &b)
CompatibleTypes< Size< T > >::Type CompatibleType
Vector3 operator-() const
Vector2 & operator/=(T s)
Matrix3(const typename CompatibleTypes< Matrix3< T > >::Type &s)
static const double PiOver4
Vector3 & operator+=(const Vector3 &b)
Quat PowNormalized(T p) const
Vector3< SInt32 > Vector3i
struct ovrQuatd_ ovrQuatd
bool operator==(const Matrix3 &b) const
Matrix3 operator*(const Matrix3 &b) const
Matrix3(const Quat< T > &q)
Vector3 Cross(const Vector3 &b) const
Matrix4 & operator+=(const Matrix4 &b)
Quat(Axis A, T angle, RotateDirection d=Rotate_CCW, HandedSystem s=Handed_R)
void Set(const T &x, AngularUnits u=Radians)
bool operator!=(const Size &b) const
T Dot(const Vector2 &b) const
T Distance(Vector3 const &b) const
Plane(const Vector3< T > &n, T d)
void InvertHomogeneousTransform()
CompatibleTypes< Vector3< T > >::Type CompatibleType
Quat operator*(T s) const
__BEGIN_NAMESPACE_STD void * memcpy(void *__restrict __dest, const void *__restrict __src, size_t __n) __THROW __nonnull((1
Rect(const CompatibleType &s)
static const float SingularityRadius
Angle operator-(const Angle &b) const
void SetPos(const Vector2< T > &pos)
Size(const CompatibleType &s)
Vector3< T > Imag() const
Matrix3< float > Matrix3f
struct ovrSizef_ ovrSizef
bool operator!=(const Angle &b) const
Size(const Size< typename Math< T >::OtherFloatType > &src)
Vector2 Lerp(const Vector2 &b, T f) const
Matrix3(const Transform< T > &p)
Quat operator/(T s) const
T Angle(const Vector2 &b) const
this_type & operator+=(const this_type &b)
static Matrix3 & Multiply(Matrix3 *d, const Matrix3 &a, const Matrix3 &b)
static const double SingularityRadius
T Cofactor(UPInt I, UPInt J) const
Size< T > GetSize() const
Matrix4 InvertedHomogeneousTransform() const
static Matrix4 Scaling(T s)
void operator=(const Matrix3 &b)
Quat & operator+=(const Quat &b)
Vector3 ProjectToPlane(const Vector3 &normal) const
Matrix4 Transposed() const
Matrix4(T m11, T m12, T m13, T m14, T m21, T m22, T m23, T m24, T m31, T m32, T m33, T m34, T m41, T m42, T m43, T m44)
Angle(T a_, AngularUnits u=Radians)
void GetEulerAngles(T *a, T *b, T *c) const
Matrix4(T m11, T m12, T m13, T m21, T m22, T m23, T m31, T m32, T m33)
Matrix3 & operator/=(T s)
void GetAxisAngle(Vector3< T > *axis, T *angle) const
Quat(const Matrix3< T > &m)
Vector2< double > Vector2d
T Distance(const Matrix4 &m2) const
Rect(const Size< T > &sz)
static Matrix4 & Multiply(Matrix4 *d, const Matrix4 &a, const Matrix4 &b)
static const Matrix4 & Identity()
Vector2 operator-() const
static const double DegreeToRadFactor
static Matrix4 Scaling(const Vector3< T > &v)
Quat(T x_, T y_, T z_, T w_)
static Matrix4 RotationAxis(Axis A, T angle, RotateDirection d, HandedSystem s)
static Size Min(const Size &a, const Size &b)
static Matrix4 FromString(const char *src)
Vector3< T > Rotate(const Vector3< T > &v) const
Matrix3 & operator+=(const Matrix3 &b)
Vector4f(const Vector3f &v)
Vector2 Normalized() const
Vector2< T > GetPos() const
Transform< double > Transformd
Matrix3 operator+(const Matrix3 &b) const
Matrix4< double > Matrix4d
Vector2(const Vector2< typename Math< T >::OtherFloatType > &src)
static Matrix3 FromString(const char *src)
Matrix4< float > Matrix4f
Matrix4 operator-(const Matrix4 &b) const
bool operator==(const Angle &b) const
Vector3 operator+(const Vector3 &b) const
bool operator==(const Vector2 &b) const
static const float PiOver2
static Matrix4 RotationX(T angle)
Vector3< T > AngularAcceleration
void Rank1(const Vector3< T > &a)
Matrix4 Adjugated() const
Matrix3 operator/(T s) const
SymMat3< float > SymMat3f
Vector2< float > Vector2f
T & operator()(int i, int j)
Vector3< T > GetTranslation() const
bool operator==(const Rect &vp) const
bool operator!=(const Rect &vp) const
T SubDet(const UPInt *rows, const UPInt *cols) const
static Matrix4 RotationY(T angle)
Quat(const typename CompatibleTypes< Quat< T > >::Type &s)
Vector3 & operator*=(T s)
T Distance(Vector2 &b) const
Transform< float > Transformf
Size & operator*=(const Size &b)
static Vector2 Min(const Vector2 &a, const Vector2 &b)
static Matrix4 AxisConversion(const WorldAxes &to, const WorldAxes &from)
Plane(T x, T y, T z, T d)
Matrix4 & operator*=(const Matrix4 &b)
T DistanceSq(Vector3 const &b) const
static Matrix4 Scaling(T x, T y, T z)
T Get(AngularUnits u=Radians) const
bool IsNormalized() const
Vector3 operator/(T s) const
CompatibleTypes< Vector2< T > >::Type CompatibleType
SymMat3< U > CastTo() const
SymMat3< double > SymMat3d
static const double RadToDegreeFactor
Size operator/(const Size &b) const
static const float PiOver4
Quat(const Quat< typename Math< T >::OtherFloatType > &src)
bool IsNormalized() const
Matrix3(const Matrix4< typename Math< T >::OtherFloatType > &src)
static const Matrix3 & Identity()
static const Matrix3 IdentityValue
const Matrix4< float > IdentityValue
T DistanceSq(const Quat &q) const
T Dot(const Quat &q) const
CompatibleTypes< Rect< T > >::Type CompatibleType
Vector3 & operator-=(const Vector3 &b)
Vector2 operator*(T s) const
void ToString(char *dest, UPInt destsize) const
Vector3< T > AngularVelocity
bool operator==(const Plane< T > &rhs) const
bool Compare(const Vector3 &b, T tolerance=Mathf::Tolerance)
Vector3 ProjectTo(const Vector3 &b) const
static const float RadToDegreeFactor
Vector3< double > Vector3d
static Vector2 Max(const Vector2 &a, const Vector2 &b)
Vector2 EntrywiseMultiply(const Vector2 &b) const
Matrix3(T m11, T m12, T m13, T m21, T m22, T m23, T m31, T m32, T m33)
T TestSide(const Vector3< T > &p) const
static SymMat3 & Multiply(SymMat3 *d, const SymMat3 &a, const SymMat3 &b)
Vector3< T > Transform(const Vector3< T > &v) const
static Matrix4 LookAtLH(const Vector3< T > &eye, const Vector3< T > &at, const Vector3< T > &up)
Matrix3 operator-(const Matrix3 &b) const
WorldAxes(AxisDirection x, AxisDirection y, AxisDirection z)
Matrix3< double > Matrix3d
void GetEulerAngles(T *a, T *b, T *c) const
Quat operator+(const Quat &b) const
static Size Max(const Size &a, const Size &b)
void GetEulerAnglesABA(T *a, T *b, T *c) const
T Angle(const Quat &q) const
static const float MaxValue
static const Matrix4 IdentityValue
static const double MinPositiveValue
Vector3 Normalized() const
T DistanceSq(Vector2 &b) const
Vector3 EntrywiseMultiply(const Vector3 &b) const
Size operator*(const Size &b) const
void Rank1Add(const Vector3< T > &a)
Angle operator+(const Angle &b) const
static Matrix4 RotationZ(T angle)
Matrix4 & operator/=(T s)
Matrix3< T > Inverse() const
static Matrix4 PerspectiveRH(T yfov, T aspect, T znear, T zfar)
static const double Tolerance
Vector2 ProjectTo(const Vector2 &b) const
struct ovrVector3d_ ovrVector3d
Vector3< T > Row(int r) const
static Matrix4 LookAtRH(const Vector3< T > &eye, const Vector3< T > &at, const Vector3< T > &up)
Matrix4 operator*(const Matrix4 &b) const
static Matrix4 Translation(T x, T y, T z=0.0f)
Matrix4(const Transform< T > &p)
struct ovrMatrix3d_ ovrMatrix3d
T operator()(int i, int j) const
static const double MaxValue
bool operator==(const Size &b) const
Vector3(T x_, T y_, T z_=0)
Vector2 operator+(const Vector2 &b) const
void Rank1Sub(const Vector3< T > &a)
bool IsNormalized() const
struct ovrPosed_ ovrPosed
Vector3< T > LinearVelocity
Quat operator-(const Quat &b) const
Vector3(const CompatibleType &s)
void GetEulerAngles(T *a, T *b, T *c) const
struct ovrPoseStated_ ovrPoseStated
Size & operator/=(const Size &b)
Vector2 & operator*=(T s)
T SubDet(const UPInt *rows, const UPInt *cols) const
Matrix4 & operator-=(const Matrix4 &b)
bool operator!=(const Vector2 &b) const
static const double TwoPi
this_type & operator*=(T s)
Matrix3 Transposed() const
SymMat3(T a00, T a01, T a02, T a11, T a12, T a22)
bool operator!=(const Vector3 &b) const
Vector2(const CompatibleType &s)
T Dot(const Vector3 &b) const
Quat Nlerp(const Quat &other, T a)
Quat & operator-=(const Quat &b)
bool operator==(const Matrix4 &b) const
Matrix4(const Matrix4< typename Math< T >::OtherFloatType > &src)
Size operator+(const Size &b) const
static Matrix4 PerspectiveLH(T yfov, T aspect, T znear, T zfar)
static Vector3 Min(const Vector3 &a, const Vector3 &b)
Vector3< T > Col(int c) const
Matrix4(const typename CompatibleTypes< Matrix4< T > >::Type &s)
Plane(const Vector3< T > &p, const Vector3< T > &n)
void Rank1Add(const Vector3< T > &a, const Vector3< T > &b)
Vector2 operator/(T s) const
UPInt OVR_CDECL OVR_sprintf(char *dest, UPInt destsize, const char *format,...)
this_type & operator-=(const this_type &b)
static Matrix4 Ortho2D(T w, T h)
Size & operator+=(const Size &b)
Matrix3 & operator-=(const Matrix3 &b)
T Distance(const Angle &b)
Vector2 & operator-=(const Vector2 &b)
this_type Inverse() const
Vector3 Lerp(const Vector3 &b, T f) const
static Vector3 Max(const Vector3 &a, const Vector3 &b)
Vector4f(float r, float g, float b, float a)
Vector3(const Vector3< typename Math< T >::OtherFloatType > &src)
T Angle(const Vector3 &b) const
Vector2< T > ToVector() const
Matrix3< T > operator*(const SymMat3< T > &a, const SymMat3< T > &b)
static const float Tolerance
bool Compare(const Vector2 &b, T tolerance=Mathf::Tolerance)
bool operator!=(const Quat &b) const
Matrix4 operator+(const Matrix4 &b) const
Rect(T x1, T y1, T w1, T h1)
void ToString(char *dest, UPInt destsize) const
static const float MinPositiveValue
Angle & operator+=(const Angle &b)
void ToEulerAngles(T *a, T *b, T *c)
Rect(const Vector2< T > &pos, const Size< T > &sz)
static Matrix4 Translation(const Vector3< T > &v)
Vector3< float > Vector3f
Vector3 operator*(T s) const
void SetTranslation(const Vector3< T > &v)
Vector2 & operator+=(const Vector2 &b)
Quat(const Matrix4< T > &m)
Matrix4(const Quat< T > &q)
bool operator==(const Quat &b) const
void ToEulerAnglesABA(T *a, T *b, T *c)
OVR_FORCE_INLINE const T Abs(const T v)
#define OVR_COMPILER_ASSERT(x)
Quat(const Vector3< T > &axis, T angle)
Vector3< T > Transform(const Vector3< T > &v) const
Vector3< T > LinearAcceleration
Plane< T > Flipped() const
void SetSize(const Size< T > &sz)
Vector3 & operator/=(T s)
static const float DegreeToRadFactor
bool operator==(const Vector3 &b) const
SymMat3 operator*(T s) const
static int Index(unsigned int i, unsigned int j)