scalar/vectormath_aos.h

Go to the documentation of this file.
00001 /*
00002    Copyright (C) 2009 Sony Computer Entertainment Inc.
00003    All rights reserved.
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages arising from the use of this software.
00007 Permission is granted to anyone to use this software for any purpose, 
00008 including commercial applications, and to alter it and redistribute it freely, 
00009 subject to the following restrictions:
00010 
00011 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
00014 
00015 */
00016 
00017 #ifndef _VECTORMATH_AOS_CPP_H
00018 #define _VECTORMATH_AOS_CPP_H
00019 
00020 #include <math.h>
00021 
00022 #ifdef _VECTORMATH_DEBUG
00023 #include <stdio.h>
00024 #endif
00025 
00026 namespace Vectormath {
00027 
00028 namespace Aos {
00029 
00030 //-----------------------------------------------------------------------------
00031 // Forward Declarations
00032 //
00033 
00034 class Vector3;
00035 class Vector4;
00036 class Point3;
00037 class Quat;
00038 class Matrix3;
00039 class Matrix4;
00040 class Transform3;
00041 
00042 // A 3-D vector in array-of-structures format
00043 //
00044 class Vector3
00045 {
00046     float mX;
00047     float mY;
00048     float mZ;
00049 #ifndef __GNUC__
00050     float d;
00051 #endif
00052 
00053 public:
00054     // Default constructor; does no initialization
00055     // 
00056     inline Vector3( ) { };
00057 
00058     // Copy a 3-D vector
00059     // 
00060     inline Vector3( const Vector3 & vec );
00061 
00062     // Construct a 3-D vector from x, y, and z elements
00063     // 
00064     inline Vector3( float x, float y, float z );
00065 
00066     // Copy elements from a 3-D point into a 3-D vector
00067     // 
00068     explicit inline Vector3( const Point3 & pnt );
00069 
00070     // Set all elements of a 3-D vector to the same scalar value
00071     // 
00072     explicit inline Vector3( float scalar );
00073 
00074     // Assign one 3-D vector to another
00075     // 
00076     inline Vector3 & operator =( const Vector3 & vec );
00077 
00078     // Set the x element of a 3-D vector
00079     // 
00080     inline Vector3 & setX( float x );
00081 
00082     // Set the y element of a 3-D vector
00083     // 
00084     inline Vector3 & setY( float y );
00085 
00086     // Set the z element of a 3-D vector
00087     // 
00088     inline Vector3 & setZ( float z );
00089 
00090     // Get the x element of a 3-D vector
00091     // 
00092     inline float getX( ) const;
00093 
00094     // Get the y element of a 3-D vector
00095     // 
00096     inline float getY( ) const;
00097 
00098     // Get the z element of a 3-D vector
00099     // 
00100     inline float getZ( ) const;
00101 
00102     // Set an x, y, or z element of a 3-D vector by index
00103     // 
00104     inline Vector3 & setElem( int idx, float value );
00105 
00106     // Get an x, y, or z element of a 3-D vector by index
00107     // 
00108     inline float getElem( int idx ) const;
00109 
00110     // Subscripting operator to set or get an element
00111     // 
00112     inline float & operator []( int idx );
00113 
00114     // Subscripting operator to get an element
00115     // 
00116     inline float operator []( int idx ) const;
00117 
00118     // Add two 3-D vectors
00119     // 
00120     inline const Vector3 operator +( const Vector3 & vec ) const;
00121 
00122     // Subtract a 3-D vector from another 3-D vector
00123     // 
00124     inline const Vector3 operator -( const Vector3 & vec ) const;
00125 
00126     // Add a 3-D vector to a 3-D point
00127     // 
00128     inline const Point3 operator +( const Point3 & pnt ) const;
00129 
00130     // Multiply a 3-D vector by a scalar
00131     // 
00132     inline const Vector3 operator *( float scalar ) const;
00133 
00134     // Divide a 3-D vector by a scalar
00135     // 
00136     inline const Vector3 operator /( float scalar ) const;
00137 
00138     // Perform compound assignment and addition with a 3-D vector
00139     // 
00140     inline Vector3 & operator +=( const Vector3 & vec );
00141 
00142     // Perform compound assignment and subtraction by a 3-D vector
00143     // 
00144     inline Vector3 & operator -=( const Vector3 & vec );
00145 
00146     // Perform compound assignment and multiplication by a scalar
00147     // 
00148     inline Vector3 & operator *=( float scalar );
00149 
00150     // Perform compound assignment and division by a scalar
00151     // 
00152     inline Vector3 & operator /=( float scalar );
00153 
00154     // Negate all elements of a 3-D vector
00155     // 
00156     inline const Vector3 operator -( ) const;
00157 
00158     // Construct x axis
00159     // 
00160     static inline const Vector3 xAxis( );
00161 
00162     // Construct y axis
00163     // 
00164     static inline const Vector3 yAxis( );
00165 
00166     // Construct z axis
00167     // 
00168     static inline const Vector3 zAxis( );
00169 
00170 }
00171 #ifdef __GNUC__
00172 __attribute__ ((aligned(16)))
00173 #endif
00174 ;
00175 
00176 // Multiply a 3-D vector by a scalar
00177 // 
00178 inline const Vector3 operator *( float scalar, const Vector3 & vec );
00179 
00180 // Multiply two 3-D vectors per element
00181 // 
00182 inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 );
00183 
00184 // Divide two 3-D vectors per element
00185 // NOTE: 
00186 // Floating-point behavior matches standard library function divf4.
00187 // 
00188 inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 );
00189 
00190 // Compute the reciprocal of a 3-D vector per element
00191 // NOTE: 
00192 // Floating-point behavior matches standard library function recipf4.
00193 // 
00194 inline const Vector3 recipPerElem( const Vector3 & vec );
00195 
00196 // Compute the square root of a 3-D vector per element
00197 // NOTE: 
00198 // Floating-point behavior matches standard library function sqrtf4.
00199 // 
00200 inline const Vector3 sqrtPerElem( const Vector3 & vec );
00201 
00202 // Compute the reciprocal square root of a 3-D vector per element
00203 // NOTE: 
00204 // Floating-point behavior matches standard library function rsqrtf4.
00205 // 
00206 inline const Vector3 rsqrtPerElem( const Vector3 & vec );
00207 
00208 // Compute the absolute value of a 3-D vector per element
00209 // 
00210 inline const Vector3 absPerElem( const Vector3 & vec );
00211 
00212 // Copy sign from one 3-D vector to another, per element
00213 // 
00214 inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 );
00215 
00216 // Maximum of two 3-D vectors per element
00217 // 
00218 inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 );
00219 
00220 // Minimum of two 3-D vectors per element
00221 // 
00222 inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 );
00223 
00224 // Maximum element of a 3-D vector
00225 // 
00226 inline float maxElem( const Vector3 & vec );
00227 
00228 // Minimum element of a 3-D vector
00229 // 
00230 inline float minElem( const Vector3 & vec );
00231 
00232 // Compute the sum of all elements of a 3-D vector
00233 // 
00234 inline float sum( const Vector3 & vec );
00235 
00236 // Compute the dot product of two 3-D vectors
00237 // 
00238 inline float dot( const Vector3 & vec0, const Vector3 & vec1 );
00239 
00240 // Compute the square of the length of a 3-D vector
00241 // 
00242 inline float lengthSqr( const Vector3 & vec );
00243 
00244 // Compute the length of a 3-D vector
00245 // 
00246 inline float length( const Vector3 & vec );
00247 
00248 // Normalize a 3-D vector
00249 // NOTE: 
00250 // The result is unpredictable when all elements of vec are at or near zero.
00251 // 
00252 inline const Vector3 normalize( const Vector3 & vec );
00253 
00254 // Compute cross product of two 3-D vectors
00255 // 
00256 inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 );
00257 
00258 // Outer product of two 3-D vectors
00259 // 
00260 inline const Matrix3 outer( const Vector3 & vec0, const Vector3 & vec1 );
00261 
00262 // Pre-multiply a row vector by a 3x3 matrix
00263 // 
00264 inline const Vector3 rowMul( const Vector3 & vec, const Matrix3 & mat );
00265 
00266 // Cross-product matrix of a 3-D vector
00267 // 
00268 inline const Matrix3 crossMatrix( const Vector3 & vec );
00269 
00270 // Create cross-product matrix and multiply
00271 // NOTE: 
00272 // Faster than separately creating a cross-product matrix and multiplying.
00273 // 
00274 inline const Matrix3 crossMatrixMul( const Vector3 & vec, const Matrix3 & mat );
00275 
00276 // Linear interpolation between two 3-D vectors
00277 // NOTE: 
00278 // Does not clamp t between 0 and 1.
00279 // 
00280 inline const Vector3 lerp( float t, const Vector3 & vec0, const Vector3 & vec1 );
00281 
00282 // Spherical linear interpolation between two 3-D vectors
00283 // NOTE: 
00284 // The result is unpredictable if the vectors point in opposite directions.
00285 // Does not clamp t between 0 and 1.
00286 // 
00287 inline const Vector3 slerp( float t, const Vector3 & unitVec0, const Vector3 & unitVec1 );
00288 
00289 // Conditionally select between two 3-D vectors
00290 // 
00291 inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, bool select1 );
00292 
00293 // Load x, y, and z elements from the first three words of a float array.
00294 // 
00295 // 
00296 inline void loadXYZ( Vector3 & vec, const float * fptr );
00297 
00298 // Store x, y, and z elements of a 3-D vector in the first three words of a float array.
00299 // Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed
00300 // 
00301 inline void storeXYZ( const Vector3 & vec, float * fptr );
00302 
00303 // Load three-half-floats as a 3-D vector
00304 // NOTE: 
00305 // This transformation does not support either denormalized numbers or NaNs.
00306 // 
00307 inline void loadHalfFloats( Vector3 & vec, const unsigned short * hfptr );
00308 
00309 // 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.
00310 // NOTE: 
00311 // 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.
00312 // 
00313 inline void storeHalfFloats( const Vector3 & vec, unsigned short * hfptr );
00314 
00315 #ifdef _VECTORMATH_DEBUG
00316 
00317 // Print a 3-D vector
00318 // NOTE: 
00319 // Function is only defined when _VECTORMATH_DEBUG is defined.
00320 // 
00321 inline void print( const Vector3 & vec );
00322 
00323 // Print a 3-D vector and an associated string identifier
00324 // NOTE: 
00325 // Function is only defined when _VECTORMATH_DEBUG is defined.
00326 // 
00327 inline void print( const Vector3 & vec, const char * name );
00328 
00329 #endif
00330 
00331 // A 4-D vector in array-of-structures format
00332 //
00333 class Vector4
00334 {
00335     float mX;
00336     float mY;
00337     float mZ;
00338     float mW;
00339 
00340 public:
00341     // Default constructor; does no initialization
00342     // 
00343     inline Vector4( ) { };
00344 
00345     // Copy a 4-D vector
00346     // 
00347     inline Vector4( const Vector4 & vec );
00348 
00349     // Construct a 4-D vector from x, y, z, and w elements
00350     // 
00351     inline Vector4( float x, float y, float z, float w );
00352 
00353     // Construct a 4-D vector from a 3-D vector and a scalar
00354     // 
00355     inline Vector4( const Vector3 & xyz, float w );
00356 
00357     // Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0
00358     // 
00359     explicit inline Vector4( const Vector3 & vec );
00360 
00361     // Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1
00362     // 
00363     explicit inline Vector4( const Point3 & pnt );
00364 
00365     // Copy elements from a quaternion into a 4-D vector
00366     // 
00367     explicit inline Vector4( const Quat & quat );
00368 
00369     // Set all elements of a 4-D vector to the same scalar value
00370     // 
00371     explicit inline Vector4( float scalar );
00372 
00373     // Assign one 4-D vector to another
00374     // 
00375     inline Vector4 & operator =( const Vector4 & vec );
00376 
00377     // Set the x, y, and z elements of a 4-D vector
00378     // NOTE: 
00379     // This function does not change the w element.
00380     // 
00381     inline Vector4 & setXYZ( const Vector3 & vec );
00382 
00383     // Get the x, y, and z elements of a 4-D vector
00384     // 
00385     inline const Vector3 getXYZ( ) const;
00386 
00387     // Set the x element of a 4-D vector
00388     // 
00389     inline Vector4 & setX( float x );
00390 
00391     // Set the y element of a 4-D vector
00392     // 
00393     inline Vector4 & setY( float y );
00394 
00395     // Set the z element of a 4-D vector
00396     // 
00397     inline Vector4 & setZ( float z );
00398 
00399     // Set the w element of a 4-D vector
00400     // 
00401     inline Vector4 & setW( float w );
00402 
00403     // Get the x element of a 4-D vector
00404     // 
00405     inline float getX( ) const;
00406 
00407     // Get the y element of a 4-D vector
00408     // 
00409     inline float getY( ) const;
00410 
00411     // Get the z element of a 4-D vector
00412     // 
00413     inline float getZ( ) const;
00414 
00415     // Get the w element of a 4-D vector
00416     // 
00417     inline float getW( ) const;
00418 
00419     // Set an x, y, z, or w element of a 4-D vector by index
00420     // 
00421     inline Vector4 & setElem( int idx, float value );
00422 
00423     // Get an x, y, z, or w element of a 4-D vector by index
00424     // 
00425     inline float getElem( int idx ) const;
00426 
00427     // Subscripting operator to set or get an element
00428     // 
00429     inline float & operator []( int idx );
00430 
00431     // Subscripting operator to get an element
00432     // 
00433     inline float operator []( int idx ) const;
00434 
00435     // Add two 4-D vectors
00436     // 
00437     inline const Vector4 operator +( const Vector4 & vec ) const;
00438 
00439     // Subtract a 4-D vector from another 4-D vector
00440     // 
00441     inline const Vector4 operator -( const Vector4 & vec ) const;
00442 
00443     // Multiply a 4-D vector by a scalar
00444     // 
00445     inline const Vector4 operator *( float scalar ) const;
00446 
00447     // Divide a 4-D vector by a scalar
00448     // 
00449     inline const Vector4 operator /( float scalar ) const;
00450 
00451     // Perform compound assignment and addition with a 4-D vector
00452     // 
00453     inline Vector4 & operator +=( const Vector4 & vec );
00454 
00455     // Perform compound assignment and subtraction by a 4-D vector
00456     // 
00457     inline Vector4 & operator -=( const Vector4 & vec );
00458 
00459     // Perform compound assignment and multiplication by a scalar
00460     // 
00461     inline Vector4 & operator *=( float scalar );
00462 
00463     // Perform compound assignment and division by a scalar
00464     // 
00465     inline Vector4 & operator /=( float scalar );
00466 
00467     // Negate all elements of a 4-D vector
00468     // 
00469     inline const Vector4 operator -( ) const;
00470 
00471     // Construct x axis
00472     // 
00473     static inline const Vector4 xAxis( );
00474 
00475     // Construct y axis
00476     // 
00477     static inline const Vector4 yAxis( );
00478 
00479     // Construct z axis
00480     // 
00481     static inline const Vector4 zAxis( );
00482 
00483     // Construct w axis
00484     // 
00485     static inline const Vector4 wAxis( );
00486 
00487 }
00488 #ifdef __GNUC__
00489 __attribute__ ((aligned(16)))
00490 #endif
00491 ;
00492 
00493 // Multiply a 4-D vector by a scalar
00494 // 
00495 inline const Vector4 operator *( float scalar, const Vector4 & vec );
00496 
00497 // Multiply two 4-D vectors per element
00498 // 
00499 inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 );
00500 
00501 // Divide two 4-D vectors per element
00502 // NOTE: 
00503 // Floating-point behavior matches standard library function divf4.
00504 // 
00505 inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 );
00506 
00507 // Compute the reciprocal of a 4-D vector per element
00508 // NOTE: 
00509 // Floating-point behavior matches standard library function recipf4.
00510 // 
00511 inline const Vector4 recipPerElem( const Vector4 & vec );
00512 
00513 // Compute the square root of a 4-D vector per element
00514 // NOTE: 
00515 // Floating-point behavior matches standard library function sqrtf4.
00516 // 
00517 inline const Vector4 sqrtPerElem( const Vector4 & vec );
00518 
00519 // Compute the reciprocal square root of a 4-D vector per element
00520 // NOTE: 
00521 // Floating-point behavior matches standard library function rsqrtf4.
00522 // 
00523 inline const Vector4 rsqrtPerElem( const Vector4 & vec );
00524 
00525 // Compute the absolute value of a 4-D vector per element
00526 // 
00527 inline const Vector4 absPerElem( const Vector4 & vec );
00528 
00529 // Copy sign from one 4-D vector to another, per element
00530 // 
00531 inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 );
00532 
00533 // Maximum of two 4-D vectors per element
00534 // 
00535 inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 );
00536 
00537 // Minimum of two 4-D vectors per element
00538 // 
00539 inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 );
00540 
00541 // Maximum element of a 4-D vector
00542 // 
00543 inline float maxElem( const Vector4 & vec );
00544 
00545 // Minimum element of a 4-D vector
00546 // 
00547 inline float minElem( const Vector4 & vec );
00548 
00549 // Compute the sum of all elements of a 4-D vector
00550 // 
00551 inline float sum( const Vector4 & vec );
00552 
00553 // Compute the dot product of two 4-D vectors
00554 // 
00555 inline float dot( const Vector4 & vec0, const Vector4 & vec1 );
00556 
00557 // Compute the square of the length of a 4-D vector
00558 // 
00559 inline float lengthSqr( const Vector4 & vec );
00560 
00561 // Compute the length of a 4-D vector
00562 // 
00563 inline float length( const Vector4 & vec );
00564 
00565 // Normalize a 4-D vector
00566 // NOTE: 
00567 // The result is unpredictable when all elements of vec are at or near zero.
00568 // 
00569 inline const Vector4 normalize( const Vector4 & vec );
00570 
00571 // Outer product of two 4-D vectors
00572 // 
00573 inline const Matrix4 outer( const Vector4 & vec0, const Vector4 & vec1 );
00574 
00575 // Linear interpolation between two 4-D vectors
00576 // NOTE: 
00577 // Does not clamp t between 0 and 1.
00578 // 
00579 inline const Vector4 lerp( float t, const Vector4 & vec0, const Vector4 & vec1 );
00580 
00581 // Spherical linear interpolation between two 4-D vectors
00582 // NOTE: 
00583 // The result is unpredictable if the vectors point in opposite directions.
00584 // Does not clamp t between 0 and 1.
00585 // 
00586 inline const Vector4 slerp( float t, const Vector4 & unitVec0, const Vector4 & unitVec1 );
00587 
00588 // Conditionally select between two 4-D vectors
00589 // 
00590 inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, bool select1 );
00591 
00592 // Load x, y, z, and w elements from the first four words of a float array.
00593 // 
00594 // 
00595 inline void loadXYZW( Vector4 & vec, const float * fptr );
00596 
00597 // Store x, y, z, and w elements of a 4-D vector in the first four words of a float array.
00598 // Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed
00599 // 
00600 inline void storeXYZW( const Vector4 & vec, float * fptr );
00601 
00602 // Load four-half-floats as a 4-D vector
00603 // NOTE: 
00604 // This transformation does not support either denormalized numbers or NaNs.
00605 // 
00606 inline void loadHalfFloats( Vector4 & vec, const unsigned short * hfptr );
00607 
00608 // 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.
00609 // NOTE: 
00610 // 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.
00611 // 
00612 inline void storeHalfFloats( const Vector4 & vec, unsigned short * hfptr );
00613 
00614 #ifdef _VECTORMATH_DEBUG
00615 
00616 // Print a 4-D vector
00617 // NOTE: 
00618 // Function is only defined when _VECTORMATH_DEBUG is defined.
00619 // 
00620 inline void print( const Vector4 & vec );
00621 
00622 // Print a 4-D vector and an associated string identifier
00623 // NOTE: 
00624 // Function is only defined when _VECTORMATH_DEBUG is defined.
00625 // 
00626 inline void print( const Vector4 & vec, const char * name );
00627 
00628 #endif
00629 
00630 // A 3-D point in array-of-structures format
00631 //
00632 class Point3
00633 {
00634     float mX;
00635     float mY;
00636     float mZ;
00637 #ifndef __GNUC__
00638     float d;
00639 #endif
00640 
00641 public:
00642     // Default constructor; does no initialization
00643     // 
00644     inline Point3( ) { };
00645 
00646     // Copy a 3-D point
00647     // 
00648     inline Point3( const Point3 & pnt );
00649 
00650     // Construct a 3-D point from x, y, and z elements
00651     // 
00652     inline Point3( float x, float y, float z );
00653 
00654     // Copy elements from a 3-D vector into a 3-D point
00655     // 
00656     explicit inline Point3( const Vector3 & vec );
00657 
00658     // Set all elements of a 3-D point to the same scalar value
00659     // 
00660     explicit inline Point3( float scalar );
00661 
00662     // Assign one 3-D point to another
00663     // 
00664     inline Point3 & operator =( const Point3 & pnt );
00665 
00666     // Set the x element of a 3-D point
00667     // 
00668     inline Point3 & setX( float x );
00669 
00670     // Set the y element of a 3-D point
00671     // 
00672     inline Point3 & setY( float y );
00673 
00674     // Set the z element of a 3-D point
00675     // 
00676     inline Point3 & setZ( float z );
00677 
00678     // Get the x element of a 3-D point
00679     // 
00680     inline float getX( ) const;
00681 
00682     // Get the y element of a 3-D point
00683     // 
00684     inline float getY( ) const;
00685 
00686     // Get the z element of a 3-D point
00687     // 
00688     inline float getZ( ) const;
00689 
00690     // Set an x, y, or z element of a 3-D point by index
00691     // 
00692     inline Point3 & setElem( int idx, float value );
00693 
00694     // Get an x, y, or z element of a 3-D point by index
00695     // 
00696     inline float getElem( int idx ) const;
00697 
00698     // Subscripting operator to set or get an element
00699     // 
00700     inline float & operator []( int idx );
00701 
00702     // Subscripting operator to get an element
00703     // 
00704     inline float operator []( int idx ) const;
00705 
00706     // Subtract a 3-D point from another 3-D point
00707     // 
00708     inline const Vector3 operator -( const Point3 & pnt ) const;
00709 
00710     // Add a 3-D point to a 3-D vector
00711     // 
00712     inline const Point3 operator +( const Vector3 & vec ) const;
00713 
00714     // Subtract a 3-D vector from a 3-D point
00715     // 
00716     inline const Point3 operator -( const Vector3 & vec ) const;
00717 
00718     // Perform compound assignment and addition with a 3-D vector
00719     // 
00720     inline Point3 & operator +=( const Vector3 & vec );
00721 
00722     // Perform compound assignment and subtraction by a 3-D vector
00723     // 
00724     inline Point3 & operator -=( const Vector3 & vec );
00725 
00726 }
00727 #ifdef __GNUC__
00728 __attribute__ ((aligned(16)))
00729 #endif
00730 ;
00731 
00732 // Multiply two 3-D points per element
00733 // 
00734 inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 );
00735 
00736 // Divide two 3-D points per element
00737 // NOTE: 
00738 // Floating-point behavior matches standard library function divf4.
00739 // 
00740 inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 );
00741 
00742 // Compute the reciprocal of a 3-D point per element
00743 // NOTE: 
00744 // Floating-point behavior matches standard library function recipf4.
00745 // 
00746 inline const Point3 recipPerElem( const Point3 & pnt );
00747 
00748 // Compute the square root of a 3-D point per element
00749 // NOTE: 
00750 // Floating-point behavior matches standard library function sqrtf4.
00751 // 
00752 inline const Point3 sqrtPerElem( const Point3 & pnt );
00753 
00754 // Compute the reciprocal square root of a 3-D point per element
00755 // NOTE: 
00756 // Floating-point behavior matches standard library function rsqrtf4.
00757 // 
00758 inline const Point3 rsqrtPerElem( const Point3 & pnt );
00759 
00760 // Compute the absolute value of a 3-D point per element
00761 // 
00762 inline const Point3 absPerElem( const Point3 & pnt );
00763 
00764 // Copy sign from one 3-D point to another, per element
00765 // 
00766 inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 );
00767 
00768 // Maximum of two 3-D points per element
00769 // 
00770 inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 );
00771 
00772 // Minimum of two 3-D points per element
00773 // 
00774 inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 );
00775 
00776 // Maximum element of a 3-D point
00777 // 
00778 inline float maxElem( const Point3 & pnt );
00779 
00780 // Minimum element of a 3-D point
00781 // 
00782 inline float minElem( const Point3 & pnt );
00783 
00784 // Compute the sum of all elements of a 3-D point
00785 // 
00786 inline float sum( const Point3 & pnt );
00787 
00788 // Apply uniform scale to a 3-D point
00789 // 
00790 inline const Point3 scale( const Point3 & pnt, float scaleVal );
00791 
00792 // Apply non-uniform scale to a 3-D point
00793 // 
00794 inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec );
00795 
00796 // Scalar projection of a 3-D point on a unit-length 3-D vector
00797 // 
00798 inline float projection( const Point3 & pnt, const Vector3 & unitVec );
00799 
00800 // Compute the square of the distance of a 3-D point from the coordinate-system origin
00801 // 
00802 inline float distSqrFromOrigin( const Point3 & pnt );
00803 
00804 // Compute the distance of a 3-D point from the coordinate-system origin
00805 // 
00806 inline float distFromOrigin( const Point3 & pnt );
00807 
00808 // Compute the square of the distance between two 3-D points
00809 // 
00810 inline float distSqr( const Point3 & pnt0, const Point3 & pnt1 );
00811 
00812 // Compute the distance between two 3-D points
00813 // 
00814 inline float dist( const Point3 & pnt0, const Point3 & pnt1 );
00815 
00816 // Linear interpolation between two 3-D points
00817 // NOTE: 
00818 // Does not clamp t between 0 and 1.
00819 // 
00820 inline const Point3 lerp( float t, const Point3 & pnt0, const Point3 & pnt1 );
00821 
00822 // Conditionally select between two 3-D points
00823 // 
00824 inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, bool select1 );
00825 
00826 // Load x, y, and z elements from the first three words of a float array.
00827 // 
00828 // 
00829 inline void loadXYZ( Point3 & pnt, const float * fptr );
00830 
00831 // Store x, y, and z elements of a 3-D point in the first three words of a float array.
00832 // Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed
00833 // 
00834 inline void storeXYZ( const Point3 & pnt, float * fptr );
00835 
00836 // Load three-half-floats as a 3-D point
00837 // NOTE: 
00838 // This transformation does not support either denormalized numbers or NaNs.
00839 // 
00840 inline void loadHalfFloats( Point3 & pnt, const unsigned short * hfptr );
00841 
00842 // 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.
00843 // NOTE: 
00844 // 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.
00845 // 
00846 inline void storeHalfFloats( const Point3 & pnt, unsigned short * hfptr );
00847 
00848 #ifdef _VECTORMATH_DEBUG
00849 
00850 // Print a 3-D point
00851 // NOTE: 
00852 // Function is only defined when _VECTORMATH_DEBUG is defined.
00853 // 
00854 inline void print( const Point3 & pnt );
00855 
00856 // Print a 3-D point and an associated string identifier
00857 // NOTE: 
00858 // Function is only defined when _VECTORMATH_DEBUG is defined.
00859 // 
00860 inline void print( const Point3 & pnt, const char * name );
00861 
00862 #endif
00863 
00864 // A quaternion in array-of-structures format
00865 //
00866 class Quat
00867 {
00868     float mX;
00869     float mY;
00870     float mZ;
00871     float mW;
00872 
00873 public:
00874     // Default constructor; does no initialization
00875     // 
00876     inline Quat( ) { };
00877 
00878     // Copy a quaternion
00879     // 
00880     inline Quat( const Quat & quat );
00881 
00882     // Construct a quaternion from x, y, z, and w elements
00883     // 
00884     inline Quat( float x, float y, float z, float w );
00885 
00886     // Construct a quaternion from a 3-D vector and a scalar
00887     // 
00888     inline Quat( const Vector3 & xyz, float w );
00889 
00890     // Copy elements from a 4-D vector into a quaternion
00891     // 
00892     explicit inline Quat( const Vector4 & vec );
00893 
00894     // Convert a rotation matrix to a unit-length quaternion
00895     // 
00896     explicit inline Quat( const Matrix3 & rotMat );
00897 
00898     // Set all elements of a quaternion to the same scalar value
00899     // 
00900     explicit inline Quat( float scalar );
00901 
00902     // Assign one quaternion to another
00903     // 
00904     inline Quat & operator =( const Quat & quat );
00905 
00906     // Set the x, y, and z elements of a quaternion
00907     // NOTE: 
00908     // This function does not change the w element.
00909     // 
00910     inline Quat & setXYZ( const Vector3 & vec );
00911 
00912     // Get the x, y, and z elements of a quaternion
00913     // 
00914     inline const Vector3 getXYZ( ) const;
00915 
00916     // Set the x element of a quaternion
00917     // 
00918     inline Quat & setX( float x );
00919 
00920     // Set the y element of a quaternion
00921     // 
00922     inline Quat & setY( float y );
00923 
00924     // Set the z element of a quaternion
00925     // 
00926     inline Quat & setZ( float z );
00927 
00928     // Set the w element of a quaternion
00929     // 
00930     inline Quat & setW( float w );
00931 
00932     // Get the x element of a quaternion
00933     // 
00934     inline float getX( ) const;
00935 
00936     // Get the y element of a quaternion
00937     // 
00938     inline float getY( ) const;
00939 
00940     // Get the z element of a quaternion
00941     // 
00942     inline float getZ( ) const;
00943 
00944     // Get the w element of a quaternion
00945     // 
00946     inline float getW( ) const;
00947 
00948     // Set an x, y, z, or w element of a quaternion by index
00949     // 
00950     inline Quat & setElem( int idx, float value );
00951 
00952     // Get an x, y, z, or w element of a quaternion by index
00953     // 
00954     inline float getElem( int idx ) const;
00955 
00956     // Subscripting operator to set or get an element
00957     // 
00958     inline float & operator []( int idx );
00959 
00960     // Subscripting operator to get an element
00961     // 
00962     inline float operator []( int idx ) const;
00963 
00964     // Add two quaternions
00965     // 
00966     inline const Quat operator +( const Quat & quat ) const;
00967 
00968     // Subtract a quaternion from another quaternion
00969     // 
00970     inline const Quat operator -( const Quat & quat ) const;
00971 
00972     // Multiply two quaternions
00973     // 
00974     inline const Quat operator *( const Quat & quat ) const;
00975 
00976     // Multiply a quaternion by a scalar
00977     // 
00978     inline const Quat operator *( float scalar ) const;
00979 
00980     // Divide a quaternion by a scalar
00981     // 
00982     inline const Quat operator /( float scalar ) const;
00983 
00984     // Perform compound assignment and addition with a quaternion
00985     // 
00986     inline Quat & operator +=( const Quat & quat );
00987 
00988     // Perform compound assignment and subtraction by a quaternion
00989     // 
00990     inline Quat & operator -=( const Quat & quat );
00991 
00992     // Perform compound assignment and multiplication by a quaternion
00993     // 
00994     inline Quat & operator *=( const Quat & quat );
00995 
00996     // Perform compound assignment and multiplication by a scalar
00997     // 
00998     inline Quat & operator *=( float scalar );
00999 
01000     // Perform compound assignment and division by a scalar
01001     // 
01002     inline Quat & operator /=( float scalar );
01003 
01004     // Negate all elements of a quaternion
01005     // 
01006     inline const Quat operator -( ) const;
01007 
01008     // Construct an identity quaternion
01009     // 
01010     static inline const Quat identity( );
01011 
01012     // Construct a quaternion to rotate between two unit-length 3-D vectors
01013     // NOTE: 
01014     // The result is unpredictable if unitVec0 and unitVec1 point in opposite directions.
01015     // 
01016     static inline const Quat rotation( const Vector3 & unitVec0, const Vector3 & unitVec1 );
01017 
01018     // Construct a quaternion to rotate around a unit-length 3-D vector
01019     // 
01020     static inline const Quat rotation( float radians, const Vector3 & unitVec );
01021 
01022     // Construct a quaternion to rotate around the x axis
01023     // 
01024     static inline const Quat rotationX( float radians );
01025 
01026     // Construct a quaternion to rotate around the y axis
01027     // 
01028     static inline const Quat rotationY( float radians );
01029 
01030     // Construct a quaternion to rotate around the z axis
01031     // 
01032     static inline const Quat rotationZ( float radians );
01033 
01034 }
01035 #ifdef __GNUC__
01036 __attribute__ ((aligned(16)))
01037 #endif
01038 ;
01039 
01040 // Multiply a quaternion by a scalar
01041 // 
01042 inline const Quat operator *( float scalar, const Quat & quat );
01043 
01044 // Compute the conjugate of a quaternion
01045 // 
01046 inline const Quat conj( const Quat & quat );
01047 
01048 // Use a unit-length quaternion to rotate a 3-D vector
01049 // 
01050 inline const Vector3 rotate( const Quat & unitQuat, const Vector3 & vec );
01051 
01052 // Compute the dot product of two quaternions
01053 // 
01054 inline float dot( const Quat & quat0, const Quat & quat1 );
01055 
01056 // Compute the norm of a quaternion
01057 // 
01058 inline float norm( const Quat & quat );
01059 
01060 // Compute the length of a quaternion
01061 // 
01062 inline float length( const Quat & quat );
01063 
01064 // Normalize a quaternion
01065 // NOTE: 
01066 // The result is unpredictable when all elements of quat are at or near zero.
01067 // 
01068 inline const Quat normalize( const Quat & quat );
01069 
01070 // Linear interpolation between two quaternions
01071 // NOTE: 
01072 // Does not clamp t between 0 and 1.
01073 // 
01074 inline const Quat lerp( float t, const Quat & quat0, const Quat & quat1 );
01075 
01076 // Spherical linear interpolation between two quaternions
01077 // NOTE: 
01078 // Interpolates along the shortest path between orientations.
01079 // Does not clamp t between 0 and 1.
01080 // 
01081 inline const Quat slerp( float t, const Quat & unitQuat0, const Quat & unitQuat1 );
01082 
01083 // Spherical quadrangle interpolation
01084 // 
01085 inline const Quat squad( float t, const Quat & unitQuat0, const Quat & unitQuat1, const Quat & unitQuat2, const Quat & unitQuat3 );
01086 
01087 // Conditionally select between two quaternions
01088 // 
01089 inline const Quat select( const Quat & quat0, const Quat & quat1, bool select1 );
01090 
01091 // Load x, y, z, and w elements from the first four words of a float array.
01092 // 
01093 // 
01094 inline void loadXYZW( Quat & quat, const float * fptr );
01095 
01096 // Store x, y, z, and w elements of a quaternion in the first four words of a float array.
01097 // Memory area of previous 16 bytes and next 32 bytes from fptr might be accessed
01098 // 
01099 inline void storeXYZW( const Quat & quat, float * fptr );
01100 
01101 #ifdef _VECTORMATH_DEBUG
01102 
01103 // Print a quaternion
01104 // NOTE: 
01105 // Function is only defined when _VECTORMATH_DEBUG is defined.
01106 // 
01107 inline void print( const Quat & quat );
01108 
01109 // Print a quaternion and an associated string identifier
01110 // NOTE: 
01111 // Function is only defined when _VECTORMATH_DEBUG is defined.
01112 // 
01113 inline void print( const Quat & quat, const char * name );
01114 
01115 #endif
01116 
01117 // A 3x3 matrix in array-of-structures format
01118 //
01119 class Matrix3
01120 {
01121     Vector3 mCol0;
01122     Vector3 mCol1;
01123     Vector3 mCol2;
01124 
01125 public:
01126     // Default constructor; does no initialization
01127     // 
01128     inline Matrix3( ) { };
01129 
01130     // Copy a 3x3 matrix
01131     // 
01132     inline Matrix3( const Matrix3 & mat );
01133 
01134     // Construct a 3x3 matrix containing the specified columns
01135     // 
01136     inline Matrix3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2 );
01137 
01138     // Construct a 3x3 rotation matrix from a unit-length quaternion
01139     // 
01140     explicit inline Matrix3( const Quat & unitQuat );
01141 
01142     // Set all elements of a 3x3 matrix to the same scalar value
01143     // 
01144     explicit inline Matrix3( float scalar );
01145 
01146     // Assign one 3x3 matrix to another
01147     // 
01148     inline Matrix3 & operator =( const Matrix3 & mat );
01149 
01150     // Set column 0 of a 3x3 matrix
01151     // 
01152     inline Matrix3 & setCol0( const Vector3 & col0 );
01153 
01154     // Set column 1 of a 3x3 matrix
01155     // 
01156     inline Matrix3 & setCol1( const Vector3 & col1 );
01157 
01158     // Set column 2 of a 3x3 matrix
01159     // 
01160     inline Matrix3 & setCol2( const Vector3 & col2 );
01161 
01162     // Get column 0 of a 3x3 matrix
01163     // 
01164     inline const Vector3 getCol0( ) const;
01165 
01166     // Get column 1 of a 3x3 matrix
01167     // 
01168     inline const Vector3 getCol1( ) const;
01169 
01170     // Get column 2 of a 3x3 matrix
01171     // 
01172     inline const Vector3 getCol2( ) const;
01173 
01174     // Set the column of a 3x3 matrix referred to by the specified index
01175     // 
01176     inline Matrix3 & setCol( int col, const Vector3 & vec );
01177 
01178     // Set the row of a 3x3 matrix referred to by the specified index
01179     // 
01180     inline Matrix3 & setRow( int row, const Vector3 & vec );
01181 
01182     // Get the column of a 3x3 matrix referred to by the specified index
01183     // 
01184     inline const Vector3 getCol( int col ) const;
01185 
01186     // Get the row of a 3x3 matrix referred to by the specified index
01187     // 
01188     inline const Vector3 getRow( int row ) const;
01189 
01190     // Subscripting operator to set or get a column
01191     // 
01192     inline Vector3 & operator []( int col );
01193 
01194     // Subscripting operator to get a column
01195     // 
01196     inline const Vector3 operator []( int col ) const;
01197 
01198     // Set the element of a 3x3 matrix referred to by column and row indices
01199     // 
01200     inline Matrix3 & setElem( int col, int row, float val );
01201 
01202     // Get the element of a 3x3 matrix referred to by column and row indices
01203     // 
01204     inline float getElem( int col, int row ) const;
01205 
01206     // Add two 3x3 matrices
01207     // 
01208     inline const Matrix3 operator +( const Matrix3 & mat ) const;
01209 
01210     // Subtract a 3x3 matrix from another 3x3 matrix
01211     // 
01212     inline const Matrix3 operator -( const Matrix3 & mat ) const;
01213 
01214     // Negate all elements of a 3x3 matrix
01215     // 
01216     inline const Matrix3 operator -( ) const;
01217 
01218     // Multiply a 3x3 matrix by a scalar
01219     // 
01220     inline const Matrix3 operator *( float scalar ) const;
01221 
01222     // Multiply a 3x3 matrix by a 3-D vector
01223     // 
01224     inline const Vector3 operator *( const Vector3 & vec ) const;
01225 
01226     // Multiply two 3x3 matrices
01227     // 
01228     inline const Matrix3 operator *( const Matrix3 & mat ) const;
01229 
01230     // Perform compound assignment and addition with a 3x3 matrix
01231     // 
01232     inline Matrix3 & operator +=( const Matrix3 & mat );
01233 
01234     // Perform compound assignment and subtraction by a 3x3 matrix
01235     // 
01236     inline Matrix3 & operator -=( const Matrix3 & mat );
01237 
01238     // Perform compound assignment and multiplication by a scalar
01239     // 
01240     inline Matrix3 & operator *=( float scalar );
01241 
01242     // Perform compound assignment and multiplication by a 3x3 matrix
01243     // 
01244     inline Matrix3 & operator *=( const Matrix3 & mat );
01245 
01246     // Construct an identity 3x3 matrix
01247     // 
01248     static inline const Matrix3 identity( );
01249 
01250     // Construct a 3x3 matrix to rotate around the x axis
01251     // 
01252     static inline const Matrix3 rotationX( float radians );
01253 
01254     // Construct a 3x3 matrix to rotate around the y axis
01255     // 
01256     static inline const Matrix3 rotationY( float radians );
01257 
01258     // Construct a 3x3 matrix to rotate around the z axis
01259     // 
01260     static inline const Matrix3 rotationZ( float radians );
01261 
01262     // Construct a 3x3 matrix to rotate around the x, y, and z axes
01263     // 
01264     static inline const Matrix3 rotationZYX( const Vector3 & radiansXYZ );
01265 
01266     // Construct a 3x3 matrix to rotate around a unit-length 3-D vector
01267     // 
01268     static inline const Matrix3 rotation( float radians, const Vector3 & unitVec );
01269 
01270     // Construct a rotation matrix from a unit-length quaternion
01271     // 
01272     static inline const Matrix3 rotation( const Quat & unitQuat );
01273 
01274     // Construct a 3x3 matrix to perform scaling
01275     // 
01276     static inline const Matrix3 scale( const Vector3 & scaleVec );
01277 
01278 };
01279 // Multiply a 3x3 matrix by a scalar
01280 // 
01281 inline const Matrix3 operator *( float scalar, const Matrix3 & mat );
01282 
01283 // Append (post-multiply) a scale transformation to a 3x3 matrix
01284 // NOTE: 
01285 // Faster than creating and multiplying a scale transformation matrix.
01286 // 
01287 inline const Matrix3 appendScale( const Matrix3 & mat, const Vector3 & scaleVec );
01288 
01289 // Prepend (pre-multiply) a scale transformation to a 3x3 matrix
01290 // NOTE: 
01291 // Faster than creating and multiplying a scale transformation matrix.
01292 // 
01293 inline const Matrix3 prependScale( const Vector3 & scaleVec, const Matrix3 & mat );
01294 
01295 // Multiply two 3x3 matrices per element
01296 // 
01297 inline const Matrix3 mulPerElem( const Matrix3 & mat0, const Matrix3 & mat1 );
01298 
01299 // Compute the absolute value of a 3x3 matrix per element
01300 // 
01301 inline const Matrix3 absPerElem( const Matrix3 & mat );
01302 
01303 // Transpose of a 3x3 matrix
01304 // 
01305 inline const Matrix3 transpose( const Matrix3 & mat );
01306 
01307 // Compute the inverse of a 3x3 matrix
01308 // NOTE: 
01309 // Result is unpredictable when the determinant of mat is equal to or near 0.
01310 // 
01311 inline const Matrix3 inverse( const Matrix3 & mat );
01312 
01313 // Determinant of a 3x3 matrix
01314 // 
01315 inline float determinant( const Matrix3 & mat );
01316 
01317 // Conditionally select between two 3x3 matrices
01318 // 
01319 inline const Matrix3 select( const Matrix3 & mat0, const Matrix3 & mat1, bool select1 );
01320 
01321 #ifdef _VECTORMATH_DEBUG
01322 
01323 // Print a 3x3 matrix
01324 // NOTE: 
01325 // Function is only defined when _VECTORMATH_DEBUG is defined.
01326 // 
01327 inline void print( const Matrix3 & mat );
01328 
01329 // Print a 3x3 matrix and an associated string identifier
01330 // NOTE: 
01331 // Function is only defined when _VECTORMATH_DEBUG is defined.
01332 // 
01333 inline void print( const Matrix3 & mat, const char * name );
01334 
01335 #endif
01336 
01337 // A 4x4 matrix in array-of-structures format
01338 //
01339 class Matrix4
01340 {
01341     Vector4 mCol0;
01342     Vector4 mCol1;
01343     Vector4 mCol2;
01344     Vector4 mCol3;
01345 
01346 public:
01347     // Default constructor; does no initialization
01348     // 
01349     inline Matrix4( ) { };
01350 
01351     // Copy a 4x4 matrix
01352     // 
01353     inline Matrix4( const Matrix4 & mat );
01354 
01355     // Construct a 4x4 matrix containing the specified columns
01356     // 
01357     inline Matrix4( const Vector4 & col0, const Vector4 & col1, const Vector4 & col2, const Vector4 & col3 );
01358 
01359     // Construct a 4x4 matrix from a 3x4 transformation matrix
01360     // 
01361     explicit inline Matrix4( const Transform3 & mat );
01362 
01363     // Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector
01364     // 
01365     inline Matrix4( const Matrix3 & mat, const Vector3 & translateVec );
01366 
01367     // Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector
01368     // 
01369     inline Matrix4( const Quat & unitQuat, const Vector3 & translateVec );
01370 
01371     // Set all elements of a 4x4 matrix to the same scalar value
01372     // 
01373     explicit inline Matrix4( float scalar );
01374 
01375     // Assign one 4x4 matrix to another
01376     // 
01377     inline Matrix4 & operator =( const Matrix4 & mat );
01378 
01379     // Set the upper-left 3x3 submatrix
01380     // NOTE: 
01381     // This function does not change the bottom row elements.
01382     // 
01383     inline Matrix4 & setUpper3x3( const Matrix3 & mat3 );
01384 
01385     // Get the upper-left 3x3 submatrix of a 4x4 matrix
01386     // 
01387     inline const Matrix3 getUpper3x3( ) const;
01388 
01389     // Set translation component
01390     // NOTE: 
01391     // This function does not change the bottom row elements.
01392     // 
01393     inline Matrix4 & setTranslation( const Vector3 & translateVec );
01394 
01395     // Get the translation component of a 4x4 matrix
01396     // 
01397     inline const Vector3 getTranslation( ) const;
01398 
01399     // Set column 0 of a 4x4 matrix
01400     // 
01401     inline Matrix4 & setCol0( const Vector4 & col0 );
01402 
01403     // Set column 1 of a 4x4 matrix
01404     // 
01405     inline Matrix4 & setCol1( const Vector4 & col1 );
01406 
01407     // Set column 2 of a 4x4 matrix
01408     // 
01409     inline Matrix4 & setCol2( const Vector4 & col2 );
01410 
01411     // Set column 3 of a 4x4 matrix
01412     // 
01413     inline Matrix4 & setCol3( const Vector4 & col3 );
01414 
01415     // Get column 0 of a 4x4 matrix
01416     // 
01417     inline const Vector4 getCol0( ) const;
01418 
01419     // Get column 1 of a 4x4 matrix
01420     // 
01421     inline const Vector4 getCol1( ) const;
01422 
01423     // Get column 2 of a 4x4 matrix
01424     // 
01425     inline const Vector4 getCol2( ) const;
01426 
01427     // Get column 3 of a 4x4 matrix
01428     // 
01429     inline const Vector4 getCol3( ) const;
01430 
01431     // Set the column of a 4x4 matrix referred to by the specified index
01432     // 
01433     inline Matrix4 & setCol( int col, const Vector4 & vec );
01434 
01435     // Set the row of a 4x4 matrix referred to by the specified index
01436     // 
01437     inline Matrix4 & setRow( int row, const Vector4 & vec );
01438 
01439     // Get the column of a 4x4 matrix referred to by the specified index
01440     // 
01441     inline const Vector4 getCol( int col ) const;
01442 
01443     // Get the row of a 4x4 matrix referred to by the specified index
01444     // 
01445     inline const Vector4 getRow( int row ) const;
01446 
01447     // Subscripting operator to set or get a column
01448     // 
01449     inline Vector4 & operator []( int col );
01450 
01451     // Subscripting operator to get a column
01452     // 
01453     inline const Vector4 operator []( int col ) const;
01454 
01455     // Set the element of a 4x4 matrix referred to by column and row indices
01456     // 
01457     inline Matrix4 & setElem( int col, int row, float val );
01458 
01459     // Get the element of a 4x4 matrix referred to by column and row indices
01460     // 
01461     inline float getElem( int col, int row ) const;
01462 
01463     // Add two 4x4 matrices
01464     // 
01465     inline const Matrix4 operator +( const Matrix4 & mat ) const;
01466 
01467     // Subtract a 4x4 matrix from another 4x4 matrix
01468     // 
01469     inline const Matrix4 operator -( const Matrix4 & mat ) const;
01470 
01471     // Negate all elements of a 4x4 matrix
01472     // 
01473     inline const Matrix4 operator -( ) const;
01474 
01475     // Multiply a 4x4 matrix by a scalar
01476     // 
01477     inline const Matrix4 operator *( float scalar ) const;
01478 
01479     // Multiply a 4x4 matrix by a 4-D vector
01480     // 
01481     inline const Vector4 operator *( const Vector4 & vec ) const;
01482 
01483     // Multiply a 4x4 matrix by a 3-D vector
01484     // 
01485     inline const Vector4 operator *( const Vector3 & vec ) const;
01486 
01487     // Multiply a 4x4 matrix by a 3-D point
01488     // 
01489     inline const Vector4 operator *( const Point3 & pnt ) const;
01490 
01491     // Multiply two 4x4 matrices
01492     // 
01493     inline const Matrix4 operator *( const Matrix4 & mat ) const;
01494 
01495     // Multiply a 4x4 matrix by a 3x4 transformation matrix
01496     // 
01497     inline const Matrix4 operator *( const Transform3 & tfrm ) const;
01498 
01499     // Perform compound assignment and addition with a 4x4 matrix
01500     // 
01501     inline Matrix4 & operator +=( const Matrix4 & mat );
01502 
01503     // Perform compound assignment and subtraction by a 4x4 matrix
01504     // 
01505     inline Matrix4 & operator -=( const Matrix4 & mat );
01506 
01507     // Perform compound assignment and multiplication by a scalar
01508     // 
01509     inline Matrix4 & operator *=( float scalar );
01510 
01511     // Perform compound assignment and multiplication by a 4x4 matrix
01512     // 
01513     inline Matrix4 & operator *=( const Matrix4 & mat );
01514 
01515     // Perform compound assignment and multiplication by a 3x4 transformation matrix
01516     // 
01517     inline Matrix4 & operator *=( const Transform3 & tfrm );
01518 
01519     // Construct an identity 4x4 matrix
01520     // 
01521     static inline const Matrix4 identity( );
01522 
01523     // Construct a 4x4 matrix to rotate around the x axis
01524     // 
01525     static inline const Matrix4 rotationX( float radians );
01526 
01527     // Construct a 4x4 matrix to rotate around the y axis
01528     // 
01529     static inline const Matrix4 rotationY( float radians );
01530 
01531     // Construct a 4x4 matrix to rotate around the z axis
01532     // 
01533     static inline const Matrix4 rotationZ( float radians );
01534 
01535     // Construct a 4x4 matrix to rotate around the x, y, and z axes
01536     // 
01537     static inline const Matrix4 rotationZYX( const Vector3 & radiansXYZ );
01538 
01539     // Construct a 4x4 matrix to rotate around a unit-length 3-D vector
01540     // 
01541     static inline const Matrix4 rotation( float radians, const Vector3 & unitVec );
01542 
01543     // Construct a rotation matrix from a unit-length quaternion
01544     // 
01545     static inline const Matrix4 rotation( const Quat & unitQuat );
01546 
01547     // Construct a 4x4 matrix to perform scaling
01548     // 
01549     static inline const Matrix4 scale( const Vector3 & scaleVec );
01550 
01551     // Construct a 4x4 matrix to perform translation
01552     // 
01553     static inline const Matrix4 translation( const Vector3 & translateVec );
01554 
01555     // Construct viewing matrix based on eye position, position looked at, and up direction
01556     // 
01557     static inline const Matrix4 lookAt( const Point3 & eyePos, const Point3 & lookAtPos, const Vector3 & upVec );
01558 
01559     // Construct a perspective projection matrix
01560     // 
01561     static inline const Matrix4 perspective( float fovyRadians, float aspect, float zNear, float zFar );
01562 
01563     // Construct a perspective projection matrix based on frustum
01564     // 
01565     static inline const Matrix4 frustum( float left, float right, float bottom, float top, float zNear, float zFar );
01566 
01567     // Construct an orthographic projection matrix
01568     // 
01569     static inline const Matrix4 orthographic( float left, float right, float bottom, float top, float zNear, float zFar );
01570 
01571 };
01572 // Multiply a 4x4 matrix by a scalar
01573 // 
01574 inline const Matrix4 operator *( float scalar, const Matrix4 & mat );
01575 
01576 // Append (post-multiply) a scale transformation to a 4x4 matrix
01577 // NOTE: 
01578 // Faster than creating and multiplying a scale transformation matrix.
01579 // 
01580 inline const Matrix4 appendScale( const Matrix4 & mat, const Vector3 & scaleVec );
01581 
01582 // Prepend (pre-multiply) a scale transformation to a 4x4 matrix
01583 // NOTE: 
01584 // Faster than creating and multiplying a scale transformation matrix.
01585 // 
01586 inline const Matrix4 prependScale( const Vector3 & scaleVec, const Matrix4 & mat );
01587 
01588 // Multiply two 4x4 matrices per element
01589 // 
01590 inline const Matrix4 mulPerElem( const Matrix4 & mat0, const Matrix4 & mat1 );
01591 
01592 // Compute the absolute value of a 4x4 matrix per element
01593 // 
01594 inline const Matrix4 absPerElem( const Matrix4 & mat );
01595 
01596 // Transpose of a 4x4 matrix
01597 // 
01598 inline const Matrix4 transpose( const Matrix4 & mat );
01599 
01600 // Compute the inverse of a 4x4 matrix
01601 // NOTE: 
01602 // Result is unpredictable when the determinant of mat is equal to or near 0.
01603 // 
01604 inline const Matrix4 inverse( const Matrix4 & mat );
01605 
01606 // Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix
01607 // NOTE: 
01608 // 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.
01609 // 
01610 inline const Matrix4 affineInverse( const Matrix4 & mat );
01611 
01612 // Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix
01613 // NOTE: 
01614 // This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions.
01615 // 
01616 inline const Matrix4 orthoInverse( const Matrix4 & mat );
01617 
01618 // Determinant of a 4x4 matrix
01619 // 
01620 inline float determinant( const Matrix4 & mat );
01621 
01622 // Conditionally select between two 4x4 matrices
01623 // 
01624 inline const Matrix4 select( const Matrix4 & mat0, const Matrix4 & mat1, bool select1 );
01625 
01626 #ifdef _VECTORMATH_DEBUG
01627 
01628 // Print a 4x4 matrix
01629 // NOTE: 
01630 // Function is only defined when _VECTORMATH_DEBUG is defined.
01631 // 
01632 inline void print( const Matrix4 & mat );
01633 
01634 // Print a 4x4 matrix and an associated string identifier
01635 // NOTE: 
01636 // Function is only defined when _VECTORMATH_DEBUG is defined.
01637 // 
01638 inline void print( const Matrix4 & mat, const char * name );
01639 
01640 #endif
01641 
01642 // A 3x4 transformation matrix in array-of-structures format
01643 //
01644 class Transform3
01645 {
01646     Vector3 mCol0;
01647     Vector3 mCol1;
01648     Vector3 mCol2;
01649     Vector3 mCol3;
01650 
01651 public:
01652     // Default constructor; does no initialization
01653     // 
01654     inline Transform3( ) { };
01655 
01656     // Copy a 3x4 transformation matrix
01657     // 
01658     inline Transform3( const Transform3 & tfrm );
01659 
01660     // Construct a 3x4 transformation matrix containing the specified columns
01661     // 
01662     inline Transform3( const Vector3 & col0, const Vector3 & col1, const Vector3 & col2, const Vector3 & col3 );
01663 
01664     // Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector
01665     // 
01666     inline Transform3( const Matrix3 & tfrm, const Vector3 & translateVec );
01667 
01668     // Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector
01669     // 
01670     inline Transform3( const Quat & unitQuat, const Vector3 & translateVec );
01671 
01672     // Set all elements of a 3x4 transformation matrix to the same scalar value
01673     // 
01674     explicit inline Transform3( float scalar );
01675 
01676     // Assign one 3x4 transformation matrix to another
01677     // 
01678     inline Transform3 & operator =( const Transform3 & tfrm );
01679 
01680     // Set the upper-left 3x3 submatrix
01681     // 
01682     inline Transform3 & setUpper3x3( const Matrix3 & mat3 );
01683 
01684     // Get the upper-left 3x3 submatrix of a 3x4 transformation matrix
01685     // 
01686     inline const Matrix3 getUpper3x3( ) const;
01687 
01688     // Set translation component
01689     // 
01690     inline Transform3 & setTranslation( const Vector3 & translateVec );
01691 
01692     // Get the translation component of a 3x4 transformation matrix
01693     // 
01694     inline const Vector3 getTranslation( ) const;
01695 
01696     // Set column 0 of a 3x4 transformation matrix
01697     // 
01698     inline Transform3 & setCol0( const Vector3 & col0 );
01699 
01700     // Set column 1 of a 3x4 transformation matrix
01701     // 
01702     inline Transform3 & setCol1( const Vector3 & col1 );
01703 
01704     // Set column 2 of a 3x4 transformation matrix
01705     // 
01706     inline Transform3 & setCol2( const Vector3 & col2 );
01707 
01708     // Set column 3 of a 3x4 transformation matrix
01709     // 
01710     inline Transform3 & setCol3( const Vector3 & col3 );
01711 
01712     // Get column 0 of a 3x4 transformation matrix
01713     // 
01714     inline const Vector3 getCol0( ) const;
01715 
01716     // Get column 1 of a 3x4 transformation matrix
01717     // 
01718     inline const Vector3 getCol1( ) const;
01719 
01720     // Get column 2 of a 3x4 transformation matrix
01721     // 
01722     inline const Vector3 getCol2( ) const;
01723 
01724     // Get column 3 of a 3x4 transformation matrix
01725     // 
01726     inline const Vector3 getCol3( ) const;
01727 
01728     // Set the column of a 3x4 transformation matrix referred to by the specified index
01729     // 
01730     inline Transform3 & setCol( int col, const Vector3 & vec );
01731 
01732     // Set the row of a 3x4 transformation matrix referred to by the specified index
01733     // 
01734     inline Transform3 & setRow( int row, const Vector4 & vec );
01735 
01736     // Get the column of a 3x4 transformation matrix referred to by the specified index
01737     // 
01738     inline const Vector3 getCol( int col ) const;
01739 
01740     // Get the row of a 3x4 transformation matrix referred to by the specified index
01741     // 
01742     inline const Vector4 getRow( int row ) const;
01743 
01744     // Subscripting operator to set or get a column
01745     // 
01746     inline Vector3 & operator []( int col );
01747 
01748     // Subscripting operator to get a column
01749     // 
01750     inline const Vector3 operator []( int col ) const;
01751 
01752     // Set the element of a 3x4 transformation matrix referred to by column and row indices
01753     // 
01754     inline Transform3 & setElem( int col, int row, float val );
01755 
01756     // Get the element of a 3x4 transformation matrix referred to by column and row indices
01757     // 
01758     inline float getElem( int col, int row ) const;
01759 
01760     // Multiply a 3x4 transformation matrix by a 3-D vector
01761     // 
01762     inline const Vector3 operator *( const Vector3 & vec ) const;
01763 
01764     // Multiply a 3x4 transformation matrix by a 3-D point
01765     // 
01766     inline const Point3 operator *( const Point3 & pnt ) const;
01767 
01768     // Multiply two 3x4 transformation matrices
01769     // 
01770     inline const Transform3 operator *( const Transform3 & tfrm ) const;
01771 
01772     // Perform compound assignment and multiplication by a 3x4 transformation matrix
01773     // 
01774     inline Transform3 & operator *=( const Transform3 & tfrm );
01775 
01776     // Construct an identity 3x4 transformation matrix
01777     // 
01778     static inline const Transform3 identity( );
01779 
01780     // Construct a 3x4 transformation matrix to rotate around the x axis
01781     // 
01782     static inline const Transform3 rotationX( float radians );
01783 
01784     // Construct a 3x4 transformation matrix to rotate around the y axis
01785     // 
01786     static inline const Transform3 rotationY( float radians );
01787 
01788     // Construct a 3x4 transformation matrix to rotate around the z axis
01789     // 
01790     static inline const Transform3 rotationZ( float radians );
01791 
01792     // Construct a 3x4 transformation matrix to rotate around the x, y, and z axes
01793     // 
01794     static inline const Transform3 rotationZYX( const Vector3 & radiansXYZ );
01795 
01796     // Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector
01797     // 
01798     static inline const Transform3 rotation( float radians, const Vector3 & unitVec );
01799 
01800     // Construct a rotation matrix from a unit-length quaternion
01801     // 
01802     static inline const Transform3 rotation( const Quat & unitQuat );
01803 
01804     // Construct a 3x4 transformation matrix to perform scaling
01805     // 
01806     static inline const Transform3 scale( const Vector3 & scaleVec );
01807 
01808     // Construct a 3x4 transformation matrix to perform translation
01809     // 
01810     static inline const Transform3 translation( const Vector3 & translateVec );
01811 
01812 };
01813 // Append (post-multiply) a scale transformation to a 3x4 transformation matrix
01814 // NOTE: 
01815 // Faster than creating and multiplying a scale transformation matrix.
01816 // 
01817 inline const Transform3 appendScale( const Transform3 & tfrm, const Vector3 & scaleVec );
01818 
01819 // Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix
01820 // NOTE: 
01821 // Faster than creating and multiplying a scale transformation matrix.
01822 // 
01823 inline const Transform3 prependScale( const Vector3 & scaleVec, const Transform3 & tfrm );
01824 
01825 // Multiply two 3x4 transformation matrices per element
01826 // 
01827 inline const Transform3 mulPerElem( const Transform3 & tfrm0, const Transform3 & tfrm1 );
01828 
01829 // Compute the absolute value of a 3x4 transformation matrix per element
01830 // 
01831 inline const Transform3 absPerElem( const Transform3 & tfrm );
01832 
01833 // Inverse of a 3x4 transformation matrix
01834 // NOTE: 
01835 // Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0.
01836 // 
01837 inline const Transform3 inverse( const Transform3 & tfrm );
01838 
01839 // Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix
01840 // NOTE: 
01841 // This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions.
01842 // 
01843 inline const Transform3 orthoInverse( const Transform3 & tfrm );
01844 
01845 // Conditionally select between two 3x4 transformation matrices
01846 // 
01847 inline const Transform3 select( const Transform3 & tfrm0, const Transform3 & tfrm1, bool select1 );
01848 
01849 #ifdef _VECTORMATH_DEBUG
01850 
01851 // Print a 3x4 transformation matrix
01852 // NOTE: 
01853 // Function is only defined when _VECTORMATH_DEBUG is defined.
01854 // 
01855 inline void print( const Transform3 & tfrm );
01856 
01857 // Print a 3x4 transformation matrix and an associated string identifier
01858 // NOTE: 
01859 // Function is only defined when _VECTORMATH_DEBUG is defined.
01860 // 
01861 inline void print( const Transform3 & tfrm, const char * name );
01862 
01863 #endif
01864 
01865 } // namespace Aos
01866 } // namespace Vectormath
01867 
01868 #include "vec_aos.h"
01869 #include "quat_aos.h"
01870 #include "mat_aos.h"
01871 
01872 #endif