17 #ifndef _VECTORMATH_AOS_CPP_H
18 #define _VECTORMATH_AOS_CPP_H
22 #ifdef _VECTORMATH_DEBUG
26 namespace Vectormath {
64 inline Vector3(
float x,
float y,
float z );
72 explicit inline Vector3(
float scalar );
92 inline float getX( )
const;
96 inline float getY( )
const;
100 inline float getZ( )
const;
108 inline float getElem(
int idx )
const;
178 inline const Vector3
operator *(
float scalar,
const Vector3 & vec );
182 inline const Vector3
mulPerElem(
const Vector3 & vec0,
const Vector3 & vec1 );
188 inline const Vector3
divPerElem(
const Vector3 & vec0,
const Vector3 & vec1 );
194 inline const Vector3
recipPerElem(
const Vector3 & vec );
200 inline const Vector3
sqrtPerElem(
const Vector3 & vec );
206 inline const Vector3
rsqrtPerElem(
const Vector3 & vec );
210 inline const Vector3
absPerElem(
const Vector3 & vec );
214 inline const Vector3
copySignPerElem(
const Vector3 & vec0,
const Vector3 & vec1 );
218 inline const Vector3
maxPerElem(
const Vector3 & vec0,
const Vector3 & vec1 );
222 inline const Vector3
minPerElem(
const Vector3 & vec0,
const Vector3 & vec1 );
226 inline float maxElem(
const Vector3 & vec );
230 inline float minElem(
const Vector3 & vec );
234 inline float sum(
const Vector3 & vec );
238 inline float dot(
const Vector3 & vec0,
const Vector3 & vec1 );
242 inline float lengthSqr(
const Vector3 & vec );
246 inline float length(
const Vector3 & vec );
252 inline const Vector3
normalize(
const Vector3 & vec );
256 inline const Vector3
cross(
const Vector3 & vec0,
const Vector3 & vec1 );
260 inline const Matrix3
outer(
const Vector3 & vec0,
const Vector3 & vec1 );
264 inline const Vector3
rowMul(
const Vector3 & vec,
const Matrix3 & mat );
268 inline const Matrix3
crossMatrix(
const Vector3 & vec );
274 inline const Matrix3
crossMatrixMul(
const Vector3 & vec,
const Matrix3 & mat );
280 inline const Vector3
lerp(
float t,
const Vector3 & vec0,
const Vector3 & vec1 );
287 inline const Vector3
slerp(
float t,
const Vector3 & unitVec0,
const Vector3 & unitVec1 );
291 inline const Vector3
select(
const Vector3 & vec0,
const Vector3 & vec1,
bool select1 );
296 inline void loadXYZ( Vector3 & vec,
const float * fptr );
301 inline void storeXYZ(
const Vector3 & vec,
float * fptr );
307 inline void loadHalfFloats( Vector3 & vec,
const unsigned short * hfptr );
313 inline void storeHalfFloats(
const Vector3 & vec,
unsigned short * hfptr );
315 #ifdef _VECTORMATH_DEBUG
321 inline void print(
const Vector3 & vec );
327 inline void print(
const Vector3 & vec,
const char * name );
351 inline Vector4(
float x,
float y,
float z,
float w );
371 explicit inline Vector4(
float scalar );
405 inline float getX( )
const;
409 inline float getY( )
const;
413 inline float getZ( )
const;
417 inline float getW( )
const;
425 inline float getElem(
int idx )
const;
495 inline const Vector4
operator *(
float scalar,
const Vector4 & vec );
499 inline const Vector4
mulPerElem(
const Vector4 & vec0,
const Vector4 & vec1 );
505 inline const Vector4
divPerElem(
const Vector4 & vec0,
const Vector4 & vec1 );
511 inline const Vector4
recipPerElem(
const Vector4 & vec );
517 inline const Vector4
sqrtPerElem(
const Vector4 & vec );
523 inline const Vector4
rsqrtPerElem(
const Vector4 & vec );
527 inline const Vector4
absPerElem(
const Vector4 & vec );
531 inline const Vector4
copySignPerElem(
const Vector4 & vec0,
const Vector4 & vec1 );
535 inline const Vector4
maxPerElem(
const Vector4 & vec0,
const Vector4 & vec1 );
539 inline const Vector4
minPerElem(
const Vector4 & vec0,
const Vector4 & vec1 );
543 inline float maxElem(
const Vector4 & vec );
547 inline float minElem(
const Vector4 & vec );
551 inline float sum(
const Vector4 & vec );
555 inline float dot(
const Vector4 & vec0,
const Vector4 & vec1 );
559 inline float lengthSqr(
const Vector4 & vec );
563 inline float length(
const Vector4 & vec );
569 inline const Vector4
normalize(
const Vector4 & vec );
573 inline const Matrix4
outer(
const Vector4 & vec0,
const Vector4 & vec1 );
579 inline const Vector4
lerp(
float t,
const Vector4 & vec0,
const Vector4 & vec1 );
586 inline const Vector4
slerp(
float t,
const Vector4 & unitVec0,
const Vector4 & unitVec1 );
590 inline const Vector4
select(
const Vector4 & vec0,
const Vector4 & vec1,
bool select1 );
595 inline void loadXYZW( Vector4 & vec,
const float * fptr );
600 inline void storeXYZW(
const Vector4 & vec,
float * fptr );
606 inline void loadHalfFloats( Vector4 & vec,
const unsigned short * hfptr );
612 inline void storeHalfFloats(
const Vector4 & vec,
unsigned short * hfptr );
614 #ifdef _VECTORMATH_DEBUG
620 inline void print(
const Vector4 & vec );
626 inline void print(
const Vector4 & vec,
const char * name );
652 inline Point3(
float x,
float y,
float z );
660 explicit inline Point3(
float scalar );
680 inline float getX( )
const;
684 inline float getY( )
const;
688 inline float getZ( )
const;
696 inline float getElem(
int idx )
const;
734 inline const Point3
mulPerElem(
const Point3 & pnt0,
const Point3 & pnt1 );
740 inline const Point3
divPerElem(
const Point3 & pnt0,
const Point3 & pnt1 );
752 inline const Point3
sqrtPerElem(
const Point3 & pnt );
762 inline const Point3
absPerElem(
const Point3 & pnt );
766 inline const Point3
copySignPerElem(
const Point3 & pnt0,
const Point3 & pnt1 );
770 inline const Point3
maxPerElem(
const Point3 & pnt0,
const Point3 & pnt1 );
774 inline const Point3
minPerElem(
const Point3 & pnt0,
const Point3 & pnt1 );
778 inline float maxElem(
const Point3 & pnt );
782 inline float minElem(
const Point3 & pnt );
786 inline float sum(
const Point3 & pnt );
790 inline const Point3
scale(
const Point3 & pnt,
float scaleVal );
794 inline const Point3
scale(
const Point3 & pnt,
const Vector3 & scaleVec );
798 inline float projection(
const Point3 & pnt,
const Vector3 & unitVec );
810 inline float distSqr(
const Point3 & pnt0,
const Point3 & pnt1 );
814 inline float dist(
const Point3 & pnt0,
const Point3 & pnt1 );
820 inline const Point3
lerp(
float t,
const Point3 & pnt0,
const Point3 & pnt1 );
824 inline const Point3
select(
const Point3 & pnt0,
const Point3 & pnt1,
bool select1 );
829 inline void loadXYZ( Point3 & pnt,
const float * fptr );
834 inline void storeXYZ(
const Point3 & pnt,
float * fptr );
840 inline void loadHalfFloats( Point3 & pnt,
const unsigned short * hfptr );
846 inline void storeHalfFloats(
const Point3 & pnt,
unsigned short * hfptr );
848 #ifdef _VECTORMATH_DEBUG
854 inline void print(
const Point3 & pnt );
860 inline void print(
const Point3 & pnt,
const char * name );
884 inline Quat(
float x,
float y,
float z,
float w );
900 explicit inline Quat(
float scalar );
934 inline float getX( )
const;
938 inline float getY( )
const;
942 inline float getZ( )
const;
946 inline float getW( )
const;
954 inline float getElem(
int idx )
const;
1042 inline const Quat
operator *(
float scalar,
const Quat & quat );
1046 inline const Quat
conj(
const Quat & quat );
1050 inline const Vector3
rotate(
const Quat & unitQuat,
const Vector3 & vec );
1054 inline float dot(
const Quat & quat0,
const Quat & quat1 );
1058 inline float norm(
const Quat & quat );
1062 inline float length(
const Quat & quat );
1068 inline const Quat
normalize(
const Quat & quat );
1074 inline const Quat
lerp(
float t,
const Quat & quat0,
const Quat & quat1 );
1081 inline const Quat
slerp(
float t,
const Quat & unitQuat0,
const Quat & unitQuat1 );
1085 inline const Quat
squad(
float t,
const Quat & unitQuat0,
const Quat & unitQuat1,
const Quat & unitQuat2,
const Quat & unitQuat3 );
1089 inline const Quat
select(
const Quat & quat0,
const Quat & quat1,
bool select1 );
1094 inline void loadXYZW( Quat & quat,
const float * fptr );
1099 inline void storeXYZW(
const Quat & quat,
float * fptr );
1101 #ifdef _VECTORMATH_DEBUG
1107 inline void print(
const Quat & quat );
1113 inline void print(
const Quat & quat,
const char * name );
1144 explicit inline Matrix3(
float scalar );
1204 inline float getElem(
int col,
int row )
const;
1281 inline const Matrix3
operator *(
float scalar,
const Matrix3 & mat );
1287 inline const Matrix3
appendScale(
const Matrix3 & mat,
const Vector3 & scaleVec );
1293 inline const Matrix3
prependScale(
const Vector3 & scaleVec,
const Matrix3 & mat );
1297 inline const Matrix3
mulPerElem(
const Matrix3 & mat0,
const Matrix3 & mat1 );
1301 inline const Matrix3
absPerElem(
const Matrix3 & mat );
1305 inline const Matrix3
transpose(
const Matrix3 & mat );
1311 inline const Matrix3
inverse(
const Matrix3 & mat );
1319 inline const Matrix3
select(
const Matrix3 & mat0,
const Matrix3 & mat1,
bool select1 );
1321 #ifdef _VECTORMATH_DEBUG
1327 inline void print(
const Matrix3 & mat );
1333 inline void print(
const Matrix3 & mat,
const char * name );
1373 explicit inline Matrix4(
float scalar );
1461 inline float getElem(
int col,
int row )
const;
1561 static inline const Matrix4 perspective(
float fovyRadians,
float aspect,
float zNear,
float zFar );
1565 static inline const Matrix4 frustum(
float left,
float right,
float bottom,
float top,
float zNear,
float zFar );
1569 static inline const Matrix4 orthographic(
float left,
float right,
float bottom,
float top,
float zNear,
float zFar );
1574 inline const Matrix4
operator *(
float scalar,
const Matrix4 & mat );
1580 inline const Matrix4
appendScale(
const Matrix4 & mat,
const Vector3 & scaleVec );
1586 inline const Matrix4
prependScale(
const Vector3 & scaleVec,
const Matrix4 & mat );
1590 inline const Matrix4
mulPerElem(
const Matrix4 & mat0,
const Matrix4 & mat1 );
1594 inline const Matrix4
absPerElem(
const Matrix4 & mat );
1598 inline const Matrix4
transpose(
const Matrix4 & mat );
1604 inline const Matrix4
inverse(
const Matrix4 & mat );
1616 inline const Matrix4
orthoInverse(
const Matrix4 & mat );
1624 inline const Matrix4
select(
const Matrix4 & mat0,
const Matrix4 & mat1,
bool select1 );
1626 #ifdef _VECTORMATH_DEBUG
1632 inline void print(
const Matrix4 & mat );
1638 inline void print(
const Matrix4 & mat,
const char * name );
1758 inline float getElem(
int col,
int row )
const;
1817 inline const Transform3
appendScale(
const Transform3 & tfrm,
const Vector3 & scaleVec );
1823 inline const Transform3
prependScale(
const Vector3 & scaleVec,
const Transform3 & tfrm );
1827 inline const Transform3
mulPerElem(
const Transform3 & tfrm0,
const Transform3 & tfrm1 );
1831 inline const Transform3
absPerElem(
const Transform3 & tfrm );
1837 inline const Transform3
inverse(
const Transform3 & tfrm );
1843 inline const Transform3
orthoInverse(
const Transform3 & tfrm );
1847 inline const Transform3
select(
const Transform3 & tfrm0,
const Transform3 & tfrm1,
bool select1 );
1849 #ifdef _VECTORMATH_DEBUG
1855 inline void print(
const Transform3 & tfrm );
1861 inline void print(
const Transform3 & tfrm,
const char * name );
const Vector4 operator*(float scalar) const
const Quat normalize(const Quat &quat)
Matrix4 & setCol1(const Vector4 &col1)
float determinant(const Matrix3 &mat)
static const Quat rotationY(float radians)
float & operator[](int idx)
const Vector3 rowMul(const Vector3 &vec, const Matrix3 &mat)
static const Matrix4 scale(const Vector3 &scaleVec)
const Vector3 getXYZ() const
const Matrix3 crossMatrixMul(const Vector3 &vec, const Matrix3 &mat)
const Vector3 recipPerElem(const Vector3 &vec)
static const Vector4 yAxis()
float minElem(const Vector3 &vec)
void loadHalfFloats(Vector3 &vec, const unsigned short *hfptr)
Vector4 & setXYZ(const Vector3 &vec)
static const Matrix4 rotationX(float radians)
Vector4 & operator+=(const Vector4 &vec)
static const Matrix4 translation(const Vector3 &translateVec)
static const Vector3 xAxis()
static const Vector3 zAxis()
const Matrix4 operator+(const Matrix4 &mat) const
void storeHalfFloats(const Vector3 &vec, unsigned short *hfptr)
float dist(const Point3 &pnt0, const Point3 &pnt1)
const Vector3 minPerElem(const Vector3 &vec0, const Vector3 &vec1)
Quat & operator*=(const Quat &quat)
Quat & operator-=(const Quat &quat)
const Matrix3 operator*(float scalar) const
Matrix3 & setElem(int col, int row, float val)
Point3 & operator=(const Point3 &pnt)
const Quat operator+(const Quat &quat) const
Point3 & setElem(int idx, float value)
static const Vector4 xAxis()
const Matrix3 appendScale(const Matrix3 &mat, const Vector3 &scaleVec)
Vector3 & operator=(const Vector3 &vec)
Matrix3 & setCol0(const Vector3 &col0)
Matrix3 & setCol2(const Vector3 &col2)
Matrix3 & operator-=(const Matrix3 &mat)
Point3 & operator-=(const Vector3 &vec)
const Matrix3 inverse(const Matrix3 &mat)
Quat & operator=(const Quat &quat)
float distFromOrigin(const Point3 &pnt)
static const Matrix4 rotation(float radians, const Vector3 &unitVec)
static const Matrix4 rotationY(float radians)
const Vector4 operator-() const
Vector3 & operator/=(float scalar)
const Vector3 rotate(const Quat &quat, const Vector3 &vec)
float & operator[](int idx)
const Matrix3 crossMatrix(const Vector3 &vec)
const Vector3 sqrtPerElem(const Vector3 &vec)
static const Quat identity()
float getElem(int col, int row) const
Matrix4 & operator-=(const Matrix4 &mat)
static const Matrix4 orthographic(float left, float right, float bottom, float top, float zNear, float zFar)
static const Matrix3 rotationZ(float radians)
static const Vector3 yAxis()
static const Matrix3 rotationZYX(const Vector3 &radiansXYZ)
static const Quat rotationZ(float radians)
static const Quat rotation(const Vector3 &unitVec0, const Vector3 &unitVec1)
Vector3 & operator-=(const Vector3 &vec)
const Matrix4 operator*(float scalar) const
const Vector4 getCol3() const
static const Matrix4 identity()
static const Vector4 wAxis()
static const Matrix3 identity()
const Vector4 getCol1() const
Matrix4 & setTranslation(const Vector3 &translateVec)
const Vector3 maxPerElem(const Vector3 &vec0, const Vector3 &vec1)
const Vector4 getCol0() const
const Matrix4 affineInverse(const Matrix4 &mat)
static const Matrix3 scale(const Vector3 &scaleVec)
float lengthSqr(const Vector3 &vec)
float distSqrFromOrigin(const Point3 &pnt)
const Point3 operator+(const Vector3 &vec) const
float & operator[](int idx)
const Point3 scale(const Point3 &pnt, float scaleVal)
const Vector3 operator-(const Point3 &pnt) const
float projection(const Point3 &pnt, const Vector3 &unitVec)
Vector4 & operator[](int col)
static const Quat rotationX(float radians)
const Vector3 copySignPerElem(const Vector3 &vec0, const Vector3 &vec1)
const Vector3 getCol0() const
const Matrix3 getUpper3x3() const
Matrix4 & setElem(int col, int row, float val)
const Matrix3 outer(const Vector3 &tfrm0, const Vector3 &tfrm1)
const Vector3 operator-() const
const Matrix4 operator-() const
Matrix4 & operator*=(float scalar)
const Vector3 operator+(const Vector3 &vec) const
const Quat operator*(const Quat &quat) const
static const Matrix4 frustum(float left, float right, float bottom, float top, float zNear, float zFar)
float norm(const Quat &quat)
Vector3 & operator[](int col)
const Quat operator/(float scalar) const
Vector3 & setElem(int idx, float value)
const Vector3 getTranslation() const
const Matrix3 prependScale(const Vector3 &scaleVec, const Matrix3 &mat)
const Quat operator-() const
const Vector4 getCol2() const
const Matrix3 operator+(const Matrix3 &mat) const
const Vector3 getXYZ() const
Matrix3 & operator+=(const Matrix3 &mat)
const Vector3 operator/(float scalar) const
const Matrix3 operator-() const
Matrix3 & setCol1(const Vector3 &col1)
Point3 & operator+=(const Vector3 &vec)
void loadXYZW(Quat &quat, const float *fptr)
static const Matrix3 rotationX(float radians)
const Matrix4 orthoInverse(const Matrix4 &mat)
const Quat conj(const Quat &quat)
const Vector4 operator+(const Vector4 &vec) const
const Vector3 rsqrtPerElem(const Vector3 &vec)
float distSqr(const Point3 &pnt0, const Point3 &pnt1)
float getElem(int idx) const
Matrix4 & setCol3(const Vector4 &col3)
static const Matrix3 rotation(float radians, const Vector3 &unitVec)
const Vector4 getCol(int col) const
Matrix4 & setCol(int col, const Vector4 &vec)
Matrix4 & setUpper3x3(const Matrix3 &mat3)
Quat & operator/=(float scalar)
void storeXYZW(const Quat &quat, float *fptr)
const Quat lerp(float t, const Quat &quat0, const Quat &quat1)
Matrix4 & setCol2(const Vector4 &col2)
static const Matrix4 lookAt(const Point3 &eyePos, const Point3 &lookAtPos, const Vector3 &upVec)
const Matrix3 select(const Matrix3 &mat0, const Matrix3 &mat1, bool select1)
Matrix4 & operator+=(const Matrix4 &mat)
Quat & setElem(int idx, float value)
static const Matrix4 perspective(float fovyRadians, float aspect, float zNear, float zFar)
const Vector4 operator/(float scalar) const
Vector3 & operator*=(float scalar)
float getElem(int idx) const
static const Matrix3 rotationY(float radians)
const Matrix3 transpose(const Matrix3 &mat)
Vector3 & operator+=(const Vector3 &vec)
Matrix3 & operator*=(float scalar)
float getElem(int idx) const
const Vector3 getRow(int row) const
float getElem(int idx) const
Matrix4 & setCol0(const Vector4 &col0)
float maxElem(const Vector3 &vec)
void storeXYZ(const Vector3 &vec, float *fptr)
float & operator[](int idx)
Matrix4 & setRow(int row, const Vector4 &vec)
Matrix3 & setCol(int col, const Vector3 &vec)
const Quat squad(float t, const Quat &unitQuat0, const Quat &unitQuat1, const Quat &unitQuat2, const Quat &unitQuat3)
float getElem(int col, int row) const
const Vector3 getCol(int col) const
static const Matrix4 rotationZYX(const Vector3 &radiansXYZ)
float sum(const Vector3 &vec)
static const Vector4 zAxis()
float dot(const Quat &quat0, const Quat &quat1)
const Vector3 cross(const Vector3 &vec0, const Vector3 &vec1)
const Matrix3 mulPerElem(const Matrix3 &mat0, const Matrix3 &mat1)
Vector4 & operator/=(float scalar)
Quat & setXYZ(const Vector3 &vec)
static const Matrix4 rotationZ(float radians)
Matrix3 & operator=(const Matrix3 &mat)
const Vector3 operator*(float scalar) const
const Vector4 getRow(int row) const
float length(const Quat &quat)
Vector4 & operator*=(float scalar)
const Vector3 divPerElem(const Vector3 &vec0, const Vector3 &vec1)
const Vector3 getCol2() const
const Matrix3 absPerElem(const Matrix3 &mat)
Vector4 & setElem(int idx, float value)
const Matrix3 operator*(float scalar, const Matrix3 &mat)
Matrix3 & setRow(int row, const Vector3 &vec)
Vector4 & operator=(const Vector4 &vec)
Matrix4 & operator=(const Matrix4 &mat)
Quat & operator+=(const Quat &quat)
Vector4 & operator-=(const Vector4 &vec)
const Vector3 getCol1() const
void loadXYZ(Vector3 &vec, const float *fptr)
const Quat slerp(float t, const Quat &unitQuat0, const Quat &unitQuat1)