498 inline Vector3(
const XrVector3f vec)
505 inline Vector3(
const float fX,
const float fY,
const float fZ)
506 : x(fX), y(fY), z(fZ) {}
508 inline explicit Vector3(
const float afCoordinate[3])
509 : x(afCoordinate[0]),
511 z(afCoordinate[2]) {}
513 inline explicit Vector3(
const int afCoordinate[3])
515 x = (float)afCoordinate[0];
516 y = (float)afCoordinate[1];
517 z = (float)afCoordinate[2];
520 inline explicit Vector3(
float*
const r)
521 : x(r[0]), y(r[1]), z(r[2]) {}
523 inline explicit Vector3(
const float scaler)
528 inline float operator [] (
const size_t i)
const
533 inline float& operator [] (
const size_t i)
543 inline const float*
ptr()
const
557 inline Vector3& operator = (
const float fScaler)
566 inline bool operator == (
const Vector3& rkVector)
const
568 return (x == rkVector.x && y == rkVector.y && z == rkVector.z);
571 inline bool operator != (
const Vector3& rkVector)
const
573 return (x != rkVector.x || y != rkVector.y || z != rkVector.z);
593 inline Vector3 operator * (
const float fScalar)
const
609 inline Vector3 operator / (
const float fScalar)
const
611 float fInv = 1.0f / fScalar;
627 inline const Vector3& operator + ()
const
632 inline Vector3 operator - ()
const
638 inline friend Vector3 operator * (
const float fScalar,
const Vector3& rkVector)
641 fScalar * rkVector.x,
642 fScalar * rkVector.y,
643 fScalar * rkVector.z);
646 inline friend Vector3 operator / (
const float fScalar,
const Vector3& rkVector)
649 fScalar / rkVector.x,
650 fScalar / rkVector.y,
651 fScalar / rkVector.z);
654 inline friend Vector3 operator + (
const Vector3& lhs,
const float rhs)
662 inline friend Vector3 operator + (
const float lhs,
const Vector3& rhs)
670 inline friend Vector3 operator - (
const Vector3& lhs,
const float rhs)
678 inline friend Vector3 operator - (
const float lhs,
const Vector3& rhs)
696 inline Vector3& operator += (
const float fScalar)
713 inline Vector3& operator -= (
const float fScalar)
721 inline Vector3& operator *= (
const float fScalar)
738 inline Vector3& operator /= (
const float fScalar)
740 float fInv = 1.0f / fScalar;
761 y * rkVector.z - z * rkVector.y,
762 z * rkVector.x - x * rkVector.z,
763 x * rkVector.y - y * rkVector.x);
766 inline float dotProduct(
const Vector3& vec)
const
769 for (
int i = 0; i < 3; i++)
770 ret +=
ptr()[i] * vec.
ptr()[i];
774 inline float squaredLength()
const {
return dotProduct(*
this); }
776 inline float length()
const {
return std::sqrt(squaredLength()); }
778 float distance(
const Vector3& rhs)
const
780 return (*
this - rhs).length();
796 inline Vector4(
const float fX,
const float fY,
const float fZ,
const float fW)
797 : x(fX), y(fY), z(fZ), w(fW) {}
799 inline explicit Vector4(
const float afCoordinate[4])
800 : x(afCoordinate[0]),
803 w(afCoordinate[3]) {}
805 inline explicit Vector4(
const int afCoordinate[4])
807 x = (float)afCoordinate[0];
808 y = (float)afCoordinate[1];
809 z = (float)afCoordinate[2];
810 w = (float)afCoordinate[3];
813 inline explicit Vector4(
float*
const r)
814 : x(r[0]), y(r[1]), z(r[2]), w(r[3]) {}
816 inline explicit Vector4(
const float scaler)
822 inline float operator [] (
const size_t i)
const
827 inline float& operator [] (
const size_t i)
837 inline const float*
ptr()
const
852 inline Vector4& operator = (
const float fScaler)
862 inline bool operator == (
const Vector4& rkVector)
const
864 return (x == rkVector.x && y == rkVector.y && z == rkVector.z);
867 inline bool operator != (
const Vector4& rkVector)
const
869 return (x != rkVector.x || y != rkVector.y || z != rkVector.z || w != rkVector.w);
891 inline Vector4 operator * (
const float fScalar)
const
909 inline Vector4 operator / (
const float fScalar)
const
911 float fInv = 1.0f / fScalar;
929 inline const Vector4& operator + ()
const
934 inline Vector4 operator - ()
const
936 return Vector4(-x, -y, -z, -w);
940 inline friend Vector4 operator * (
const float fScalar,
const Vector4& rkVector)
943 fScalar * rkVector.x,
944 fScalar * rkVector.y,
945 fScalar * rkVector.z,
946 fScalar * rkVector.w);
949 inline friend Vector4 operator / (
const float fScalar,
const Vector4& rkVector)
952 fScalar / rkVector.x,
953 fScalar / rkVector.y,
954 fScalar / rkVector.z,
955 fScalar / rkVector.w);
958 inline friend Vector4 operator + (
const Vector4& lhs,
const float rhs)
967 inline friend Vector4 operator + (
const float lhs,
const Vector4& rhs)
976 inline friend Vector4 operator - (
const Vector4& lhs,
const float rhs)
985 inline friend Vector4 operator - (
const float lhs,
const Vector4& rhs)
1005 inline Vector4& operator += (
const float fScalar)
1024 inline Vector4& operator -= (
const float fScalar)
1033 inline Vector4& operator *= (
const float fScalar)
1052 inline Vector4& operator /= (
const float fScalar)
1054 float fInv = 1.0f / fScalar;
1137 inline Quaternion() : w(1), x(0), y(0), z(0) {}
1139 inline Quaternion(
float fW,
float fX,
float fY,
float fZ) : w(fW), x(fX), y(fY), z(fZ) {}
1151 this->FromRotationMatrix(rot);
1156 this->FromAngleAxis(rfAngle, rkAxis);
1159 inline float operator [] (
const size_t i)
const
1164 inline float& operator [] (
const size_t i)
1169 inline void FromAngleAxis(
const float& rfAngle,
const Vector3& rkAxis)
1176 float fHalfAngle = 0.5f * rfAngle;
1177 float fSin = std::sin(fHalfAngle);
1178 w = std::cos(fHalfAngle);
1179 x = fSin * rkAxis.x;
1180 y = fSin * rkAxis.y;
1181 z = fSin * rkAxis.z;
1184 void FromRotationMatrix(
const Matrix3& kRot);
1186 void ToRotationMatrix(
Matrix3& kRot)
const;
1198 return Quaternion(w + rkQ.w, x + rkQ.x, y + rkQ.y, z + rkQ.z);
1202 return Quaternion(w - rkQ.w, x - rkQ.x, y - rkQ.y, z - rkQ.z);
1208 w * rkQ.w - x * rkQ.x - y * rkQ.y - z * rkQ.z,
1209 w * rkQ.x + x * rkQ.w + y * rkQ.z - z * rkQ.y,
1210 w * rkQ.y + y * rkQ.w + z * rkQ.x - x * rkQ.z,
1211 w * rkQ.z + z * rkQ.w + x * rkQ.y - y * rkQ.x
1216 return Quaternion(fScalar*w, fScalar*x, fScalar*y, fScalar*z);
1224 uv = qvec.crossProduct(v);
1225 uuv = qvec.crossProduct(uv);
1229 return v + uv + uuv;
1236 inline bool operator== (
const Quaternion& rhs)
const
1238 return (rhs.x == x) && (rhs.y == y) && (rhs.z == z) && (rhs.w == w);
1240 inline bool operator!= (
const Quaternion& rhs)
const
1242 return !operator==(rhs);
1248 inline const float* ptr()
const
1253 float normalise(
void);
1265 static const Matrix4 IDENTITY;
1270 float m00,
float m01,
float m02,
float m03,
1271 float m10,
float m11,
float m12,
float m13,
1272 float m20,
float m21,
float m22,
float m23,
1273 float m30,
float m31,
float m32,
float m33)
1298 m[0][3] = mat.m[12];
1302 m[1][3] = mat.m[13];
1305 m[2][2] = mat.m[10];
1306 m[2][3] = mat.m[14];
1309 m[3][2] = mat.m[11];
1310 m[3][3] = mat.m[15];
1315 operator=(IDENTITY);
1322 rot.ToRotationMatrix(m3x3);
1323 operator=(IDENTITY);
1327 inline void extract3x3MatrixNegZ(
Matrix3& m3x3)
const
1329 m3x3.m[0][0] = m[0][0];
1330 m3x3.m[0][1] = m[0][1];
1331 m3x3.m[0][2] = -m[0][2];
1332 m3x3.m[1][0] = m[1][0];
1333 m3x3.m[1][1] = m[1][1];
1334 m3x3.m[1][2] = -m[1][2];
1335 m3x3.m[2][0] = -m[2][0];
1336 m3x3.m[2][1] = -m[2][1];
1337 m3x3.m[2][2] = m[2][2];
1340 inline void extract3x3MatrixNegX(
Matrix3& m3x3)
const
1342 m3x3.m[0][0] = -m[0][0];
1343 m3x3.m[0][1] = m[0][1];
1344 m3x3.m[0][2] = m[0][2];
1345 m3x3.m[1][0] = -m[1][0];
1346 m3x3.m[1][1] = m[1][1];
1347 m3x3.m[1][2] = m[1][2];
1348 m3x3.m[2][0] = m[2][0];
1349 m3x3.m[2][1] = -m[2][1];
1350 m3x3.m[2][2] = -m[2][2];
1353 inline void extract3x3Matrix(
Matrix3& m3x3)
const
1355 m3x3.m[0][0] = m[0][0];
1356 m3x3.m[0][1] = m[0][1];
1357 m3x3.m[0][2] = m[0][2];
1358 m3x3.m[1][0] = m[1][0];
1359 m3x3.m[1][1] = m[1][1];
1360 m3x3.m[1][2] = m[1][2];
1361 m3x3.m[2][0] = m[2][0];
1362 m3x3.m[2][1] = m[2][1];
1363 m3x3.m[2][2] = m[2][2];
1369 extract3x3Matrix(m3x3);
1373 inline Quaternion extractQuaternionNegZ()
const
1376 extract3x3MatrixNegZ(m3x3);
1380 inline Quaternion extractQuaternionNegX()
const
1383 extract3x3MatrixNegX(m3x3);
1387 inline Vector3 getTrans()
const
1389 return Vector3(m[0][3], m[1][3], m[2][3]);
1391 inline void operator = (
const Matrix3& mat3)
1393 m[0][0] = mat3.m[0][0]; m[0][1] = mat3.m[0][1]; m[0][2] = mat3.m[0][2];
1394 m[1][0] = mat3.m[1][0]; m[1][1] = mat3.m[1][1]; m[1][2] = mat3.m[1][2];
1395 m[2][0] = mat3.m[2][0]; m[2][1] = mat3.m[2][1]; m[2][2] = mat3.m[2][2];
1397 inline float* operator [] (
size_t iRow)
1402 inline const float *operator [] (
size_t iRow)
const
1409 return concatenate(m2);
1415 r.m[0][0] = m[0][0] * m2.m[0][0] + m[0][1] * m2.m[1][0] + m[0][2] * m2.m[2][0] + m[0][3] * m2.m[3][0];
1416 r.m[0][1] = m[0][0] * m2.m[0][1] + m[0][1] * m2.m[1][1] + m[0][2] * m2.m[2][1] + m[0][3] * m2.m[3][1];
1417 r.m[0][2] = m[0][0] * m2.m[0][2] + m[0][1] * m2.m[1][2] + m[0][2] * m2.m[2][2] + m[0][3] * m2.m[3][2];
1418 r.m[0][3] = m[0][0] * m2.m[0][3] + m[0][1] * m2.m[1][3] + m[0][2] * m2.m[2][3] + m[0][3] * m2.m[3][3];
1420 r.m[1][0] = m[1][0] * m2.m[0][0] + m[1][1] * m2.m[1][0] + m[1][2] * m2.m[2][0] + m[1][3] * m2.m[3][0];
1421 r.m[1][1] = m[1][0] * m2.m[0][1] + m[1][1] * m2.m[1][1] + m[1][2] * m2.m[2][1] + m[1][3] * m2.m[3][1];
1422 r.m[1][2] = m[1][0] * m2.m[0][2] + m[1][1] * m2.m[1][2] + m[1][2] * m2.m[2][2] + m[1][3] * m2.m[3][2];
1423 r.m[1][3] = m[1][0] * m2.m[0][3] + m[1][1] * m2.m[1][3] + m[1][2] * m2.m[2][3] + m[1][3] * m2.m[3][3];
1425 r.m[2][0] = m[2][0] * m2.m[0][0] + m[2][1] * m2.m[1][0] + m[2][2] * m2.m[2][0] + m[2][3] * m2.m[3][0];
1426 r.m[2][1] = m[2][0] * m2.m[0][1] + m[2][1] * m2.m[1][1] + m[2][2] * m2.m[2][1] + m[2][3] * m2.m[3][1];
1427 r.m[2][2] = m[2][0] * m2.m[0][2] + m[2][1] * m2.m[1][2] + m[2][2] * m2.m[2][2] + m[2][3] * m2.m[3][2];
1428 r.m[2][3] = m[2][0] * m2.m[0][3] + m[2][1] * m2.m[1][3] + m[2][2] * m2.m[2][3] + m[2][3] * m2.m[3][3];
1430 r.m[3][0] = m[3][0] * m2.m[0][0] + m[3][1] * m2.m[1][0] + m[3][2] * m2.m[2][0] + m[3][3] * m2.m[3][0];
1431 r.m[3][1] = m[3][0] * m2.m[0][1] + m[3][1] * m2.m[1][1] + m[3][2] * m2.m[2][1] + m[3][3] * m2.m[3][1];
1432 r.m[3][2] = m[3][0] * m2.m[0][2] + m[3][1] * m2.m[1][2] + m[3][2] * m2.m[2][2] + m[3][3] * m2.m[3][2];
1433 r.m[3][3] = m[3][0] * m2.m[0][3] + m[3][1] * m2.m[1][3] + m[3][2] * m2.m[2][3] + m[3][3] * m2.m[3][3];