2 Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
\r
5 Redistribution and use in source and binary forms,
\r
6 with or without modification, are permitted provided that the
\r
7 following conditions are met:
\r
8 * Redistributions of source code must retain the above copyright
\r
9 notice, this list of conditions and the following disclaimer.
\r
10 * Redistributions in binary form must reproduce the above copyright
\r
11 notice, this list of conditions and the following disclaimer in the
\r
12 documentation and/or other materials provided with the distribution.
\r
13 * Neither the name of the Sony Computer Entertainment Inc nor the names
\r
14 of its contributors may be used to endorse or promote products derived
\r
15 from this software without specific prior written permission.
\r
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
\r
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\r
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
\r
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
\r
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
\r
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
\r
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
\r
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
\r
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
27 POSSIBILITY OF SUCH DAMAGE.
\r
30 #ifndef _VECTORMATH_AOS_CPP_SCALAR_H
\r
31 #define _VECTORMATH_AOS_CPP_SCALAR_H
\r
35 #ifdef _VECTORMATH_DEBUG
\r
39 namespace Vectormath {
\r
43 //-----------------------------------------------------------------------------
\r
44 // Forward Declarations
\r
55 // A 3-D vector in array-of-structures format
\r
62 // ARA begin code change
\r
63 // Removed #ifndef __GNUC__ condition
\r
68 // Default constructor; does no initialization
\r
70 // ARA begin insert new code
\r
71 // Added explicit initialization of d = 0.0f;
\r
72 inline Vector3( ) { d = 0.0f; };
\r
75 // Copy a 3-D vector
\r
77 inline Vector3( const Vector3 & vec );
\r
79 // Construct a 3-D vector from x, y, and z elements
\r
81 inline Vector3( float x, float y, float z );
\r
83 // Copy elements from a 3-D point into a 3-D vector
\r
85 explicit inline Vector3( const Point3 & pnt );
\r
87 // Set all elements of a 3-D vector to the same scalar value
\r
89 explicit inline Vector3( float scalar );
\r
91 // Assign one 3-D vector to another
\r
93 inline Vector3 & operator =( const Vector3 & vec );
\r
95 // Set the x element of a 3-D vector
\r
97 inline Vector3 & setX( float x );
\r
99 // Set the y element of a 3-D vector
\r
101 inline Vector3 & setY( float y );
\r
103 // Set the z element of a 3-D vector
\r
105 inline Vector3 & setZ( float z );
\r
107 // Get the x element of a 3-D vector
\r
109 inline float getX( ) const;
\r
111 // Get the y element of a 3-D vector
\r
113 inline float getY( ) const;
\r
115 // Get the z element of a 3-D vector
\r
117 inline float getZ( ) const;
\r
119 // Set an x, y, or z element of a 3-D vector by index
\r
121 inline Vector3 & setElem( int idx, float value );
\r
123 // Get an x, y, or z element of a 3-D vector by index
\r
125 inline float getElem( int idx ) const;
\r
127 // Subscripting operator to set or get an element
\r
129 inline float & operator []( int idx );
\r
131 // Subscripting operator to get an element
\r
133 inline float operator []( int idx ) const;
\r
135 // Add two 3-D vectors
\r
137 inline const Vector3 operator +( const Vector3 & vec ) const;
\r
139 // Subtract a 3-D vector from another 3-D vector
\r
141 inline const Vector3 operator -( const Vector3 & vec ) const;
\r
143 // Add a 3-D vector to a 3-D point
\r
145 inline const Point3 operator +( const Point3 & pnt ) const;
\r
147 // Multiply a 3-D vector by a scalar
\r
149 inline const Vector3 operator *( float scalar ) const;
\r
151 // Divide a 3-D vector by a scalar
\r
153 inline const Vector3 operator /( float scalar ) const;
\r
155 // Perform compound assignment and addition with a 3-D vector
\r
157 inline Vector3 & operator +=( const Vector3 & vec );
\r
159 // Perform compound assignment and subtraction by a 3-D vector
\r
161 inline Vector3 & operator -=( const Vector3 & vec );
\r
163 // Perform compound assignment and multiplication by a scalar
\r
165 inline Vector3 & operator *=( float scalar );
\r
167 // Perform compound assignment and division by a scalar
\r
169 inline Vector3 & operator /=( float scalar );
\r
171 // Negate all elements of a 3-D vector
\r
173 inline const Vector3 operator -( ) const;
\r
175 // Construct x axis
\r
177 static inline const Vector3 xAxis( );
\r
179 // Construct y axis
\r
181 static inline const Vector3 yAxis( );
\r
183 // Construct z axis
\r
185 static inline const Vector3 zAxis( );
\r
189 __attribute__ ((aligned(16)))
\r
193 // Multiply a 3-D vector by a scalar
\r
195 inline const Vector3 operator *( float scalar, const Vector3 & vec );
\r
197 // Multiply two 3-D vectors per element
\r
199 inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 );
\r
201 // Divide two 3-D vectors per element
\r
203 // Floating-point behavior matches standard library function divf4.
\r
205 inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 );
\r
207 // Compute the reciprocal of a 3-D vector per element
\r
209 // Floating-point behavior matches standard library function recipf4.
\r
211 inline const Vector3 recipPerElem( const Vector3 & vec );
\r
213 // Compute the square root of a 3-D vector per element
\r
215 // Floating-point behavior matches standard library function sqrtf4.
\r
217 inline const Vector3 sqrtPerElem( const Vector3 & vec );
\r
219 // Compute the reciprocal square root of a 3-D vector per element
\r
221 // Floating-point behavior matches standard library function rsqrtf4.
\r
223 inline const Vector3 rsqrtPerElem( const Vector3 & vec );
\r
225 // Compute the absolute value of a 3-D vector per element
\r
227 inline const Vector3 absPerElem( const Vector3 & vec );
\r
229 // Copy sign from one 3-D vector to another, per element
\r
231 inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 );
\r
233 // Maximum of two 3-D vectors per element
\r
235 inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 );
\r
237 // Minimum of two 3-D vectors per element
\r
239 inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 );
\r
241 // Maximum element of a 3-D vector
\r
243 inline float maxElem( const Vector3 & vec );
\r
245 // Minimum element of a 3-D vector
\r
247 inline float minElem( const Vector3 & vec );
\r
249 // Compute the sum of all elements of a 3-D vector
\r
251 inline float sum( const Vector3 & vec );
\r
253 // Compute the dot product of two 3-D vectors
\r
255 inline float dot( const Vector3 & vec0, const Vector3 & vec1 );
\r
257 // Compute the square of the length of a 3-D vector
\r
259 inline float lengthSqr( const Vector3 & vec );
\r
261 // Compute the length of a 3-D vector
\r
263 inline float length( const Vector3 & vec );
\r
265 // Normalize a 3-D vector
\r
267 // The result is unpredictable when all elements of vec are at or near zero.
\r
269 inline const Vector3 normalize( const Vector3 & vec );
\r
271 // Compute cross product of two 3-D vectors
\r
273 inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 );
\r
275 // Outer product of two 3-D vectors
\r
277 inline const Matrix3 outer( const Vector3 & vec0, const Vector3 & vec1 );
\r
279 // Pre-multiply a row vector by a 3x3 matrix
\r
281 inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat );
\r
283 // Cross-product matrix of a 3-D vector
\r
285 inline const Matrix3 crossMatrix( const Vector3 & vec );
\r
287 // Create cross-product matrix and multiply
\r
289 // Faster than separately creating a cross-product matrix and multiplying.
\r
291 inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat );
\r
293 // Linear interpolation between two 3-D vectors
\r
295 // Does not clamp t between 0 and 1.
\r
297 inline const Vector3 lerp( float t, const Vector3 & vec0, const Vector3 & vec1 );
\r
299 // Spherical linear interpolation between two 3-D vectors
\r
301 // The result is unpredictable if the vectors point in opposite directions.
\r
302 // Does not clamp t between 0 and 1.
\r
304 inline const Vector3 slerp( float t, const Vector3 & unitVec0, const Vector3 & unitVec1 );
\r
306 // Conditionally select between two 3-D vectors
\r
308 inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, bool select1 );
\r
310 // Load x, y, and z elements from the first three words of a float array.
\r
313 inline void loadXYZ( Vector3 & vec, const float * fptr );
\r
315 // Store x, y, and z elements of a 3-D vector in the first three words of a float array.
\r
316 // Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed
\r
318 inline void storeXYZ( const Vector3 & vec, float * fptr );
\r
320 // Load three-half-floats as a 3-D vector
\r
322 // This transformation does not support either denormalized numbers or NaNs.
\r
324 inline void loadHalfFloats( Vector3 & vec, const unsigned short * hfptr );
\r
326 // Store a 3-D vector as half-floats. Memory area of previous 16 bytes and next 32 bytes from <code><i>hfptr</i></code> might be accessed.
\r
328 // This transformation does not support either denormalized numbers or NaNs. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed.
\r
330 inline void storeHalfFloats( const Vector3 & vec, unsigned short * hfptr );
\r
332 #ifdef _VECTORMATH_DEBUG
\r
334 // Print a 3-D vector
\r
336 // Function is only defined when _VECTORMATH_DEBUG is defined.
\r
338 inline void print( const Vector3 & vec );
\r
340 // Print a 3-D vector and an associated string identifier
\r
342 // Function is only defined when _VECTORMATH_DEBUG is defined.
\r
344 inline void print( const Vector3 & vec, const char * name );
\r
348 // A 4-D vector in array-of-structures format
\r
358 // Default constructor; does no initialization
\r
360 inline Vector4( ) { };
\r
362 // Copy a 4-D vector
\r
364 inline Vector4( const Vector4 & vec );
\r
366 // Construct a 4-D vector from x, y, z, and w elements
\r
368 inline Vector4( float x, float y, float z, float w );
\r
370 // Construct a 4-D vector from a 3-D vector and a scalar
\r
372 inline Vector4( const Vector3 & xyz, float w );
\r
374 // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0
\r
376 explicit inline Vector4( const Vector3 & vec );
\r
378 // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1
\r
380 explicit inline Vector4( const Point3 & pnt );
\r
382 // Copy elements from a quaternion into a 4-D vector
\r
384 explicit inline Vector4( const Quat & quat );
\r
386 // Set all elements of a 4-D vector to the same scalar value
\r
388 explicit inline Vector4( float scalar );
\r
390 // Assign one 4-D vector to another
\r
392 inline Vector4 & operator =( const Vector4 & vec );
\r
394 // Set the x, y, and z elements of a 4-D vector
\r
396 // This function does not change the w element.
\r
398 inline Vector4 & setXYZ( const Vector3 & vec );
\r
400 // Get the x, y, and z elements of a 4-D vector
\r
402 inline const Vector3 getXYZ( ) const;
\r
404 // Set the x element of a 4-D vector
\r
406 inline Vector4 & setX( float x );
\r
408 // Set the y element of a 4-D vector
\r
410 inline Vector4 & setY( float y );
\r
412 // Set the z element of a 4-D vector
\r
414 inline Vector4 & setZ( float z );
\r
416 // Set the w element of a 4-D vector
\r
418 inline Vector4 & setW( float w );
\r
420 // Get the x element of a 4-D vector
\r
422 inline float getX( ) const;
\r
424 // Get the y element of a 4-D vector
\r
426 inline float getY( ) const;
\r
428 // Get the z element of a 4-D vector
\r
430 inline float getZ( ) const;
\r
432 // Get the w element of a 4-D vector
\r
434 inline float getW( ) const;
\r
436 // Set an x, y, z, or w element of a 4-D vector by index
\r
438 inline Vector4 & setElem( int idx, float value );
\r
440 // Get an x, y, z, or w element of a 4-D vector by index
\r
442 inline float getElem( int idx ) const;
\r
444 // Subscripting operator to set or get an element
\r
446 inline float & operator []( int idx );
\r
448 // Subscripting operator to get an element
\r
450 inline float operator []( int idx ) const;
\r
452 // Add two 4-D vectors
\r
454 inline const Vector4 operator +( const Vector4 & vec ) const;
\r
456 // Subtract a 4-D vector from another 4-D vector
\r
458 inline const Vector4 operator -( const Vector4 & vec ) const;
\r
460 // Multiply a 4-D vector by a scalar
\r
462 inline const Vector4 operator *( float scalar ) const;
\r
464 // Divide a 4-D vector by a scalar
\r
466 inline const Vector4 operator /( float scalar ) const;
\r
468 // Perform compound assignment and addition with a 4-D vector
\r
470 inline Vector4 & operator +=( const Vector4 & vec );
\r
472 // Perform compound assignment and subtraction by a 4-D vector
\r
474 inline Vector4 & operator -=( const Vector4 & vec );
\r
476 // Perform compound assignment and multiplication by a scalar
\r
478 inline Vector4 & operator *=( float scalar );
\r
480 // Perform compound assignment and division by a scalar
\r
482 inline Vector4 & operator /=( float scalar );
\r
484 // Negate all elements of a 4-D vector
\r
486 inline const Vector4 operator -( ) const;
\r
488 // Construct x axis
\r
490 static inline const Vector4 xAxis( );
\r
492 // Construct y axis
\r
494 static inline const Vector4 yAxis( );
\r
496 // Construct z axis
\r
498 static inline const Vector4 zAxis( );
\r
500 // Construct w axis
\r
502 static inline const Vector4 wAxis( );
\r
506 __attribute__ ((aligned(16)))
\r
510 // Multiply a 4-D vector by a scalar
\r
512 inline const Vector4 operator *( float scalar, const Vector4 & vec );
\r
514 // Multiply two 4-D vectors per element
\r
516 inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 );
\r
518 // Divide two 4-D vectors per element
\r
520 // Floating-point behavior matches standard library function divf4.
\r
522 inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 );
\r
524 // Compute the reciprocal of a 4-D vector per element
\r
526 // Floating-point behavior matches standard library function recipf4.
\r
528 inline const Vector4 recipPerElem( const Vector4 & vec );
\r
530 // Compute the square root of a 4-D vector per element
\r
532 // Floating-point behavior matches standard library function sqrtf4.
\r
534 inline const Vector4 sqrtPerElem( const Vector4 & vec );
\r
536 // Compute the reciprocal square root of a 4-D vector per element
\r
538 // Floating-point behavior matches standard library function rsqrtf4.
\r
540 inline const Vector4 rsqrtPerElem( const Vector4 & vec );
\r
542 // Compute the absolute value of a 4-D vector per element
\r
544 inline const Vector4 absPerElem( const Vector4 & vec );
\r
546 // Copy sign from one 4-D vector to another, per element
\r
548 inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 );
\r
550 // Maximum of two 4-D vectors per element
\r
552 inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 );
\r
554 // Minimum of two 4-D vectors per element
\r
556 inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 );
\r
558 // Maximum element of a 4-D vector
\r
560 inline float maxElem( const Vector4 & vec );
\r
562 // Minimum element of a 4-D vector
\r
564 inline float minElem( const Vector4 & vec );
\r
566 // Compute the sum of all elements of a 4-D vector
\r
568 inline float sum( const Vector4 & vec );
\r
570 // Compute the dot product of two 4-D vectors
\r
572 inline float dot( const Vector4 & vec0, const Vector4 & vec1 );
\r
574 // Compute the square of the length of a 4-D vector
\r
576 inline float lengthSqr( const Vector4 & vec );
\r
578 // Compute the length of a 4-D vector
\r
580 inline float length( const Vector4 & vec );
\r
582 // Normalize a 4-D vector
\r
584 // The result is unpredictable when all elements of vec are at or near zero.
\r
586 inline const Vector4 normalize( const Vector4 & vec );
\r
588 // Outer product of two 4-D vectors
\r
590 inline const Matrix4 outer( const Vector4 & vec0, const Vector4 & vec1 );
\r
592 // Linear interpolation between two 4-D vectors
\r
594 // Does not clamp t between 0 and 1.
\r
596 inline const Vector4 lerp( float t, const Vector4 & vec0, const Vector4 & vec1 );
\r
598 // Spherical linear interpolation between two 4-D vectors
\r
600 // The result is unpredictable if the vectors point in opposite directions.
\r
601 // Does not clamp t between 0 and 1.
\r
603 inline const Vector4 slerp( float t, const Vector4 & unitVec0, const Vector4 & unitVec1 );
\r
605 // Conditionally select between two 4-D vectors
\r
607 inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, bool select1 );
\r
609 // Load x, y, z, and w elements from the first four words of a float array.
\r
612 inline void loadXYZW( Vector4 & vec, const float * fptr );
\r
614 // Store x, y, z, and w elements of a 4-D vector in the first four words of a float array.
\r
615 // Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed
\r
617 inline void storeXYZW( const Vector4 & vec, float * fptr );
\r
619 // Load four-half-floats as a 4-D vector
\r
621 // This transformation does not support either denormalized numbers or NaNs.
\r
623 inline void loadHalfFloats( Vector4 & vec, const unsigned short * hfptr );
\r
625 // Store a 4-D vector as half-floats. Memory area of previous 16 bytes and next 32 bytes from <code><i>hfptr</i></code> might be accessed.
\r
627 // This transformation does not support either denormalized numbers or NaNs. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed.
\r
629 inline void storeHalfFloats( const Vector4 & vec, unsigned short * hfptr );
\r
631 #ifdef _VECTORMATH_DEBUG
\r
633 // Print a 4-D vector
\r
635 // Function is only defined when _VECTORMATH_DEBUG is defined.
\r
637 inline void print( const Vector4 & vec );
\r
639 // Print a 4-D vector and an associated string identifier
\r
641 // Function is only defined when _VECTORMATH_DEBUG is defined.
\r
643 inline void print( const Vector4 & vec, const char * name );
\r
647 // A 3-D point in array-of-structures format
\r
654 // ARA begin code change
\r
655 // Removed #ifndef __GNUC__ condition
\r
660 // Default constructor; does no initialization
\r
662 // ARA begin insert new code
\r
663 // Added explicit initialization of d = 0.0f;
\r
664 inline Point3( ) { d = 0.0f; };
\r
667 // Copy a 3-D point
\r
669 inline Point3( const Point3 & pnt );
\r
671 // Construct a 3-D point from x, y, and z elements
\r
673 inline Point3( float x, float y, float z );
\r
675 // Copy elements from a 3-D vector into a 3-D point
\r
677 explicit inline Point3( const Vector3 & vec );
\r
679 // Set all elements of a 3-D point to the same scalar value
\r
681 explicit inline Point3( float scalar );
\r
683 // Assign one 3-D point to another
\r
685 inline Point3 & operator =( const Point3 & pnt );
\r
687 // Set the x element of a 3-D point
\r
689 inline Point3 & setX( float x );
\r
691 // Set the y element of a 3-D point
\r
693 inline Point3 & setY( float y );
\r
695 // Set the z element of a 3-D point
\r
697 inline Point3 & setZ( float z );
\r
699 // Get the x element of a 3-D point
\r
701 inline float getX( ) const;
\r
703 // Get the y element of a 3-D point
\r
705 inline float getY( ) const;
\r
707 // Get the z element of a 3-D point
\r
709 inline float getZ( ) const;
\r
711 // Set an x, y, or z element of a 3-D point by index
\r
713 inline Point3 & setElem( int idx, float value );
\r
715 // Get an x, y, or z element of a 3-D point by index
\r
717 inline float getElem( int idx ) const;
\r
719 // Subscripting operator to set or get an element
\r
721 inline float & operator []( int idx );
\r
723 // Subscripting operator to get an element
\r
725 inline float operator []( int idx ) const;
\r
727 // Subtract a 3-D point from another 3-D point
\r
729 inline const Vector3 operator -( const Point3 & pnt ) const;
\r
731 // Add a 3-D point to a 3-D vector
\r
733 inline const Point3 operator +( const Vector3 & vec ) const;
\r
735 // Subtract a 3-D vector from a 3-D point
\r
737 inline const Point3 operator -( const Vector3 & vec ) const;
\r
739 // Perform compound assignment and addition with a 3-D vector
\r
741 inline Point3 & operator +=( const Vector3 & vec );
\r
743 // Perform compound assignment and subtraction by a 3-D vector
\r
745 inline Point3 & operator -=( const Vector3 & vec );
\r
749 __attribute__ ((aligned(16)))
\r
753 // Multiply two 3-D points per element
\r
755 inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 );
\r
757 // Divide two 3-D points per element
\r
759 // Floating-point behavior matches standard library function divf4.
\r
761 inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 );
\r
763 // Compute the reciprocal of a 3-D point per element
\r
765 // Floating-point behavior matches standard library function recipf4.
\r
767 inline const Point3 recipPerElem( const Point3 & pnt );
\r
769 // Compute the square root of a 3-D point per element
\r
771 // Floating-point behavior matches standard library function sqrtf4.
\r
773 inline const Point3 sqrtPerElem( const Point3 & pnt );
\r
775 // Compute the reciprocal square root of a 3-D point per element
\r
777 // Floating-point behavior matches standard library function rsqrtf4.
\r
779 inline const Point3 rsqrtPerElem( const Point3 & pnt );
\r
781 // Compute the absolute value of a 3-D point per element
\r
783 inline const Point3 absPerElem( const Point3 & pnt );
\r
785 // Copy sign from one 3-D point to another, per element
\r
787 inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 );
\r
789 // Maximum of two 3-D points per element
\r
791 inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 );
\r
793 // Minimum of two 3-D points per element
\r
795 inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 );
\r
797 // Maximum element of a 3-D point
\r
799 inline float maxElem( const Point3 & pnt );
\r
801 // Minimum element of a 3-D point
\r
803 inline float minElem( const Point3 & pnt );
\r
805 // Compute the sum of all elements of a 3-D point
\r
807 inline float sum( const Point3 & pnt );
\r
809 // Apply uniform scale to a 3-D point
\r
811 inline const Point3 scale( const Point3 & pnt, float scaleVal );
\r
813 // Apply non-uniform scale to a 3-D point
\r
815 inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec );
\r
817 // Scalar projection of a 3-D point on a unit-length 3-D vector
\r
819 inline float projection( const Point3 & pnt, const Vector3 & unitVec );
\r
821 // Compute the square of the distance of a 3-D point from the coordinate-system origin
\r
823 inline float distSqrFromOrigin( const Point3 & pnt );
\r
825 // Compute the distance of a 3-D point from the coordinate-system origin
\r
827 inline float distFromOrigin( const Point3 & pnt );
\r
829 // Compute the square of the distance between two 3-D points
\r
831 inline float distSqr( const Point3 & pnt0, const Point3 & pnt1 );
\r
833 // Compute the distance between two 3-D points
\r
835 inline float dist( const Point3 & pnt0, const Point3 & pnt1 );
\r
837 // Linear interpolation between two 3-D points
\r
839 // Does not clamp t between 0 and 1.
\r
841 inline const Point3 lerp( float t, const Point3 & pnt0, const Point3 & pnt1 );
\r
843 // Conditionally select between two 3-D points
\r
845 inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, bool select1 );
\r
847 // Load x, y, and z elements from the first three words of a float array.
\r
850 inline void loadXYZ( Point3 & pnt, const float * fptr );
\r
852 // Store x, y, and z elements of a 3-D point in the first three words of a float array.
\r
853 // Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed
\r
855 inline void storeXYZ( const Point3 & pnt, float * fptr );
\r
857 // Load three-half-floats as a 3-D point
\r
859 // This transformation does not support either denormalized numbers or NaNs.
\r
861 inline void loadHalfFloats( Point3 & pnt, const unsigned short * hfptr );
\r
863 // Store a 3-D point as half-floats. Memory area of previous 16 bytes and next 32 bytes from <code><i>hfptr</i></code> might be accessed.
\r
865 // This transformation does not support either denormalized numbers or NaNs. Memory area of previous 16 bytes and next 32 bytes from hfptr might be accessed.
\r
867 inline void storeHalfFloats( const Point3 & pnt, unsigned short * hfptr );
\r
869 #ifdef _VECTORMATH_DEBUG
\r
871 // Print a 3-D point
\r
873 // Function is only defined when _VECTORMATH_DEBUG is defined.
\r
875 inline void print( const Point3 & pnt );
\r
877 // Print a 3-D point and an associated string identifier
\r
879 // Function is only defined when _VECTORMATH_DEBUG is defined.
\r
881 inline void print( const Point3 & pnt, const char * name );
\r
885 // A quaternion in array-of-structures format
\r
895 // Default constructor; does no initialization
\r
897 inline Quat( ) { };
\r
899 // Copy a quaternion
\r
901 inline Quat( const Quat & quat );
\r
903 // Construct a quaternion from x, y, z, and w elements
\r
905 inline Quat( float x, float y, float z, float w );
\r
907 // Construct a quaternion from a 3-D vector and a scalar
\r
909 inline Quat( const Vector3 & xyz, float w );
\r
911 // Copy elements from a 4-D vector into a quaternion
\r
913 explicit inline Quat( const Vector4 & vec );
\r
915 // Convert a rotation matrix to a unit-length quaternion
\r
917 explicit inline Quat( const Matrix3 & rotMat );
\r
919 // Set all elements of a quaternion to the same scalar value
\r
921 explicit inline Quat( float scalar );
\r
923 // Assign one quaternion to another
\r
925 inline Quat & operator =( const Quat & quat );
\r
927 // Set the x, y, and z elements of a quaternion
\r
929 // This function does not change the w element.
\r
931 inline Quat & setXYZ( const Vector3 & vec );
\r
933 // Get the x, y, and z elements of a quaternion
\r
935 inline const Vector3 getXYZ( ) const;
\r
937 // Set the x element of a quaternion
\r
939 inline Quat & setX( float x );
\r
941 // Set the y element of a quaternion
\r
943 inline Quat & setY( float y );
\r
945 // Set the z element of a quaternion
\r
947 inline Quat & setZ( float z );
\r
949 // Set the w element of a quaternion
\r
951 inline Quat & setW( float w );
\r
953 // Get the x element of a quaternion
\r
955 inline float getX( ) const;
\r
957 // Get the y element of a quaternion
\r
959 inline float getY( ) const;
\r
961 // Get the z element of a quaternion
\r
963 inline float getZ( ) const;
\r
965 // Get the w element of a quaternion
\r
967 inline float getW( ) const;
\r
969 // Set an x, y, z, or w element of a quaternion by index
\r
971 inline Quat & setElem( int idx, float value );
\r
973 // Get an x, y, z, or w element of a quaternion by index
\r
975 inline float getElem( int idx ) const;
\r
977 // Subscripting operator to set or get an element
\r
979 inline float & operator []( int idx );
\r
981 // Subscripting operator to get an element
\r
983 inline float operator []( int idx ) const;
\r
985 // Add two quaternions
\r
987 inline const Quat operator +( const Quat & quat ) const;
\r
989 // Subtract a quaternion from another quaternion
\r
991 inline const Quat operator -( const Quat & quat ) const;
\r
993 // Multiply two quaternions
\r
995 inline const Quat operator *( const Quat & quat ) const;
\r
997 // Multiply a quaternion by a scalar
\r
999 inline const Quat operator *( float scalar ) const;
\r
1001 // Divide a quaternion by a scalar
\r
1003 inline const Quat operator /( float scalar ) const;
\r
1005 // Perform compound assignment and addition with a quaternion
\r
1007 inline Quat & operator +=( const Quat & quat );
\r
1009 // Perform compound assignment and subtraction by a quaternion
\r
1011 inline Quat & operator -=( const Quat & quat );
\r
1013 // Perform compound assignment and multiplication by a quaternion
\r
1015 inline Quat & operator *=( const Quat & quat );
\r
1017 // Perform compound assignment and multiplication by a scalar
\r
1019 inline Quat & operator *=( float scalar );
\r
1021 // Perform compound assignment and division by a scalar
\r
1023 inline Quat & operator /=( float scalar );
\r
1025 // Negate all elements of a quaternion
\r
1027 inline const Quat operator -( ) const;
\r
1029 // Construct an identity quaternion
\r
1031 static inline const Quat identity( );
\r
1033 // Construct a quaternion to rotate between two unit-length 3-D vectors
\r
1035 // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions.
\r
1037 static inline const Quat rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 );
\r
1039 // Construct a quaternion to rotate around a unit-length 3-D vector
\r
1041 static inline const Quat rotation( float radians, const Vector3 & unitVec );
\r
1043 // Construct a quaternion to rotate around the x axis
\r
1045 static inline const Quat rotationX( float radians );
\r
1047 // Construct a quaternion to rotate around the y axis
\r
1049 static inline const Quat rotationY( float radians );
\r
1051 // Construct a quaternion to rotate around the z axis
\r
1053 static inline const Quat rotationZ( float radians );
\r
1057 __attribute__ ((aligned(16)))
\r
1061 // Multiply a quaternion by a scalar
\r
1063 inline const Quat operator *( float scalar, const Quat & quat );
\r
1065 // Compute the conjugate of a quaternion
\r
1067 inline const Quat conj( const Quat & quat );
\r
1069 // Use a unit-length quaternion to rotate a 3-D vector
\r
1071 inline const Vector3 rotate( const Quat & unitQuat, const Vector3 & vec );
\r
1073 // Compute the dot product of two quaternions
\r
1075 inline float dot( const Quat & quat0, const Quat & quat1 );
\r
1077 // Compute the norm of a quaternion
\r
1079 inline float norm( const Quat & quat );
\r
1081 // Compute the length of a quaternion
\r
1083 inline float length( const Quat & quat );
\r
1085 // Normalize a quaternion
\r
1087 // The result is unpredictable when all elements of quat are at or near zero.
\r
1089 inline const Quat normalize( const Quat & quat );
\r
1091 // Linear interpolation between two quaternions
\r
1093 // Does not clamp t between 0 and 1.
\r
1095 inline const Quat lerp( float t, const Quat & quat0, const Quat & quat1 );
\r
1097 // Spherical linear interpolation between two quaternions
\r
1099 // Interpolates along the shortest path between orientations.
\r
1100 // Does not clamp t between 0 and 1.
\r
1102 inline const Quat slerp( float t, const Quat & unitQuat0, const Quat & unitQuat1 );
\r
1104 // Spherical quadrangle interpolation
\r
1106 inline const Quat squad( float t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 );
\r
1108 // Conditionally select between two quaternions
\r
1110 inline const Quat select( const Quat & quat0, const Quat & quat1, bool select1 );
\r
1112 // Load x, y, z, and w elements from the first four words of a float array.
\r
1115 inline void loadXYZW( Quat & quat, const float * fptr );
\r
1117 // Store x, y, z, and w elements of a quaternion in the first four words of a float array.
\r
1118 // Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed
\r
1120 inline void storeXYZW( const Quat & quat, float * fptr );
\r
1122 #ifdef _VECTORMATH_DEBUG
\r
1124 // Print a quaternion
\r
1126 // Function is only defined when _VECTORMATH_DEBUG is defined.
\r
1128 inline void print( const Quat & quat );
\r
1130 // Print a quaternion and an associated string identifier
\r
1132 // Function is only defined when _VECTORMATH_DEBUG is defined.
\r
1134 inline void print( const Quat & quat, const char * name );
\r
1138 // A 3x3 matrix in array-of-structures format
\r
1147 // Default constructor; does no initialization
\r
1149 inline Matrix3( ) { };
\r
1151 // Copy a 3x3 matrix
\r
1153 inline Matrix3( const Matrix3 & mat );
\r
1155 // Construct a 3x3 matrix containing the specified columns
\r
1157 inline Matrix3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2 );
\r
1159 // Construct a 3x3 rotation matrix from a unit-length quaternion
\r
1161 explicit inline Matrix3( const Quat & unitQuat );
\r
1163 // Set all elements of a 3x3 matrix to the same scalar value
\r
1165 explicit inline Matrix3( float scalar );
\r
1167 // Assign one 3x3 matrix to another
\r
1169 inline Matrix3 & operator =( const Matrix3 & mat );
\r
1171 // Set column 0 of a 3x3 matrix
\r
1173 inline Matrix3 & setCol0( const Vector3 & col0 );
\r
1175 // Set column 1 of a 3x3 matrix
\r
1177 inline Matrix3 & setCol1( const Vector3 & col1 );
\r
1179 // Set column 2 of a 3x3 matrix
\r
1181 inline Matrix3 & setCol2( const Vector3 & col2 );
\r
1183 // Get column 0 of a 3x3 matrix
\r
1185 inline const Vector3 getCol0( ) const;
\r
1187 // Get column 1 of a 3x3 matrix
\r
1189 inline const Vector3 getCol1( ) const;
\r
1191 // Get column 2 of a 3x3 matrix
\r
1193 inline const Vector3 getCol2( ) const;
\r
1195 // Set the column of a 3x3 matrix referred to by the specified index
\r
1197 inline Matrix3 & setCol( int col, const Vector3 & vec );
\r
1199 // Set the row of a 3x3 matrix referred to by the specified index
\r
1201 inline Matrix3 & setRow( int row, const Vector3 & vec );
\r
1203 // Get the column of a 3x3 matrix referred to by the specified index
\r
1205 inline const Vector3 getCol( int col ) const;
\r
1207 // Get the row of a 3x3 matrix referred to by the specified index
\r
1209 inline const Vector3 getRow( int row ) const;
\r
1211 // Subscripting operator to set or get a column
\r
1213 inline Vector3 & operator []( int col );
\r
1215 // Subscripting operator to get a column
\r
1217 inline const Vector3 operator []( int col ) const;
\r
1219 // Set the element of a 3x3 matrix referred to by column and row indices
\r
1221 inline Matrix3 & setElem( int col, int row, float val );
\r
1223 // Get the element of a 3x3 matrix referred to by column and row indices
\r
1225 inline float getElem( int col, int row ) const;
\r
1227 // Add two 3x3 matrices
\r
1229 inline const Matrix3 operator +( const Matrix3 & mat ) const;
\r
1231 // Subtract a 3x3 matrix from another 3x3 matrix
\r
1233 inline const Matrix3 operator -( const Matrix3 & mat ) const;
\r
1235 // Negate all elements of a 3x3 matrix
\r
1237 inline const Matrix3 operator -( ) const;
\r
1239 // Multiply a 3x3 matrix by a scalar
\r
1241 inline const Matrix3 operator *( float scalar ) const;
\r
1243 // Multiply a 3x3 matrix by a 3-D vector
\r
1245 inline const Vector3 operator *( const Vector3 & vec ) const;
\r
1247 // Multiply two 3x3 matrices
\r
1249 inline const Matrix3 operator *( const Matrix3 & mat ) const;
\r
1251 // Perform compound assignment and addition with a 3x3 matrix
\r
1253 inline Matrix3 & operator +=( const Matrix3 & mat );
\r
1255 // Perform compound assignment and subtraction by a 3x3 matrix
\r
1257 inline Matrix3 & operator -=( const Matrix3 & mat );
\r
1259 // Perform compound assignment and multiplication by a scalar
\r
1261 inline Matrix3 & operator *=( float scalar );
\r
1263 // Perform compound assignment and multiplication by a 3x3 matrix
\r
1265 inline Matrix3 & operator *=( const Matrix3 & mat );
\r
1267 // Construct an identity 3x3 matrix
\r
1269 static inline const Matrix3 identity( );
\r
1271 // Construct a 3x3 matrix to rotate around the x axis
\r
1273 static inline const Matrix3 rotationX( float radians );
\r
1275 // Construct a 3x3 matrix to rotate around the y axis
\r
1277 static inline const Matrix3 rotationY( float radians );
\r
1279 // Construct a 3x3 matrix to rotate around the z axis
\r
1281 static inline const Matrix3 rotationZ( float radians );
\r
1283 // Construct a 3x3 matrix to rotate around the x, y, and z axes
\r
1285 static inline const Matrix3 rotationZYX( const Vector3 & radiansXYZ );
\r
1287 // Construct a 3x3 matrix to rotate around a unit-length 3-D vector
\r
1289 static inline const Matrix3 rotation( float radians, const Vector3 & unitVec );
\r
1291 // Construct a rotation matrix from a unit-length quaternion
\r
1293 static inline const Matrix3 rotation( const Quat & unitQuat );
\r
1295 // Construct a 3x3 matrix to perform scaling
\r
1297 static inline const Matrix3 scale( const Vector3 & scaleVec );
\r
1300 // Multiply a 3x3 matrix by a scalar
\r
1302 inline const Matrix3 operator *( float scalar, const Matrix3 & mat );
\r
1304 // Append (post-multiply) a scale transformation to a 3x3 matrix
\r
1306 // Faster than creating and multiplying a scale transformation matrix.
\r
1308 inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec );
\r
1310 // Prepend (pre-multiply) a scale transformation to a 3x3 matrix
\r
1312 // Faster than creating and multiplying a scale transformation matrix.
\r
1314 inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat );
\r
1316 // Multiply two 3x3 matrices per element
\r
1318 inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 );
\r
1320 // Compute the absolute value of a 3x3 matrix per element
\r
1322 inline const Matrix3 absPerElem( const Matrix3 & mat );
\r
1324 // Transpose of a 3x3 matrix
\r
1326 inline const Matrix3 transpose( const Matrix3 & mat );
\r
1328 // Compute the inverse of a 3x3 matrix
\r
1330 // Result is unpredictable when the determinant of mat is equal to or near 0.
\r
1332 inline const Matrix3 inverse( const Matrix3 & mat );
\r
1334 // Determinant of a 3x3 matrix
\r
1336 inline float determinant( const Matrix3 & mat );
\r
1338 // Conditionally select between two 3x3 matrices
\r
1340 inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 );
\r
1342 #ifdef _VECTORMATH_DEBUG
\r
1344 // Print a 3x3 matrix
\r
1346 // Function is only defined when _VECTORMATH_DEBUG is defined.
\r
1348 inline void print( const Matrix3 & mat );
\r
1350 // Print a 3x3 matrix and an associated string identifier
\r
1352 // Function is only defined when _VECTORMATH_DEBUG is defined.
\r
1354 inline void print( const Matrix3 & mat, const char * name );
\r
1358 // A 4x4 matrix in array-of-structures format
\r
1368 // Default constructor; does no initialization
\r
1370 inline Matrix4( ) { };
\r
1372 // Copy a 4x4 matrix
\r
1374 inline Matrix4( const Matrix4 & mat );
\r
1376 // Construct a 4x4 matrix containing the specified columns
\r
1378 inline Matrix4( const Vector4 & col0, const Vector4 & col1, const Vector4 & col2, const Vector4 & col3 );
\r
1380 // Construct a 4x4 matrix from a 3x4 transformation matrix
\r
1382 explicit inline Matrix4( const Transform3 & mat );
\r
1384 // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector
\r
1386 inline Matrix4( const Matrix3 & mat, const Vector3 & translateVec );
\r
1388 // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector
\r
1390 inline Matrix4( const Quat & unitQuat, const Vector3 & translateVec );
\r
1392 // Set all elements of a 4x4 matrix to the same scalar value
\r
1394 explicit inline Matrix4( float scalar );
\r
1396 // Assign one 4x4 matrix to another
\r
1398 inline Matrix4 & operator =( const Matrix4 & mat );
\r
1400 // Set the upper-left 3x3 submatrix
\r
1402 // This function does not change the bottom row elements.
\r
1404 inline Matrix4 & setUpper3x3( const Matrix3 & mat3 );
\r
1406 // Get the upper-left 3x3 submatrix of a 4x4 matrix
\r
1408 inline const Matrix3 getUpper3x3( ) const;
\r
1410 // Set translation component
\r
1412 // This function does not change the bottom row elements.
\r
1414 inline Matrix4 & setTranslation( const Vector3 & translateVec );
\r
1416 // Get the translation component of a 4x4 matrix
\r
1418 inline const Vector3 getTranslation( ) const;
\r
1420 // Set column 0 of a 4x4 matrix
\r
1422 inline Matrix4 & setCol0( const Vector4 & col0 );
\r
1424 // Set column 1 of a 4x4 matrix
\r
1426 inline Matrix4 & setCol1( const Vector4 & col1 );
\r
1428 // Set column 2 of a 4x4 matrix
\r
1430 inline Matrix4 & setCol2( const Vector4 & col2 );
\r
1432 // Set column 3 of a 4x4 matrix
\r
1434 inline Matrix4 & setCol3( const Vector4 & col3 );
\r
1436 // Get column 0 of a 4x4 matrix
\r
1438 inline const Vector4 getCol0( ) const;
\r
1440 // Get column 1 of a 4x4 matrix
\r
1442 inline const Vector4 getCol1( ) const;
\r
1444 // Get column 2 of a 4x4 matrix
\r
1446 inline const Vector4 getCol2( ) const;
\r
1448 // Get column 3 of a 4x4 matrix
\r
1450 inline const Vector4 getCol3( ) const;
\r
1452 // Set the column of a 4x4 matrix referred to by the specified index
\r
1454 inline Matrix4 & setCol( int col, const Vector4 & vec );
\r
1456 // Set the row of a 4x4 matrix referred to by the specified index
\r
1458 inline Matrix4 & setRow( int row, const Vector4 & vec );
\r
1460 // Get the column of a 4x4 matrix referred to by the specified index
\r
1462 inline const Vector4 getCol( int col ) const;
\r
1464 // Get the row of a 4x4 matrix referred to by the specified index
\r
1466 inline const Vector4 getRow( int row ) const;
\r
1468 // Subscripting operator to set or get a column
\r
1470 inline Vector4 & operator []( int col );
\r
1472 // Subscripting operator to get a column
\r
1474 inline const Vector4 operator []( int col ) const;
\r
1476 // Set the element of a 4x4 matrix referred to by column and row indices
\r
1478 inline Matrix4 & setElem( int col, int row, float val );
\r
1480 // Get the element of a 4x4 matrix referred to by column and row indices
\r
1482 inline float getElem( int col, int row ) const;
\r
1484 // Add two 4x4 matrices
\r
1486 inline const Matrix4 operator +( const Matrix4 & mat ) const;
\r
1488 // Subtract a 4x4 matrix from another 4x4 matrix
\r
1490 inline const Matrix4 operator -( const Matrix4 & mat ) const;
\r
1492 // Negate all elements of a 4x4 matrix
\r
1494 inline const Matrix4 operator -( ) const;
\r
1496 // Multiply a 4x4 matrix by a scalar
\r
1498 inline const Matrix4 operator *( float scalar ) const;
\r
1500 // Multiply a 4x4 matrix by a 4-D vector
\r
1502 inline const Vector4 operator *( const Vector4 & vec ) const;
\r
1504 // Multiply a 4x4 matrix by a 3-D vector
\r
1506 inline const Vector4 operator *( const Vector3 & vec ) const;
\r
1508 // Multiply a 4x4 matrix by a 3-D point
\r
1510 inline const Vector4 operator *( const Point3 & pnt ) const;
\r
1512 // Multiply two 4x4 matrices
\r
1514 inline const Matrix4 operator *( const Matrix4 & mat ) const;
\r
1516 // Multiply a 4x4 matrix by a 3x4 transformation matrix
\r
1518 inline const Matrix4 operator *( const Transform3 & tfrm ) const;
\r
1520 // Perform compound assignment and addition with a 4x4 matrix
\r
1522 inline Matrix4 & operator +=( const Matrix4 & mat );
\r
1524 // Perform compound assignment and subtraction by a 4x4 matrix
\r
1526 inline Matrix4 & operator -=( const Matrix4 & mat );
\r
1528 // Perform compound assignment and multiplication by a scalar
\r
1530 inline Matrix4 & operator *=( float scalar );
\r
1532 // Perform compound assignment and multiplication by a 4x4 matrix
\r
1534 inline Matrix4 & operator *=( const Matrix4 & mat );
\r
1536 // Perform compound assignment and multiplication by a 3x4 transformation matrix
\r
1538 inline Matrix4 & operator *=( const Transform3 & tfrm );
\r
1540 // Construct an identity 4x4 matrix
\r
1542 static inline const Matrix4 identity( );
\r
1544 // Construct a 4x4 matrix to rotate around the x axis
\r
1546 static inline const Matrix4 rotationX( float radians );
\r
1548 // Construct a 4x4 matrix to rotate around the y axis
\r
1550 static inline const Matrix4 rotationY( float radians );
\r
1552 // Construct a 4x4 matrix to rotate around the z axis
\r
1554 static inline const Matrix4 rotationZ( float radians );
\r
1556 // Construct a 4x4 matrix to rotate around the x, y, and z axes
\r
1558 static inline const Matrix4 rotationZYX( const Vector3 & radiansXYZ );
\r
1560 // Construct a 4x4 matrix to rotate around a unit-length 3-D vector
\r
1562 static inline const Matrix4 rotation( float radians, const Vector3 & unitVec );
\r
1564 // Construct a rotation matrix from a unit-length quaternion
\r
1566 static inline const Matrix4 rotation( const Quat & unitQuat );
\r
1568 // Construct a 4x4 matrix to perform scaling
\r
1570 static inline const Matrix4 scale( const Vector3 & scaleVec );
\r
1572 // Construct a 4x4 matrix to perform translation
\r
1574 static inline const Matrix4 translation( const Vector3 & translateVec );
\r
1576 // Construct viewing matrix based on eye position, position looked at, and up direction
\r
1578 static inline const Matrix4 lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec );
\r
1580 // Construct a perspective projection matrix
\r
1582 static inline const Matrix4 perspective( float fovyRadians, float aspect, float zNear, float zFar );
\r
1584 // Construct a perspective projection matrix based on frustum
\r
1586 static inline const Matrix4 frustum( float left, float right, float bottom, float top, float zNear, float zFar );
\r
1588 // Construct an orthographic projection matrix
\r
1590 static inline const Matrix4 orthographic( float left, float right, float bottom, float top, float zNear, float zFar );
\r
1593 // Multiply a 4x4 matrix by a scalar
\r
1595 inline const Matrix4 operator *( float scalar, const Matrix4 & mat );
\r
1597 // Append (post-multiply) a scale transformation to a 4x4 matrix
\r
1599 // Faster than creating and multiplying a scale transformation matrix.
\r
1601 inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec );
\r
1603 // Prepend (pre-multiply) a scale transformation to a 4x4 matrix
\r
1605 // Faster than creating and multiplying a scale transformation matrix.
\r
1607 inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat );
\r
1609 // Multiply two 4x4 matrices per element
\r
1611 inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 );
\r
1613 // Compute the absolute value of a 4x4 matrix per element
\r
1615 inline const Matrix4 absPerElem( const Matrix4 & mat );
\r
1617 // Transpose of a 4x4 matrix
\r
1619 inline const Matrix4 transpose( const Matrix4 & mat );
\r
1621 // Compute the inverse of a 4x4 matrix
\r
1623 // Result is unpredictable when the determinant of mat is equal to or near 0.
\r
1625 inline const Matrix4 inverse( const Matrix4 & mat );
\r
1627 // Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix
\r
1629 // 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.
\r
1631 inline const Matrix4 affineInverse( const Matrix4 & mat );
\r
1633 // Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix
\r
1635 // This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions.
\r
1637 inline const Matrix4 orthoInverse( const Matrix4 & mat );
\r
1639 // Determinant of a 4x4 matrix
\r
1641 inline float determinant( const Matrix4 & mat );
\r
1643 // Conditionally select between two 4x4 matrices
\r
1645 inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 );
\r
1647 #ifdef _VECTORMATH_DEBUG
\r
1649 // Print a 4x4 matrix
\r
1651 // Function is only defined when _VECTORMATH_DEBUG is defined.
\r
1653 inline void print( const Matrix4 & mat );
\r
1655 // Print a 4x4 matrix and an associated string identifier
\r
1657 // Function is only defined when _VECTORMATH_DEBUG is defined.
\r
1659 inline void print( const Matrix4 & mat, const char * name );
\r
1663 // A 3x4 transformation matrix in array-of-structures format
\r
1673 // Default constructor; does no initialization
\r
1675 inline Transform3( ) { };
\r
1677 // Copy a 3x4 transformation matrix
\r
1679 inline Transform3( const Transform3 & tfrm );
\r
1681 // Construct a 3x4 transformation matrix containing the specified columns
\r
1683 inline Transform3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2, const Vector3 & col3 );
\r
1685 // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector
\r
1687 inline Transform3( const Matrix3 & tfrm, const Vector3 & translateVec );
\r
1689 // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector
\r
1691 inline Transform3( const Quat & unitQuat, const Vector3 & translateVec );
\r
1693 // Set all elements of a 3x4 transformation matrix to the same scalar value
\r
1695 explicit inline Transform3( float scalar );
\r
1697 // Assign one 3x4 transformation matrix to another
\r
1699 inline Transform3 & operator =( const Transform3 & tfrm );
\r
1701 // Set the upper-left 3x3 submatrix
\r
1703 inline Transform3 & setUpper3x3( const Matrix3 & mat3 );
\r
1705 // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix
\r
1707 inline const Matrix3 getUpper3x3( ) const;
\r
1709 // Set translation component
\r
1711 inline Transform3 & setTranslation( const Vector3 & translateVec );
\r
1713 // Get the translation component of a 3x4 transformation matrix
\r
1715 inline const Vector3 getTranslation( ) const;
\r
1717 // Set column 0 of a 3x4 transformation matrix
\r
1719 inline Transform3 & setCol0( const Vector3 & col0 );
\r
1721 // Set column 1 of a 3x4 transformation matrix
\r
1723 inline Transform3 & setCol1( const Vector3 & col1 );
\r
1725 // Set column 2 of a 3x4 transformation matrix
\r
1727 inline Transform3 & setCol2( const Vector3 & col2 );
\r
1729 // Set column 3 of a 3x4 transformation matrix
\r
1731 inline Transform3 & setCol3( const Vector3 & col3 );
\r
1733 // Get column 0 of a 3x4 transformation matrix
\r
1735 inline const Vector3 getCol0( ) const;
\r
1737 // Get column 1 of a 3x4 transformation matrix
\r
1739 inline const Vector3 getCol1( ) const;
\r
1741 // Get column 2 of a 3x4 transformation matrix
\r
1743 inline const Vector3 getCol2( ) const;
\r
1745 // Get column 3 of a 3x4 transformation matrix
\r
1747 inline const Vector3 getCol3( ) const;
\r
1749 // Set the column of a 3x4 transformation matrix referred to by the specified index
\r
1751 inline Transform3 & setCol( int col, const Vector3 & vec );
\r
1753 // Set the row of a 3x4 transformation matrix referred to by the specified index
\r
1755 inline Transform3 & setRow( int row, const Vector4 & vec );
\r
1757 // Get the column of a 3x4 transformation matrix referred to by the specified index
\r
1759 inline const Vector3 getCol( int col ) const;
\r
1761 // Get the row of a 3x4 transformation matrix referred to by the specified index
\r
1763 inline const Vector4 getRow( int row ) const;
\r
1765 // Subscripting operator to set or get a column
\r
1767 inline Vector3 & operator []( int col );
\r
1769 // Subscripting operator to get a column
\r
1771 inline const Vector3 operator []( int col ) const;
\r
1773 // Set the element of a 3x4 transformation matrix referred to by column and row indices
\r
1775 inline Transform3 & setElem( int col, int row, float val );
\r
1777 // Get the element of a 3x4 transformation matrix referred to by column and row indices
\r
1779 inline float getElem( int col, int row ) const;
\r
1781 // Multiply a 3x4 transformation matrix by a 3-D vector
\r
1783 inline const Vector3 operator *( const Vector3 & vec ) const;
\r
1785 // Multiply a 3x4 transformation matrix by a 3-D point
\r
1787 inline const Point3 operator *( const Point3 & pnt ) const;
\r
1789 // Multiply two 3x4 transformation matrices
\r
1791 inline const Transform3 operator *( const Transform3 & tfrm ) const;
\r
1793 // Perform compound assignment and multiplication by a 3x4 transformation matrix
\r
1795 inline Transform3 & operator *=( const Transform3 & tfrm );
\r
1797 // Construct an identity 3x4 transformation matrix
\r
1799 static inline const Transform3 identity( );
\r
1801 // Construct a 3x4 transformation matrix to rotate around the x axis
\r
1803 static inline const Transform3 rotationX( float radians );
\r
1805 // Construct a 3x4 transformation matrix to rotate around the y axis
\r
1807 static inline const Transform3 rotationY( float radians );
\r
1809 // Construct a 3x4 transformation matrix to rotate around the z axis
\r
1811 static inline const Transform3 rotationZ( float radians );
\r
1813 // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes
\r
1815 static inline const Transform3 rotationZYX( const Vector3 & radiansXYZ );
\r
1817 // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector
\r
1819 static inline const Transform3 rotation( float radians, const Vector3 & unitVec );
\r
1821 // Construct a rotation matrix from a unit-length quaternion
\r
1823 static inline const Transform3 rotation( const Quat & unitQuat );
\r
1825 // Construct a 3x4 transformation matrix to perform scaling
\r
1827 static inline const Transform3 scale( const Vector3 & scaleVec );
\r
1829 // Construct a 3x4 transformation matrix to perform translation
\r
1831 static inline const Transform3 translation( const Vector3 & translateVec );
\r
1834 // Append (post-multiply) a scale transformation to a 3x4 transformation matrix
\r
1836 // Faster than creating and multiplying a scale transformation matrix.
\r
1838 inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec );
\r
1840 // Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix
\r
1842 // Faster than creating and multiplying a scale transformation matrix.
\r
1844 inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm );
\r
1846 // Multiply two 3x4 transformation matrices per element
\r
1848 inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 );
\r
1850 // Compute the absolute value of a 3x4 transformation matrix per element
\r
1852 inline const Transform3 absPerElem( const Transform3 & tfrm );
\r
1854 // Inverse of a 3x4 transformation matrix
\r
1856 // Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0.
\r
1858 inline const Transform3 inverse( const Transform3 & tfrm );
\r
1860 // Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix
\r
1862 // This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions.
\r
1864 inline const Transform3 orthoInverse( const Transform3 & tfrm );
\r
1866 // Conditionally select between two 3x4 transformation matrices
\r
1868 inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 );
\r
1870 #ifdef _VECTORMATH_DEBUG
\r
1872 // Print a 3x4 transformation matrix
\r
1874 // Function is only defined when _VECTORMATH_DEBUG is defined.
\r
1876 inline void print( const Transform3 & tfrm );
\r
1878 // Print a 3x4 transformation matrix and an associated string identifier
\r
1880 // Function is only defined when _VECTORMATH_DEBUG is defined.
\r
1882 inline void print( const Transform3 & tfrm, const char * name );
\r
1886 } // namespace Aos
\r
1887 } // namespace Vectormath
\r
1889 #include "vec_aos.h"
\r
1890 #include "quat_aos.h"
\r
1891 #include "mat_aos.h"
\r