19 #ifndef _VECTORMATH_AOS_CPP_H
20 #define _VECTORMATH_AOS_CPP_H
24 #ifdef _VECTORMATH_DEBUG
28 namespace Vectormath {
66 inline Vector3(
float x,
float y,
float z );
74 explicit inline Vector3(
float scalar );
94 inline float getX( )
const;
98 inline float getY( )
const;
102 inline float getZ( )
const;
110 inline float getElem(
int idx )
const;
180 inline const Vector3
operator *(
float scalar,
const Vector3 & vec );
184 inline const Vector3
mulPerElem(
const Vector3 & vec0,
const Vector3 & vec1 );
190 inline const Vector3
divPerElem(
const Vector3 & vec0,
const Vector3 & vec1 );
196 inline const Vector3
recipPerElem(
const Vector3 & vec );
202 inline const Vector3
sqrtPerElem(
const Vector3 & vec );
208 inline const Vector3
rsqrtPerElem(
const Vector3 & vec );
212 inline const Vector3
absPerElem(
const Vector3 & vec );
216 inline const Vector3
copySignPerElem(
const Vector3 & vec0,
const Vector3 & vec1 );
220 inline const Vector3
maxPerElem(
const Vector3 & vec0,
const Vector3 & vec1 );
224 inline const Vector3
minPerElem(
const Vector3 & vec0,
const Vector3 & vec1 );
228 inline float maxElem(
const Vector3 & vec );
232 inline float minElem(
const Vector3 & vec );
236 inline float sum(
const Vector3 & vec );
240 inline float dot(
const Vector3 & vec0,
const Vector3 & vec1 );
244 inline float lengthSqr(
const Vector3 & vec );
248 inline float length(
const Vector3 & vec );
254 inline const Vector3
normalize(
const Vector3 & vec );
258 inline const Vector3
cross(
const Vector3 & vec0,
const Vector3 & vec1 );
262 inline const Matrix3
outer(
const Vector3 & vec0,
const Vector3 & vec1 );
266 inline const Vector3
rowMul(
const Vector3 & vec,
const Matrix3 & mat );
270 inline const Matrix3
crossMatrix(
const Vector3 & vec );
276 inline const Matrix3
crossMatrixMul(
const Vector3 & vec,
const Matrix3 & mat );
282 inline const Vector3
lerp(
float t,
const Vector3 & vec0,
const Vector3 & vec1 );
289 inline const Vector3
slerp(
float t,
const Vector3 & unitVec0,
const Vector3 & unitVec1 );
293 inline const Vector3
select(
const Vector3 & vec0,
const Vector3 & vec1,
bool select1 );
298 inline void loadXYZ( Vector3 & vec,
const float * fptr );
303 inline void storeXYZ(
const Vector3 & vec,
float * fptr );
309 inline void loadHalfFloats( Vector3 & vec,
const unsigned short * hfptr );
315 inline void storeHalfFloats(
const Vector3 & vec,
unsigned short * hfptr );
317 #ifdef _VECTORMATH_DEBUG
323 inline void print(
const Vector3 & vec );
329 inline void print(
const Vector3 & vec,
const char * name );
353 inline Vector4(
float x,
float y,
float z,
float w );
373 explicit inline Vector4(
float scalar );
407 inline float getX( )
const;
411 inline float getY( )
const;
415 inline float getZ( )
const;
419 inline float getW( )
const;
427 inline float getElem(
int idx )
const;
497 inline const Vector4
operator *(
float scalar,
const Vector4 & vec );
501 inline const Vector4
mulPerElem(
const Vector4 & vec0,
const Vector4 & vec1 );
507 inline const Vector4
divPerElem(
const Vector4 & vec0,
const Vector4 & vec1 );
513 inline const Vector4
recipPerElem(
const Vector4 & vec );
519 inline const Vector4
sqrtPerElem(
const Vector4 & vec );
525 inline const Vector4
rsqrtPerElem(
const Vector4 & vec );
529 inline const Vector4
absPerElem(
const Vector4 & vec );
533 inline const Vector4
copySignPerElem(
const Vector4 & vec0,
const Vector4 & vec1 );
537 inline const Vector4
maxPerElem(
const Vector4 & vec0,
const Vector4 & vec1 );
541 inline const Vector4
minPerElem(
const Vector4 & vec0,
const Vector4 & vec1 );
545 inline float maxElem(
const Vector4 & vec );
549 inline float minElem(
const Vector4 & vec );
553 inline float sum(
const Vector4 & vec );
557 inline float dot(
const Vector4 & vec0,
const Vector4 & vec1 );
561 inline float lengthSqr(
const Vector4 & vec );
565 inline float length(
const Vector4 & vec );
571 inline const Vector4
normalize(
const Vector4 & vec );
575 inline const Matrix4
outer(
const Vector4 & vec0,
const Vector4 & vec1 );
581 inline const Vector4
lerp(
float t,
const Vector4 & vec0,
const Vector4 & vec1 );
588 inline const Vector4
slerp(
float t,
const Vector4 & unitVec0,
const Vector4 & unitVec1 );
592 inline const Vector4
select(
const Vector4 & vec0,
const Vector4 & vec1,
bool select1 );
597 inline void loadXYZW( Vector4 & vec,
const float * fptr );
602 inline void storeXYZW(
const Vector4 & vec,
float * fptr );
608 inline void loadHalfFloats( Vector4 & vec,
const unsigned short * hfptr );
614 inline void storeHalfFloats(
const Vector4 & vec,
unsigned short * hfptr );
616 #ifdef _VECTORMATH_DEBUG
622 inline void print(
const Vector4 & vec );
628 inline void print(
const Vector4 & vec,
const char * name );
654 inline Point3(
float x,
float y,
float z );
662 explicit inline Point3(
float scalar );
682 inline float getX( )
const;
686 inline float getY( )
const;
690 inline float getZ( )
const;
698 inline float getElem(
int idx )
const;
736 inline const Point3
mulPerElem(
const Point3 & pnt0,
const Point3 & pnt1 );
742 inline const Point3
divPerElem(
const Point3 & pnt0,
const Point3 & pnt1 );
754 inline const Point3
sqrtPerElem(
const Point3 & pnt );
764 inline const Point3
absPerElem(
const Point3 & pnt );
768 inline const Point3
copySignPerElem(
const Point3 & pnt0,
const Point3 & pnt1 );
772 inline const Point3
maxPerElem(
const Point3 & pnt0,
const Point3 & pnt1 );
776 inline const Point3
minPerElem(
const Point3 & pnt0,
const Point3 & pnt1 );
780 inline float maxElem(
const Point3 & pnt );
784 inline float minElem(
const Point3 & pnt );
788 inline float sum(
const Point3 & pnt );
792 inline const Point3
scale(
const Point3 & pnt,
float scaleVal );
796 inline const Point3
scale(
const Point3 & pnt,
const Vector3 & scaleVec );
800 inline float projection(
const Point3 & pnt,
const Vector3 & unitVec );
812 inline float distSqr(
const Point3 & pnt0,
const Point3 & pnt1 );
816 inline float dist(
const Point3 & pnt0,
const Point3 & pnt1 );
822 inline const Point3
lerp(
float t,
const Point3 & pnt0,
const Point3 & pnt1 );
826 inline const Point3
select(
const Point3 & pnt0,
const Point3 & pnt1,
bool select1 );
831 inline void loadXYZ( Point3 & pnt,
const float * fptr );
836 inline void storeXYZ(
const Point3 & pnt,
float * fptr );
842 inline void loadHalfFloats( Point3 & pnt,
const unsigned short * hfptr );
848 inline void storeHalfFloats(
const Point3 & pnt,
unsigned short * hfptr );
850 #ifdef _VECTORMATH_DEBUG
856 inline void print(
const Point3 & pnt );
862 inline void print(
const Point3 & pnt,
const char * name );
870 #if defined( __APPLE__ ) && defined( BT_USE_NEON )
893 inline Quat(
float x,
float y,
float z,
float w );
897 inline Quat( float32x4_t fXYZW );
913 explicit inline Quat(
float scalar );
945 #if defined( __APPLE__ ) && defined( BT_USE_NEON )
946 inline float32x4_t getvXYZW( )
const;
951 inline float getX( )
const;
955 inline float getY( )
const;
959 inline float getZ( )
const;
963 inline float getW( )
const;
971 inline float getElem(
int idx )
const;
1059 inline const Quat
operator *(
float scalar,
const Quat & quat );
1063 inline const Quat
conj(
const Quat & quat );
1067 inline const Vector3
rotate(
const Quat & unitQuat,
const Vector3 & vec );
1071 inline float dot(
const Quat & quat0,
const Quat & quat1 );
1075 inline float norm(
const Quat & quat );
1079 inline float length(
const Quat & quat );
1085 inline const Quat
normalize(
const Quat & quat );
1091 inline const Quat
lerp(
float t,
const Quat & quat0,
const Quat & quat1 );
1098 inline const Quat
slerp(
float t,
const Quat & unitQuat0,
const Quat & unitQuat1 );
1102 inline const Quat
squad(
float t,
const Quat & unitQuat0,
const Quat & unitQuat1,
const Quat & unitQuat2,
const Quat & unitQuat3 );
1106 inline const Quat
select(
const Quat & quat0,
const Quat & quat1,
bool select1 );
1111 inline void loadXYZW( Quat & quat,
const float * fptr );
1116 inline void storeXYZW(
const Quat & quat,
float * fptr );
1118 #ifdef _VECTORMATH_DEBUG
1124 inline void print(
const Quat & quat );
1130 inline void print(
const Quat & quat,
const char * name );
1161 explicit inline Matrix3(
float scalar );
1221 inline float getElem(
int col,
int row )
const;
1298 inline const Matrix3
operator *(
float scalar,
const Matrix3 & mat );
1304 inline const Matrix3
appendScale(
const Matrix3 & mat,
const Vector3 & scaleVec );
1310 inline const Matrix3
prependScale(
const Vector3 & scaleVec,
const Matrix3 & mat );
1314 inline const Matrix3
mulPerElem(
const Matrix3 & mat0,
const Matrix3 & mat1 );
1318 inline const Matrix3
absPerElem(
const Matrix3 & mat );
1322 inline const Matrix3
transpose(
const Matrix3 & mat );
1328 inline const Matrix3
inverse(
const Matrix3 & mat );
1336 inline const Matrix3
select(
const Matrix3 & mat0,
const Matrix3 & mat1,
bool select1 );
1338 #ifdef _VECTORMATH_DEBUG
1344 inline void print(
const Matrix3 & mat );
1350 inline void print(
const Matrix3 & mat,
const char * name );
1390 explicit inline Matrix4(
float scalar );
1478 inline float getElem(
int col,
int row )
const;
1578 static inline const Matrix4 perspective(
float fovyRadians,
float aspect,
float zNear,
float zFar );
1582 static inline const Matrix4 frustum(
float left,
float right,
float bottom,
float top,
float zNear,
float zFar );
1586 static inline const Matrix4 orthographic(
float left,
float right,
float bottom,
float top,
float zNear,
float zFar );
1591 inline const Matrix4
operator *(
float scalar,
const Matrix4 & mat );
1597 inline const Matrix4
appendScale(
const Matrix4 & mat,
const Vector3 & scaleVec );
1603 inline const Matrix4
prependScale(
const Vector3 & scaleVec,
const Matrix4 & mat );
1607 inline const Matrix4
mulPerElem(
const Matrix4 & mat0,
const Matrix4 & mat1 );
1611 inline const Matrix4
absPerElem(
const Matrix4 & mat );
1615 inline const Matrix4
transpose(
const Matrix4 & mat );
1621 inline const Matrix4
inverse(
const Matrix4 & mat );
1633 inline const Matrix4
orthoInverse(
const Matrix4 & mat );
1641 inline const Matrix4
select(
const Matrix4 & mat0,
const Matrix4 & mat1,
bool select1 );
1643 #ifdef _VECTORMATH_DEBUG
1649 inline void print(
const Matrix4 & mat );
1655 inline void print(
const Matrix4 & mat,
const char * name );
1775 inline float getElem(
int col,
int row )
const;
1834 inline const Transform3
appendScale(
const Transform3 & tfrm,
const Vector3 & scaleVec );
1840 inline const Transform3
prependScale(
const Vector3 & scaleVec,
const Transform3 & tfrm );
1844 inline const Transform3
mulPerElem(
const Transform3 & tfrm0,
const Transform3 & tfrm1 );
1848 inline const Transform3
absPerElem(
const Transform3 & tfrm );
1854 inline const Transform3
inverse(
const Transform3 & tfrm );
1860 inline const Transform3
orthoInverse(
const Transform3 & tfrm );
1864 inline const Transform3
select(
const Transform3 & tfrm0,
const Transform3 & tfrm1,
bool select1 );
1866 #ifdef _VECTORMATH_DEBUG
1872 inline void print(
const Transform3 & tfrm );
1878 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)