2 Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
5 Redistribution and use in source and binary forms,
6 with or without modification, are permitted provided that the
7 following conditions are met:
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of the Sony Computer Entertainment Inc nor the names
14 of its contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE.
30 #ifndef _VECTORMATH_AOS_CPP_SPU_H
31 #define _VECTORMATH_AOS_CPP_SPU_H
34 #include <spu_intrinsics.h>
35 #include "floatInVec.h"
36 #include "boolInVec.h"
37 #include "vecidx_aos.h"
40 #ifdef _VECTORMATH_DEBUG
43 namespace Vectormath {
47 //-----------------------------------------------------------------------------
48 // Forward Declarations
59 // A 3-D vector in array-of-structures format
66 // Default constructor; does no initialization
68 inline Vector3( ) { };
70 // Construct a 3-D vector from x, y, and z elements
72 inline Vector3( float x, float y, float z );
74 // Copy elements from a 3-D point into a 3-D vector
76 explicit inline Vector3( Point3 pnt );
78 // Set all elements of a 3-D vector to the same scalar value
80 explicit inline Vector3( float scalar );
82 // Set vector float data in a 3-D vector
84 explicit inline Vector3( vec_float4 vf4 );
86 // Get vector float data from a 3-D vector
88 inline vec_float4 get128( ) const;
90 // Assign one 3-D vector to another
92 inline Vector3 & operator =( Vector3 vec );
94 // Set the x element of a 3-D vector
96 inline Vector3 & setX( float x );
98 // Set the y element of a 3-D vector
100 inline Vector3 & setY( float y );
102 // Set the z element of a 3-D vector
104 inline Vector3 & setZ( float z );
106 // Get the x element of a 3-D vector
108 inline float getX( ) const;
110 // Get the y element of a 3-D vector
112 inline float getY( ) const;
114 // Get the z element of a 3-D vector
116 inline float getZ( ) const;
118 // Set an x, y, or z element of a 3-D vector by index
120 inline Vector3 & setElem( int idx, float value );
122 // Get an x, y, or z element of a 3-D vector by index
124 inline float getElem( int idx ) const;
126 // Subscripting operator to set or get an element
128 inline VecIdx operator []( int idx );
130 // Subscripting operator to get an element
132 inline float operator []( int idx ) const;
134 // Add two 3-D vectors
136 inline const Vector3 operator +( Vector3 vec ) const;
138 // Subtract a 3-D vector from another 3-D vector
140 inline const Vector3 operator -( Vector3 vec ) const;
142 // Add a 3-D vector to a 3-D point
144 inline const Point3 operator +( Point3 pnt ) const;
146 // Multiply a 3-D vector by a scalar
148 inline const Vector3 operator *( float scalar ) const;
150 // Divide a 3-D vector by a scalar
152 inline const Vector3 operator /( float scalar ) const;
154 // Perform compound assignment and addition with a 3-D vector
156 inline Vector3 & operator +=( Vector3 vec );
158 // Perform compound assignment and subtraction by a 3-D vector
160 inline Vector3 & operator -=( Vector3 vec );
162 // Perform compound assignment and multiplication by a scalar
164 inline Vector3 & operator *=( float scalar );
166 // Perform compound assignment and division by a scalar
168 inline Vector3 & operator /=( float scalar );
170 // Negate all elements of a 3-D vector
172 inline const Vector3 operator -( ) const;
176 static inline const Vector3 xAxis( );
180 static inline const Vector3 yAxis( );
184 static inline const Vector3 zAxis( );
188 // Multiply a 3-D vector by a scalar
190 inline const Vector3 operator *( float scalar, Vector3 vec );
192 // Multiply two 3-D vectors per element
194 inline const Vector3 mulPerElem( Vector3 vec0, Vector3 vec1 );
196 // Divide two 3-D vectors per element
198 // Floating-point behavior matches standard library function divf4.
200 inline const Vector3 divPerElem( Vector3 vec0, Vector3 vec1 );
202 // Compute the reciprocal of a 3-D vector per element
204 // Floating-point behavior matches standard library function recipf4.
206 inline const Vector3 recipPerElem( Vector3 vec );
208 // Compute the square root of a 3-D vector per element
210 // Floating-point behavior matches standard library function sqrtf4.
212 inline const Vector3 sqrtPerElem( Vector3 vec );
214 // Compute the reciprocal square root of a 3-D vector per element
216 // Floating-point behavior matches standard library function rsqrtf4.
218 inline const Vector3 rsqrtPerElem( Vector3 vec );
220 // Compute the absolute value of a 3-D vector per element
222 inline const Vector3 absPerElem( Vector3 vec );
224 // Copy sign from one 3-D vector to another, per element
226 inline const Vector3 copySignPerElem( Vector3 vec0, Vector3 vec1 );
228 // Maximum of two 3-D vectors per element
230 inline const Vector3 maxPerElem( Vector3 vec0, Vector3 vec1 );
232 // Minimum of two 3-D vectors per element
234 inline const Vector3 minPerElem( Vector3 vec0, Vector3 vec1 );
236 // Maximum element of a 3-D vector
238 inline float maxElem( Vector3 vec );
240 // Minimum element of a 3-D vector
242 inline float minElem( Vector3 vec );
244 // Compute the sum of all elements of a 3-D vector
246 inline float sum( Vector3 vec );
248 // Compute the dot product of two 3-D vectors
250 inline float dot( Vector3 vec0, Vector3 vec1 );
252 // Compute the square of the length of a 3-D vector
254 inline float lengthSqr( Vector3 vec );
256 // Compute the length of a 3-D vector
258 inline float length( Vector3 vec );
260 // Normalize a 3-D vector
262 // The result is unpredictable when all elements of vec are at or near zero.
264 inline const Vector3 normalize( Vector3 vec );
266 // Compute cross product of two 3-D vectors
268 inline const Vector3 cross( Vector3 vec0, Vector3 vec1 );
270 // Outer product of two 3-D vectors
272 inline const Matrix3 outer( Vector3 vec0, Vector3 vec1 );
274 // Pre-multiply a row vector by a 3x3 matrix
276 // Slower than column post-multiply.
278 inline const Vector3 rowMul( Vector3 vec, const Matrix3 & mat );
280 // Cross-product matrix of a 3-D vector
282 inline const Matrix3 crossMatrix( Vector3 vec );
284 // Create cross-product matrix and multiply
286 // Faster than separately creating a cross-product matrix and multiplying.
288 inline const Matrix3 crossMatrixMul( Vector3 vec, const Matrix3 & mat );
290 // Linear interpolation between two 3-D vectors
292 // Does not clamp t between 0 and 1.
294 inline const Vector3 lerp( float t, Vector3 vec0, Vector3 vec1 );
296 // Spherical linear interpolation between two 3-D vectors
298 // The result is unpredictable if the vectors point in opposite directions.
299 // Does not clamp t between 0 and 1.
301 inline const Vector3 slerp( float t, Vector3 unitVec0, Vector3 unitVec1 );
303 // Conditionally select between two 3-D vectors
305 // This function uses a conditional select instruction to avoid a branch.
307 inline const Vector3 select( Vector3 vec0, Vector3 vec1, bool select1 );
309 // Store x, y, and z elements of a 3-D vector in the first three words of a quadword.
310 // The value of the fourth word (the word with the highest address) remains unchanged
312 inline void storeXYZ( Vector3 vec, vec_float4 * quad );
314 // Load four three-float 3-D vectors, stored in three quadwords
316 inline void loadXYZArray( Vector3 & vec0, Vector3 & vec1, Vector3 & vec2, Vector3 & vec3, const vec_float4 * threeQuads );
318 // Store four 3-D vectors in three quadwords
320 inline void storeXYZArray( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, vec_float4 * threeQuads );
322 // Store eight 3-D vectors as half-floats
324 inline void storeHalfFloats( Vector3 vec0, Vector3 vec1, Vector3 vec2, Vector3 vec3, Vector3 vec4, Vector3 vec5, Vector3 vec6, Vector3 vec7, vec_ushort8 * threeQuads );
326 #ifdef _VECTORMATH_DEBUG
328 // Print a 3-D vector
330 // Function is only defined when _VECTORMATH_DEBUG is defined.
332 inline void print( Vector3 vec );
334 // Print a 3-D vector and an associated string identifier
336 // Function is only defined when _VECTORMATH_DEBUG is defined.
338 inline void print( Vector3 vec, const char * name );
342 // A 4-D vector in array-of-structures format
349 // Default constructor; does no initialization
351 inline Vector4( ) { };
353 // Construct a 4-D vector from x, y, z, and w elements
355 inline Vector4( float x, float y, float z, float w );
357 // Construct a 4-D vector from a 3-D vector and a scalar
359 inline Vector4( Vector3 xyz, float w );
361 // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0
363 explicit inline Vector4( Vector3 vec );
365 // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1
367 explicit inline Vector4( Point3 pnt );
369 // Copy elements from a quaternion into a 4-D vector
371 explicit inline Vector4( Quat quat );
373 // Set all elements of a 4-D vector to the same scalar value
375 explicit inline Vector4( float scalar );
377 // Set vector float data in a 4-D vector
379 explicit inline Vector4( vec_float4 vf4 );
381 // Get vector float data from a 4-D vector
383 inline vec_float4 get128( ) const;
385 // Assign one 4-D vector to another
387 inline Vector4 & operator =( Vector4 vec );
389 // Set the x, y, and z elements of a 4-D vector
391 // This function does not change the w element.
393 inline Vector4 & setXYZ( Vector3 vec );
395 // Get the x, y, and z elements of a 4-D vector
397 inline const Vector3 getXYZ( ) const;
399 // Set the x element of a 4-D vector
401 inline Vector4 & setX( float x );
403 // Set the y element of a 4-D vector
405 inline Vector4 & setY( float y );
407 // Set the z element of a 4-D vector
409 inline Vector4 & setZ( float z );
411 // Set the w element of a 4-D vector
413 inline Vector4 & setW( float w );
415 // Get the x element of a 4-D vector
417 inline float getX( ) const;
419 // Get the y element of a 4-D vector
421 inline float getY( ) const;
423 // Get the z element of a 4-D vector
425 inline float getZ( ) const;
427 // Get the w element of a 4-D vector
429 inline float getW( ) const;
431 // Set an x, y, z, or w element of a 4-D vector by index
433 inline Vector4 & setElem( int idx, float value );
435 // Get an x, y, z, or w element of a 4-D vector by index
437 inline float getElem( int idx ) const;
439 // Subscripting operator to set or get an element
441 inline VecIdx operator []( int idx );
443 // Subscripting operator to get an element
445 inline float operator []( int idx ) const;
447 // Add two 4-D vectors
449 inline const Vector4 operator +( Vector4 vec ) const;
451 // Subtract a 4-D vector from another 4-D vector
453 inline const Vector4 operator -( Vector4 vec ) const;
455 // Multiply a 4-D vector by a scalar
457 inline const Vector4 operator *( float scalar ) const;
459 // Divide a 4-D vector by a scalar
461 inline const Vector4 operator /( float scalar ) const;
463 // Perform compound assignment and addition with a 4-D vector
465 inline Vector4 & operator +=( Vector4 vec );
467 // Perform compound assignment and subtraction by a 4-D vector
469 inline Vector4 & operator -=( Vector4 vec );
471 // Perform compound assignment and multiplication by a scalar
473 inline Vector4 & operator *=( float scalar );
475 // Perform compound assignment and division by a scalar
477 inline Vector4 & operator /=( float scalar );
479 // Negate all elements of a 4-D vector
481 inline const Vector4 operator -( ) const;
485 static inline const Vector4 xAxis( );
489 static inline const Vector4 yAxis( );
493 static inline const Vector4 zAxis( );
497 static inline const Vector4 wAxis( );
501 // Multiply a 4-D vector by a scalar
503 inline const Vector4 operator *( float scalar, Vector4 vec );
505 // Multiply two 4-D vectors per element
507 inline const Vector4 mulPerElem( Vector4 vec0, Vector4 vec1 );
509 // Divide two 4-D vectors per element
511 // Floating-point behavior matches standard library function divf4.
513 inline const Vector4 divPerElem( Vector4 vec0, Vector4 vec1 );
515 // Compute the reciprocal of a 4-D vector per element
517 // Floating-point behavior matches standard library function recipf4.
519 inline const Vector4 recipPerElem( Vector4 vec );
521 // Compute the square root of a 4-D vector per element
523 // Floating-point behavior matches standard library function sqrtf4.
525 inline const Vector4 sqrtPerElem( Vector4 vec );
527 // Compute the reciprocal square root of a 4-D vector per element
529 // Floating-point behavior matches standard library function rsqrtf4.
531 inline const Vector4 rsqrtPerElem( Vector4 vec );
533 // Compute the absolute value of a 4-D vector per element
535 inline const Vector4 absPerElem( Vector4 vec );
537 // Copy sign from one 4-D vector to another, per element
539 inline const Vector4 copySignPerElem( Vector4 vec0, Vector4 vec1 );
541 // Maximum of two 4-D vectors per element
543 inline const Vector4 maxPerElem( Vector4 vec0, Vector4 vec1 );
545 // Minimum of two 4-D vectors per element
547 inline const Vector4 minPerElem( Vector4 vec0, Vector4 vec1 );
549 // Maximum element of a 4-D vector
551 inline float maxElem( Vector4 vec );
553 // Minimum element of a 4-D vector
555 inline float minElem( Vector4 vec );
557 // Compute the sum of all elements of a 4-D vector
559 inline float sum( Vector4 vec );
561 // Compute the dot product of two 4-D vectors
563 inline float dot( Vector4 vec0, Vector4 vec1 );
565 // Compute the square of the length of a 4-D vector
567 inline float lengthSqr( Vector4 vec );
569 // Compute the length of a 4-D vector
571 inline float length( Vector4 vec );
573 // Normalize a 4-D vector
575 // The result is unpredictable when all elements of vec are at or near zero.
577 inline const Vector4 normalize( Vector4 vec );
579 // Outer product of two 4-D vectors
581 inline const Matrix4 outer( Vector4 vec0, Vector4 vec1 );
583 // Linear interpolation between two 4-D vectors
585 // Does not clamp t between 0 and 1.
587 inline const Vector4 lerp( float t, Vector4 vec0, Vector4 vec1 );
589 // Spherical linear interpolation between two 4-D vectors
591 // The result is unpredictable if the vectors point in opposite directions.
592 // Does not clamp t between 0 and 1.
594 inline const Vector4 slerp( float t, Vector4 unitVec0, Vector4 unitVec1 );
596 // Conditionally select between two 4-D vectors
598 // This function uses a conditional select instruction to avoid a branch.
600 inline const Vector4 select( Vector4 vec0, Vector4 vec1, bool select1 );
602 // Store four 4-D vectors as half-floats
604 inline void storeHalfFloats( Vector4 vec0, Vector4 vec1, Vector4 vec2, Vector4 vec3, vec_ushort8 * twoQuads );
606 #ifdef _VECTORMATH_DEBUG
608 // Print a 4-D vector
610 // Function is only defined when _VECTORMATH_DEBUG is defined.
612 inline void print( Vector4 vec );
614 // Print a 4-D vector and an associated string identifier
616 // Function is only defined when _VECTORMATH_DEBUG is defined.
618 inline void print( Vector4 vec, const char * name );
622 // A 3-D point in array-of-structures format
629 // Default constructor; does no initialization
631 inline Point3( ) { };
633 // Construct a 3-D point from x, y, and z elements
635 inline Point3( float x, float y, float z );
637 // Copy elements from a 3-D vector into a 3-D point
639 explicit inline Point3( Vector3 vec );
641 // Set all elements of a 3-D point to the same scalar value
643 explicit inline Point3( float scalar );
645 // Set vector float data in a 3-D point
647 explicit inline Point3( vec_float4 vf4 );
649 // Get vector float data from a 3-D point
651 inline vec_float4 get128( ) const;
653 // Assign one 3-D point to another
655 inline Point3 & operator =( Point3 pnt );
657 // Set the x element of a 3-D point
659 inline Point3 & setX( float x );
661 // Set the y element of a 3-D point
663 inline Point3 & setY( float y );
665 // Set the z element of a 3-D point
667 inline Point3 & setZ( float z );
669 // Get the x element of a 3-D point
671 inline float getX( ) const;
673 // Get the y element of a 3-D point
675 inline float getY( ) const;
677 // Get the z element of a 3-D point
679 inline float getZ( ) const;
681 // Set an x, y, or z element of a 3-D point by index
683 inline Point3 & setElem( int idx, float value );
685 // Get an x, y, or z element of a 3-D point by index
687 inline float getElem( int idx ) const;
689 // Subscripting operator to set or get an element
691 inline VecIdx operator []( int idx );
693 // Subscripting operator to get an element
695 inline float operator []( int idx ) const;
697 // Subtract a 3-D point from another 3-D point
699 inline const Vector3 operator -( Point3 pnt ) const;
701 // Add a 3-D point to a 3-D vector
703 inline const Point3 operator +( Vector3 vec ) const;
705 // Subtract a 3-D vector from a 3-D point
707 inline const Point3 operator -( Vector3 vec ) const;
709 // Perform compound assignment and addition with a 3-D vector
711 inline Point3 & operator +=( Vector3 vec );
713 // Perform compound assignment and subtraction by a 3-D vector
715 inline Point3 & operator -=( Vector3 vec );
719 // Multiply two 3-D points per element
721 inline const Point3 mulPerElem( Point3 pnt0, Point3 pnt1 );
723 // Divide two 3-D points per element
725 // Floating-point behavior matches standard library function divf4.
727 inline const Point3 divPerElem( Point3 pnt0, Point3 pnt1 );
729 // Compute the reciprocal of a 3-D point per element
731 // Floating-point behavior matches standard library function recipf4.
733 inline const Point3 recipPerElem( Point3 pnt );
735 // Compute the square root of a 3-D point per element
737 // Floating-point behavior matches standard library function sqrtf4.
739 inline const Point3 sqrtPerElem( Point3 pnt );
741 // Compute the reciprocal square root of a 3-D point per element
743 // Floating-point behavior matches standard library function rsqrtf4.
745 inline const Point3 rsqrtPerElem( Point3 pnt );
747 // Compute the absolute value of a 3-D point per element
749 inline const Point3 absPerElem( Point3 pnt );
751 // Copy sign from one 3-D point to another, per element
753 inline const Point3 copySignPerElem( Point3 pnt0, Point3 pnt1 );
755 // Maximum of two 3-D points per element
757 inline const Point3 maxPerElem( Point3 pnt0, Point3 pnt1 );
759 // Minimum of two 3-D points per element
761 inline const Point3 minPerElem( Point3 pnt0, Point3 pnt1 );
763 // Maximum element of a 3-D point
765 inline float maxElem( Point3 pnt );
767 // Minimum element of a 3-D point
769 inline float minElem( Point3 pnt );
771 // Compute the sum of all elements of a 3-D point
773 inline float sum( Point3 pnt );
775 // Apply uniform scale to a 3-D point
777 inline const Point3 scale( Point3 pnt, float scaleVal );
779 // Apply non-uniform scale to a 3-D point
781 inline const Point3 scale( Point3 pnt, Vector3 scaleVec );
783 // Scalar projection of a 3-D point on a unit-length 3-D vector
785 inline float projection( Point3 pnt, Vector3 unitVec );
787 // Compute the square of the distance of a 3-D point from the coordinate-system origin
789 inline float distSqrFromOrigin( Point3 pnt );
791 // Compute the distance of a 3-D point from the coordinate-system origin
793 inline float distFromOrigin( Point3 pnt );
795 // Compute the square of the distance between two 3-D points
797 inline float distSqr( Point3 pnt0, Point3 pnt1 );
799 // Compute the distance between two 3-D points
801 inline float dist( Point3 pnt0, Point3 pnt1 );
803 // Linear interpolation between two 3-D points
805 // Does not clamp t between 0 and 1.
807 inline const Point3 lerp( float t, Point3 pnt0, Point3 pnt1 );
809 // Conditionally select between two 3-D points
811 // This function uses a conditional select instruction to avoid a branch.
813 inline const Point3 select( Point3 pnt0, Point3 pnt1, bool select1 );
815 // Store x, y, and z elements of a 3-D point in the first three words of a quadword.
816 // The value of the fourth word (the word with the highest address) remains unchanged
818 inline void storeXYZ( Point3 pnt, vec_float4 * quad );
820 // Load four three-float 3-D points, stored in three quadwords
822 inline void loadXYZArray( Point3 & pnt0, Point3 & pnt1, Point3 & pnt2, Point3 & pnt3, const vec_float4 * threeQuads );
824 // Store four 3-D points in three quadwords
826 inline void storeXYZArray( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, vec_float4 * threeQuads );
828 // Store eight 3-D points as half-floats
830 inline void storeHalfFloats( Point3 pnt0, Point3 pnt1, Point3 pnt2, Point3 pnt3, Point3 pnt4, Point3 pnt5, Point3 pnt6, Point3 pnt7, vec_ushort8 * threeQuads );
832 #ifdef _VECTORMATH_DEBUG
836 // Function is only defined when _VECTORMATH_DEBUG is defined.
838 inline void print( Point3 pnt );
840 // Print a 3-D point and an associated string identifier
842 // Function is only defined when _VECTORMATH_DEBUG is defined.
844 inline void print( Point3 pnt, const char * name );
848 // A quaternion in array-of-structures format
855 // Default constructor; does no initialization
859 // Construct a quaternion from x, y, z, and w elements
861 inline Quat( float x, float y, float z, float w );
863 // Construct a quaternion from a 3-D vector and a scalar
865 inline Quat( Vector3 xyz, float w );
867 // Copy elements from a 4-D vector into a quaternion
869 explicit inline Quat( Vector4 vec );
871 // Convert a rotation matrix to a unit-length quaternion
873 explicit inline Quat( const Matrix3 & rotMat );
875 // Set all elements of a quaternion to the same scalar value
877 explicit inline Quat( float scalar );
879 // Set vector float data in a quaternion
881 explicit inline Quat( vec_float4 vf4 );
883 // Get vector float data from a quaternion
885 inline vec_float4 get128( ) const;
887 // Assign one quaternion to another
889 inline Quat & operator =( Quat quat );
891 // Set the x, y, and z elements of a quaternion
893 // This function does not change the w element.
895 inline Quat & setXYZ( Vector3 vec );
897 // Get the x, y, and z elements of a quaternion
899 inline const Vector3 getXYZ( ) const;
901 // Set the x element of a quaternion
903 inline Quat & setX( float x );
905 // Set the y element of a quaternion
907 inline Quat & setY( float y );
909 // Set the z element of a quaternion
911 inline Quat & setZ( float z );
913 // Set the w element of a quaternion
915 inline Quat & setW( float w );
917 // Get the x element of a quaternion
919 inline float getX( ) const;
921 // Get the y element of a quaternion
923 inline float getY( ) const;
925 // Get the z element of a quaternion
927 inline float getZ( ) const;
929 // Get the w element of a quaternion
931 inline float getW( ) const;
933 // Set an x, y, z, or w element of a quaternion by index
935 inline Quat & setElem( int idx, float value );
937 // Get an x, y, z, or w element of a quaternion by index
939 inline float getElem( int idx ) const;
941 // Subscripting operator to set or get an element
943 inline VecIdx operator []( int idx );
945 // Subscripting operator to get an element
947 inline float operator []( int idx ) const;
949 // Add two quaternions
951 inline const Quat operator +( Quat quat ) const;
953 // Subtract a quaternion from another quaternion
955 inline const Quat operator -( Quat quat ) const;
957 // Multiply two quaternions
959 inline const Quat operator *( Quat quat ) const;
961 // Multiply a quaternion by a scalar
963 inline const Quat operator *( float scalar ) const;
965 // Divide a quaternion by a scalar
967 inline const Quat operator /( float scalar ) const;
969 // Perform compound assignment and addition with a quaternion
971 inline Quat & operator +=( Quat quat );
973 // Perform compound assignment and subtraction by a quaternion
975 inline Quat & operator -=( Quat quat );
977 // Perform compound assignment and multiplication by a quaternion
979 inline Quat & operator *=( Quat quat );
981 // Perform compound assignment and multiplication by a scalar
983 inline Quat & operator *=( float scalar );
985 // Perform compound assignment and division by a scalar
987 inline Quat & operator /=( float scalar );
989 // Negate all elements of a quaternion
991 inline const Quat operator -( ) const;
993 // Construct an identity quaternion
995 static inline const Quat identity( );
997 // Construct a quaternion to rotate between two unit-length 3-D vectors
999 // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions.
1001 static inline const Quat rotation( Vector3 unitVec0, Vector3 unitVec1 );
1003 // Construct a quaternion to rotate around a unit-length 3-D vector
1005 static inline const Quat rotation( float radians, Vector3 unitVec );
1007 // Construct a quaternion to rotate around the x axis
1009 static inline const Quat rotationX( float radians );
1011 // Construct a quaternion to rotate around the y axis
1013 static inline const Quat rotationY( float radians );
1015 // Construct a quaternion to rotate around the z axis
1017 static inline const Quat rotationZ( float radians );
1021 // Multiply a quaternion by a scalar
1023 inline const Quat operator *( float scalar, Quat quat );
1025 // Compute the conjugate of a quaternion
1027 inline const Quat conj( Quat quat );
1029 // Use a unit-length quaternion to rotate a 3-D vector
1031 inline const Vector3 rotate( Quat unitQuat, Vector3 vec );
1033 // Compute the dot product of two quaternions
1035 inline float dot( Quat quat0, Quat quat1 );
1037 // Compute the norm of a quaternion
1039 inline float norm( Quat quat );
1041 // Compute the length of a quaternion
1043 inline float length( Quat quat );
1045 // Normalize a quaternion
1047 // The result is unpredictable when all elements of quat are at or near zero.
1049 inline const Quat normalize( Quat quat );
1051 // Linear interpolation between two quaternions
1053 // Does not clamp t between 0 and 1.
1055 inline const Quat lerp( float t, Quat quat0, Quat quat1 );
1057 // Spherical linear interpolation between two quaternions
1059 // Interpolates along the shortest path between orientations.
1060 // Does not clamp t between 0 and 1.
1062 inline const Quat slerp( float t, Quat unitQuat0, Quat unitQuat1 );
1064 // Spherical quadrangle interpolation
1066 inline const Quat squad( float t, Quat unitQuat0, Quat unitQuat1, Quat unitQuat2, Quat unitQuat3 );
1068 // Conditionally select between two quaternions
1070 // This function uses a conditional select instruction to avoid a branch.
1072 inline const Quat select( Quat quat0, Quat quat1, bool select1 );
1074 #ifdef _VECTORMATH_DEBUG
1076 // Print a quaternion
1078 // Function is only defined when _VECTORMATH_DEBUG is defined.
1080 inline void print( Quat quat );
1082 // Print a quaternion and an associated string identifier
1084 // Function is only defined when _VECTORMATH_DEBUG is defined.
1086 inline void print( Quat quat, const char * name );
1090 // A 3x3 matrix in array-of-structures format
1099 // Default constructor; does no initialization
1101 inline Matrix3( ) { };
1103 // Copy a 3x3 matrix
1105 inline Matrix3( const Matrix3 & mat );
1107 // Construct a 3x3 matrix containing the specified columns
1109 inline Matrix3( Vector3 col0, Vector3 col1, Vector3 col2 );
1111 // Construct a 3x3 rotation matrix from a unit-length quaternion
1113 explicit inline Matrix3( Quat unitQuat );
1115 // Set all elements of a 3x3 matrix to the same scalar value
1117 explicit inline Matrix3( float scalar );
1119 // Assign one 3x3 matrix to another
1121 inline Matrix3 & operator =( const Matrix3 & mat );
1123 // Set column 0 of a 3x3 matrix
1125 inline Matrix3 & setCol0( Vector3 col0 );
1127 // Set column 1 of a 3x3 matrix
1129 inline Matrix3 & setCol1( Vector3 col1 );
1131 // Set column 2 of a 3x3 matrix
1133 inline Matrix3 & setCol2( Vector3 col2 );
1135 // Get column 0 of a 3x3 matrix
1137 inline const Vector3 getCol0( ) const;
1139 // Get column 1 of a 3x3 matrix
1141 inline const Vector3 getCol1( ) const;
1143 // Get column 2 of a 3x3 matrix
1145 inline const Vector3 getCol2( ) const;
1147 // Set the column of a 3x3 matrix referred to by the specified index
1149 inline Matrix3 & setCol( int col, Vector3 vec );
1151 // Set the row of a 3x3 matrix referred to by the specified index
1153 inline Matrix3 & setRow( int row, Vector3 vec );
1155 // Get the column of a 3x3 matrix referred to by the specified index
1157 inline const Vector3 getCol( int col ) const;
1159 // Get the row of a 3x3 matrix referred to by the specified index
1161 inline const Vector3 getRow( int row ) const;
1163 // Subscripting operator to set or get a column
1165 inline Vector3 & operator []( int col );
1167 // Subscripting operator to get a column
1169 inline const Vector3 operator []( int col ) const;
1171 // Set the element of a 3x3 matrix referred to by column and row indices
1173 inline Matrix3 & setElem( int col, int row, float val );
1175 // Get the element of a 3x3 matrix referred to by column and row indices
1177 inline float getElem( int col, int row ) const;
1179 // Add two 3x3 matrices
1181 inline const Matrix3 operator +( const Matrix3 & mat ) const;
1183 // Subtract a 3x3 matrix from another 3x3 matrix
1185 inline const Matrix3 operator -( const Matrix3 & mat ) const;
1187 // Negate all elements of a 3x3 matrix
1189 inline const Matrix3 operator -( ) const;
1191 // Multiply a 3x3 matrix by a scalar
1193 inline const Matrix3 operator *( float scalar ) const;
1195 // Multiply a 3x3 matrix by a 3-D vector
1197 inline const Vector3 operator *( Vector3 vec ) const;
1199 // Multiply two 3x3 matrices
1201 inline const Matrix3 operator *( const Matrix3 & mat ) const;
1203 // Perform compound assignment and addition with a 3x3 matrix
1205 inline Matrix3 & operator +=( const Matrix3 & mat );
1207 // Perform compound assignment and subtraction by a 3x3 matrix
1209 inline Matrix3 & operator -=( const Matrix3 & mat );
1211 // Perform compound assignment and multiplication by a scalar
1213 inline Matrix3 & operator *=( float scalar );
1215 // Perform compound assignment and multiplication by a 3x3 matrix
1217 inline Matrix3 & operator *=( const Matrix3 & mat );
1219 // Construct an identity 3x3 matrix
1221 static inline const Matrix3 identity( );
1223 // Construct a 3x3 matrix to rotate around the x axis
1225 static inline const Matrix3 rotationX( float radians );
1227 // Construct a 3x3 matrix to rotate around the y axis
1229 static inline const Matrix3 rotationY( float radians );
1231 // Construct a 3x3 matrix to rotate around the z axis
1233 static inline const Matrix3 rotationZ( float radians );
1235 // Construct a 3x3 matrix to rotate around the x, y, and z axes
1237 static inline const Matrix3 rotationZYX( Vector3 radiansXYZ );
1239 // Construct a 3x3 matrix to rotate around a unit-length 3-D vector
1241 static inline const Matrix3 rotation( float radians, Vector3 unitVec );
1243 // Construct a rotation matrix from a unit-length quaternion
1245 static inline const Matrix3 rotation( Quat unitQuat );
1247 // Construct a 3x3 matrix to perform scaling
1249 static inline const Matrix3 scale( Vector3 scaleVec );
1252 // Multiply a 3x3 matrix by a scalar
1254 inline const Matrix3 operator *( float scalar, const Matrix3 & mat );
1256 // Append (post-multiply) a scale transformation to a 3x3 matrix
1258 // Faster than creating and multiplying a scale transformation matrix.
1260 inline const Matrix3 appendScale( const Matrix3 & mat, Vector3 scaleVec );
1262 // Prepend (pre-multiply) a scale transformation to a 3x3 matrix
1264 // Faster than creating and multiplying a scale transformation matrix.
1266 inline const Matrix3 prependScale( Vector3 scaleVec, const Matrix3 & mat );
1268 // Multiply two 3x3 matrices per element
1270 inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 );
1272 // Compute the absolute value of a 3x3 matrix per element
1274 inline const Matrix3 absPerElem( const Matrix3 & mat );
1276 // Transpose of a 3x3 matrix
1278 inline const Matrix3 transpose( const Matrix3 & mat );
1280 // Compute the inverse of a 3x3 matrix
1282 // Result is unpredictable when the determinant of mat is equal to or near 0.
1284 inline const Matrix3 inverse( const Matrix3 & mat );
1286 // Determinant of a 3x3 matrix
1288 inline float determinant( const Matrix3 & mat );
1290 // Conditionally select between two 3x3 matrices
1292 // This function uses a conditional select instruction to avoid a branch.
1294 inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 );
1296 #ifdef _VECTORMATH_DEBUG
1298 // Print a 3x3 matrix
1300 // Function is only defined when _VECTORMATH_DEBUG is defined.
1302 inline void print( const Matrix3 & mat );
1304 // Print a 3x3 matrix and an associated string identifier
1306 // Function is only defined when _VECTORMATH_DEBUG is defined.
1308 inline void print( const Matrix3 & mat, const char * name );
1312 // A 4x4 matrix in array-of-structures format
1322 // Default constructor; does no initialization
1324 inline Matrix4( ) { };
1326 // Copy a 4x4 matrix
1328 inline Matrix4( const Matrix4 & mat );
1330 // Construct a 4x4 matrix containing the specified columns
1332 inline Matrix4( Vector4 col0, Vector4 col1, Vector4 col2, Vector4 col3 );
1334 // Construct a 4x4 matrix from a 3x4 transformation matrix
1336 explicit inline Matrix4( const Transform3 & mat );
1338 // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector
1340 inline Matrix4( const Matrix3 & mat, Vector3 translateVec );
1342 // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector
1344 inline Matrix4( Quat unitQuat, Vector3 translateVec );
1346 // Set all elements of a 4x4 matrix to the same scalar value
1348 explicit inline Matrix4( float scalar );
1350 // Assign one 4x4 matrix to another
1352 inline Matrix4 & operator =( const Matrix4 & mat );
1354 // Set the upper-left 3x3 submatrix
1356 // This function does not change the bottom row elements.
1358 inline Matrix4 & setUpper3x3( const Matrix3 & mat3 );
1360 // Get the upper-left 3x3 submatrix of a 4x4 matrix
1362 inline const Matrix3 getUpper3x3( ) const;
1364 // Set translation component
1366 // This function does not change the bottom row elements.
1368 inline Matrix4 & setTranslation( Vector3 translateVec );
1370 // Get the translation component of a 4x4 matrix
1372 inline const Vector3 getTranslation( ) const;
1374 // Set column 0 of a 4x4 matrix
1376 inline Matrix4 & setCol0( Vector4 col0 );
1378 // Set column 1 of a 4x4 matrix
1380 inline Matrix4 & setCol1( Vector4 col1 );
1382 // Set column 2 of a 4x4 matrix
1384 inline Matrix4 & setCol2( Vector4 col2 );
1386 // Set column 3 of a 4x4 matrix
1388 inline Matrix4 & setCol3( Vector4 col3 );
1390 // Get column 0 of a 4x4 matrix
1392 inline const Vector4 getCol0( ) const;
1394 // Get column 1 of a 4x4 matrix
1396 inline const Vector4 getCol1( ) const;
1398 // Get column 2 of a 4x4 matrix
1400 inline const Vector4 getCol2( ) const;
1402 // Get column 3 of a 4x4 matrix
1404 inline const Vector4 getCol3( ) const;
1406 // Set the column of a 4x4 matrix referred to by the specified index
1408 inline Matrix4 & setCol( int col, Vector4 vec );
1410 // Set the row of a 4x4 matrix referred to by the specified index
1412 inline Matrix4 & setRow( int row, Vector4 vec );
1414 // Get the column of a 4x4 matrix referred to by the specified index
1416 inline const Vector4 getCol( int col ) const;
1418 // Get the row of a 4x4 matrix referred to by the specified index
1420 inline const Vector4 getRow( int row ) const;
1422 // Subscripting operator to set or get a column
1424 inline Vector4 & operator []( int col );
1426 // Subscripting operator to get a column
1428 inline const Vector4 operator []( int col ) const;
1430 // Set the element of a 4x4 matrix referred to by column and row indices
1432 inline Matrix4 & setElem( int col, int row, float val );
1434 // Get the element of a 4x4 matrix referred to by column and row indices
1436 inline float getElem( int col, int row ) const;
1438 // Add two 4x4 matrices
1440 inline const Matrix4 operator +( const Matrix4 & mat ) const;
1442 // Subtract a 4x4 matrix from another 4x4 matrix
1444 inline const Matrix4 operator -( const Matrix4 & mat ) const;
1446 // Negate all elements of a 4x4 matrix
1448 inline const Matrix4 operator -( ) const;
1450 // Multiply a 4x4 matrix by a scalar
1452 inline const Matrix4 operator *( float scalar ) const;
1454 // Multiply a 4x4 matrix by a 4-D vector
1456 inline const Vector4 operator *( Vector4 vec ) const;
1458 // Multiply a 4x4 matrix by a 3-D vector
1460 inline const Vector4 operator *( Vector3 vec ) const;
1462 // Multiply a 4x4 matrix by a 3-D point
1464 inline const Vector4 operator *( Point3 pnt ) const;
1466 // Multiply two 4x4 matrices
1468 inline const Matrix4 operator *( const Matrix4 & mat ) const;
1470 // Multiply a 4x4 matrix by a 3x4 transformation matrix
1472 inline const Matrix4 operator *( const Transform3 & tfrm ) const;
1474 // Perform compound assignment and addition with a 4x4 matrix
1476 inline Matrix4 & operator +=( const Matrix4 & mat );
1478 // Perform compound assignment and subtraction by a 4x4 matrix
1480 inline Matrix4 & operator -=( const Matrix4 & mat );
1482 // Perform compound assignment and multiplication by a scalar
1484 inline Matrix4 & operator *=( float scalar );
1486 // Perform compound assignment and multiplication by a 4x4 matrix
1488 inline Matrix4 & operator *=( const Matrix4 & mat );
1490 // Perform compound assignment and multiplication by a 3x4 transformation matrix
1492 inline Matrix4 & operator *=( const Transform3 & tfrm );
1494 // Construct an identity 4x4 matrix
1496 static inline const Matrix4 identity( );
1498 // Construct a 4x4 matrix to rotate around the x axis
1500 static inline const Matrix4 rotationX( float radians );
1502 // Construct a 4x4 matrix to rotate around the y axis
1504 static inline const Matrix4 rotationY( float radians );
1506 // Construct a 4x4 matrix to rotate around the z axis
1508 static inline const Matrix4 rotationZ( float radians );
1510 // Construct a 4x4 matrix to rotate around the x, y, and z axes
1512 static inline const Matrix4 rotationZYX( Vector3 radiansXYZ );
1514 // Construct a 4x4 matrix to rotate around a unit-length 3-D vector
1516 static inline const Matrix4 rotation( float radians, Vector3 unitVec );
1518 // Construct a rotation matrix from a unit-length quaternion
1520 static inline const Matrix4 rotation( Quat unitQuat );
1522 // Construct a 4x4 matrix to perform scaling
1524 static inline const Matrix4 scale( Vector3 scaleVec );
1526 // Construct a 4x4 matrix to perform translation
1528 static inline const Matrix4 translation( Vector3 translateVec );
1530 // Construct viewing matrix based on eye position, position looked at, and up direction
1532 static inline const Matrix4 lookAt( Point3 eyePos, Point3 lookAtPos, Vector3 upVec );
1534 // Construct a perspective projection matrix
1536 static inline const Matrix4 perspective( float fovyRadians, float aspect, float zNear, float zFar );
1538 // Construct a perspective projection matrix based on frustum
1540 static inline const Matrix4 frustum( float left, float right, float bottom, float top, float zNear, float zFar );
1542 // Construct an orthographic projection matrix
1544 static inline const Matrix4 orthographic( float left, float right, float bottom, float top, float zNear, float zFar );
1547 // Multiply a 4x4 matrix by a scalar
1549 inline const Matrix4 operator *( float scalar, const Matrix4 & mat );
1551 // Append (post-multiply) a scale transformation to a 4x4 matrix
1553 // Faster than creating and multiplying a scale transformation matrix.
1555 inline const Matrix4 appendScale( const Matrix4 & mat, Vector3 scaleVec );
1557 // Prepend (pre-multiply) a scale transformation to a 4x4 matrix
1559 // Faster than creating and multiplying a scale transformation matrix.
1561 inline const Matrix4 prependScale( Vector3 scaleVec, const Matrix4 & mat );
1563 // Multiply two 4x4 matrices per element
1565 inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 );
1567 // Compute the absolute value of a 4x4 matrix per element
1569 inline const Matrix4 absPerElem( const Matrix4 & mat );
1571 // Transpose of a 4x4 matrix
1573 inline const Matrix4 transpose( const Matrix4 & mat );
1575 // Compute the inverse of a 4x4 matrix
1577 // Result is unpredictable when the determinant of mat is equal to or near 0.
1579 inline const Matrix4 inverse( const Matrix4 & mat );
1581 // Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix
1583 // This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions. The result is unpredictable when the determinant of mat is equal to or near 0.
1585 inline const Matrix4 affineInverse( const Matrix4 & mat );
1587 // Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix
1589 // This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions.
1591 inline const Matrix4 orthoInverse( const Matrix4 & mat );
1593 // Determinant of a 4x4 matrix
1595 inline float determinant( const Matrix4 & mat );
1597 // Conditionally select between two 4x4 matrices
1599 // This function uses a conditional select instruction to avoid a branch.
1601 inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 );
1603 #ifdef _VECTORMATH_DEBUG
1605 // Print a 4x4 matrix
1607 // Function is only defined when _VECTORMATH_DEBUG is defined.
1609 inline void print( const Matrix4 & mat );
1611 // Print a 4x4 matrix and an associated string identifier
1613 // Function is only defined when _VECTORMATH_DEBUG is defined.
1615 inline void print( const Matrix4 & mat, const char * name );
1619 // A 3x4 transformation matrix in array-of-structures format
1629 // Default constructor; does no initialization
1631 inline Transform3( ) { };
1633 // Copy a 3x4 transformation matrix
1635 inline Transform3( const Transform3 & tfrm );
1637 // Construct a 3x4 transformation matrix containing the specified columns
1639 inline Transform3( Vector3 col0, Vector3 col1, Vector3 col2, Vector3 col3 );
1641 // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector
1643 inline Transform3( const Matrix3 & tfrm, Vector3 translateVec );
1645 // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector
1647 inline Transform3( Quat unitQuat, Vector3 translateVec );
1649 // Set all elements of a 3x4 transformation matrix to the same scalar value
1651 explicit inline Transform3( float scalar );
1653 // Assign one 3x4 transformation matrix to another
1655 inline Transform3 & operator =( const Transform3 & tfrm );
1657 // Set the upper-left 3x3 submatrix
1659 inline Transform3 & setUpper3x3( const Matrix3 & mat3 );
1661 // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix
1663 inline const Matrix3 getUpper3x3( ) const;
1665 // Set translation component
1667 inline Transform3 & setTranslation( Vector3 translateVec );
1669 // Get the translation component of a 3x4 transformation matrix
1671 inline const Vector3 getTranslation( ) const;
1673 // Set column 0 of a 3x4 transformation matrix
1675 inline Transform3 & setCol0( Vector3 col0 );
1677 // Set column 1 of a 3x4 transformation matrix
1679 inline Transform3 & setCol1( Vector3 col1 );
1681 // Set column 2 of a 3x4 transformation matrix
1683 inline Transform3 & setCol2( Vector3 col2 );
1685 // Set column 3 of a 3x4 transformation matrix
1687 inline Transform3 & setCol3( Vector3 col3 );
1689 // Get column 0 of a 3x4 transformation matrix
1691 inline const Vector3 getCol0( ) const;
1693 // Get column 1 of a 3x4 transformation matrix
1695 inline const Vector3 getCol1( ) const;
1697 // Get column 2 of a 3x4 transformation matrix
1699 inline const Vector3 getCol2( ) const;
1701 // Get column 3 of a 3x4 transformation matrix
1703 inline const Vector3 getCol3( ) const;
1705 // Set the column of a 3x4 transformation matrix referred to by the specified index
1707 inline Transform3 & setCol( int col, Vector3 vec );
1709 // Set the row of a 3x4 transformation matrix referred to by the specified index
1711 inline Transform3 & setRow( int row, Vector4 vec );
1713 // Get the column of a 3x4 transformation matrix referred to by the specified index
1715 inline const Vector3 getCol( int col ) const;
1717 // Get the row of a 3x4 transformation matrix referred to by the specified index
1719 inline const Vector4 getRow( int row ) const;
1721 // Subscripting operator to set or get a column
1723 inline Vector3 & operator []( int col );
1725 // Subscripting operator to get a column
1727 inline const Vector3 operator []( int col ) const;
1729 // Set the element of a 3x4 transformation matrix referred to by column and row indices
1731 inline Transform3 & setElem( int col, int row, float val );
1733 // Get the element of a 3x4 transformation matrix referred to by column and row indices
1735 inline float getElem( int col, int row ) const;
1737 // Multiply a 3x4 transformation matrix by a 3-D vector
1739 inline const Vector3 operator *( Vector3 vec ) const;
1741 // Multiply a 3x4 transformation matrix by a 3-D point
1743 inline const Point3 operator *( Point3 pnt ) const;
1745 // Multiply two 3x4 transformation matrices
1747 inline const Transform3 operator *( const Transform3 & tfrm ) const;
1749 // Perform compound assignment and multiplication by a 3x4 transformation matrix
1751 inline Transform3 & operator *=( const Transform3 & tfrm );
1753 // Construct an identity 3x4 transformation matrix
1755 static inline const Transform3 identity( );
1757 // Construct a 3x4 transformation matrix to rotate around the x axis
1759 static inline const Transform3 rotationX( float radians );
1761 // Construct a 3x4 transformation matrix to rotate around the y axis
1763 static inline const Transform3 rotationY( float radians );
1765 // Construct a 3x4 transformation matrix to rotate around the z axis
1767 static inline const Transform3 rotationZ( float radians );
1769 // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes
1771 static inline const Transform3 rotationZYX( Vector3 radiansXYZ );
1773 // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector
1775 static inline const Transform3 rotation( float radians, Vector3 unitVec );
1777 // Construct a rotation matrix from a unit-length quaternion
1779 static inline const Transform3 rotation( Quat unitQuat );
1781 // Construct a 3x4 transformation matrix to perform scaling
1783 static inline const Transform3 scale( Vector3 scaleVec );
1785 // Construct a 3x4 transformation matrix to perform translation
1787 static inline const Transform3 translation( Vector3 translateVec );
1790 // Append (post-multiply) a scale transformation to a 3x4 transformation matrix
1792 // Faster than creating and multiplying a scale transformation matrix.
1794 inline const Transform3 appendScale( const Transform3 & tfrm, Vector3 scaleVec );
1796 // Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix
1798 // Faster than creating and multiplying a scale transformation matrix.
1800 inline const Transform3 prependScale( Vector3 scaleVec, const Transform3 & tfrm );
1802 // Multiply two 3x4 transformation matrices per element
1804 inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 );
1806 // Compute the absolute value of a 3x4 transformation matrix per element
1808 inline const Transform3 absPerElem( const Transform3 & tfrm );
1810 // Inverse of a 3x4 transformation matrix
1812 // Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0.
1814 inline const Transform3 inverse( const Transform3 & tfrm );
1816 // Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix
1818 // This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions.
1820 inline const Transform3 orthoInverse( const Transform3 & tfrm );
1822 // Conditionally select between two 3x4 transformation matrices
1824 // This function uses a conditional select instruction to avoid a branch.
1826 inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 );
1828 #ifdef _VECTORMATH_DEBUG
1830 // Print a 3x4 transformation matrix
1832 // Function is only defined when _VECTORMATH_DEBUG is defined.
1834 inline void print( const Transform3 & tfrm );
1836 // Print a 3x4 transformation matrix and an associated string identifier
1838 // Function is only defined when _VECTORMATH_DEBUG is defined.
1840 inline void print( const Transform3 & tfrm, const char * name );
1845 } // namespace Vectormath
1847 #include "vec_aos.h"
1848 #include "quat_aos.h"
1849 #include "mat_aos.h"