2 Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
5 Redistribution and use in source and binary forms,
6 with or without modification, are permitted provided that the
7 following conditions are met:
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of the Sony Computer Entertainment Inc nor the names
14 of its contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE.
30 #ifndef _VECTORMATH_SOA_C_SPU_H
31 #define _VECTORMATH_SOA_C_SPU_H
34 #include <spu_intrinsics.h>
35 #include "vectormath_aos.h"
37 #ifdef _VECTORMATH_DEBUG
42 #endif /* __cplusplus */
44 #ifndef _VECTORMATH_SOA_C_TYPES_H
45 #define _VECTORMATH_SOA_C_TYPES_H
47 /* A set of four 3-D vectors in structure-of-arrays format
49 typedef struct _VmathSoaVector3
56 /* A set of four 4-D vectors in structure-of-arrays format
58 typedef struct _VmathSoaVector4
66 /* A set of four 3-D points in structure-of-arrays format
68 typedef struct _VmathSoaPoint3
75 /* A set of four quaternions in structure-of-arrays format
77 typedef struct _VmathSoaQuat
85 /* A set of four 3x3 matrices in structure-of-arrays format
87 typedef struct _VmathSoaMatrix3
94 /* A set of four 4x4 matrices in structure-of-arrays format
96 typedef struct _VmathSoaMatrix4
100 VmathSoaVector4 col2;
101 VmathSoaVector4 col3;
104 /* A set of four 3x4 transformation matrices in structure-of-arrays format
106 typedef struct _VmathSoaTransform3
108 VmathSoaVector3 col0;
109 VmathSoaVector3 col1;
110 VmathSoaVector3 col2;
111 VmathSoaVector3 col3;
112 } VmathSoaTransform3;
119 static inline void vmathSoaV3Copy( VmathSoaVector3 *result, const VmathSoaVector3 *vec );
122 * Construct a 3-D vector from x, y, and z elements
124 static inline void vmathSoaV3MakeFromElems( VmathSoaVector3 *result, vec_float4 x, vec_float4 y, vec_float4 z );
127 * Copy elements from a 3-D point into a 3-D vector
129 static inline void vmathSoaV3MakeFromP3( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt );
132 * Set all elements of a 3-D vector to the same scalar value
134 static inline void vmathSoaV3MakeFromScalar( VmathSoaVector3 *result, vec_float4 scalar );
137 * Replicate an AoS 3-D vector
139 static inline void vmathSoaV3MakeFromAos( VmathSoaVector3 *result, const VmathVector3 *vec );
142 * Insert four AoS 3-D vectors
144 static inline void vmathSoaV3MakeFrom4Aos( VmathSoaVector3 *result, const VmathVector3 *vec0, const VmathVector3 *vec1, const VmathVector3 *vec2, const VmathVector3 *vec3 );
147 * Extract four AoS 3-D vectors
149 static inline void vmathSoaV3Get4Aos( const VmathSoaVector3 *vec, VmathVector3 *result0, VmathVector3 *result1, VmathVector3 *result2, VmathVector3 *result3 );
152 * Set the x element of a 3-D vector
154 static inline void vmathSoaV3SetX( VmathSoaVector3 *result, vec_float4 x );
157 * Set the y element of a 3-D vector
159 static inline void vmathSoaV3SetY( VmathSoaVector3 *result, vec_float4 y );
162 * Set the z element of a 3-D vector
164 static inline void vmathSoaV3SetZ( VmathSoaVector3 *result, vec_float4 z );
167 * Get the x element of a 3-D vector
169 static inline vec_float4 vmathSoaV3GetX( const VmathSoaVector3 *vec );
172 * Get the y element of a 3-D vector
174 static inline vec_float4 vmathSoaV3GetY( const VmathSoaVector3 *vec );
177 * Get the z element of a 3-D vector
179 static inline vec_float4 vmathSoaV3GetZ( const VmathSoaVector3 *vec );
182 * Set an x, y, or z element of a 3-D vector by index
184 static inline void vmathSoaV3SetElem( VmathSoaVector3 *result, int idx, vec_float4 value );
187 * Get an x, y, or z element of a 3-D vector by index
189 static inline vec_float4 vmathSoaV3GetElem( const VmathSoaVector3 *vec, int idx );
192 * Add two 3-D vectors
194 static inline void vmathSoaV3Add( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 );
197 * Subtract a 3-D vector from another 3-D vector
199 static inline void vmathSoaV3Sub( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 );
202 * Add a 3-D vector to a 3-D point
204 static inline void vmathSoaV3AddP3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec, const VmathSoaPoint3 *pnt );
207 * Multiply a 3-D vector by a scalar
209 static inline void vmathSoaV3ScalarMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar );
212 * Divide a 3-D vector by a scalar
214 static inline void vmathSoaV3ScalarDiv( VmathSoaVector3 *result, const VmathSoaVector3 *vec, vec_float4 scalar );
217 * Negate all elements of a 3-D vector
219 static inline void vmathSoaV3Neg( VmathSoaVector3 *result, const VmathSoaVector3 *vec );
224 static inline void vmathSoaV3MakeXAxis( VmathSoaVector3 *result );
229 static inline void vmathSoaV3MakeYAxis( VmathSoaVector3 *result );
234 static inline void vmathSoaV3MakeZAxis( VmathSoaVector3 *result );
237 * Multiply two 3-D vectors per element
239 static inline void vmathSoaV3MulPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 );
242 * Divide two 3-D vectors per element
244 * Floating-point behavior matches standard library function divf4.
246 static inline void vmathSoaV3DivPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 );
249 * Compute the reciprocal of a 3-D vector per element
251 * Floating-point behavior matches standard library function recipf4.
253 static inline void vmathSoaV3RecipPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec );
256 * Compute the square root of a 3-D vector per element
258 * Floating-point behavior matches standard library function sqrtf4.
260 static inline void vmathSoaV3SqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec );
263 * Compute the reciprocal square root of a 3-D vector per element
265 * Floating-point behavior matches standard library function rsqrtf4.
267 static inline void vmathSoaV3RsqrtPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec );
270 * Compute the absolute value of a 3-D vector per element
272 static inline void vmathSoaV3AbsPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec );
275 * Copy sign from one 3-D vector to another, per element
277 static inline void vmathSoaV3CopySignPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 );
280 * Maximum of two 3-D vectors per element
282 static inline void vmathSoaV3MaxPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 );
285 * Minimum of two 3-D vectors per element
287 static inline void vmathSoaV3MinPerElem( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 );
290 * Maximum element of a 3-D vector
292 static inline vec_float4 vmathSoaV3MaxElem( const VmathSoaVector3 *vec );
295 * Minimum element of a 3-D vector
297 static inline vec_float4 vmathSoaV3MinElem( const VmathSoaVector3 *vec );
300 * Compute the sum of all elements of a 3-D vector
302 static inline vec_float4 vmathSoaV3Sum( const VmathSoaVector3 *vec );
305 * Compute the dot product of two 3-D vectors
307 static inline vec_float4 vmathSoaV3Dot( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 );
310 * Compute the square of the length of a 3-D vector
312 static inline vec_float4 vmathSoaV3LengthSqr( const VmathSoaVector3 *vec );
315 * Compute the length of a 3-D vector
317 static inline vec_float4 vmathSoaV3Length( const VmathSoaVector3 *vec );
320 * Normalize a 3-D vector
322 * The result is unpredictable when all elements of vec are at or near zero.
324 static inline void vmathSoaV3Normalize( VmathSoaVector3 *result, const VmathSoaVector3 *vec );
327 * Compute cross product of two 3-D vectors
329 static inline void vmathSoaV3Cross( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 );
332 * Outer product of two 3-D vectors
334 static inline void vmathSoaV3Outer( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 );
337 * Pre-multiply a row vector by a 3x3 matrix
339 static inline void vmathSoaV3RowMul( VmathSoaVector3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat );
342 * Cross-product matrix of a 3-D vector
344 static inline void vmathSoaV3CrossMatrix( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec );
347 * Create cross-product matrix and multiply
349 * Faster than separately creating a cross-product matrix and multiplying.
351 static inline void vmathSoaV3CrossMatrixMul( VmathSoaMatrix3 *result, const VmathSoaVector3 *vec, const VmathSoaMatrix3 *mat );
354 * Linear interpolation between two 3-D vectors
356 * Does not clamp t between 0 and 1.
358 static inline void vmathSoaV3Lerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1 );
361 * Spherical linear interpolation between two 3-D vectors
363 * The result is unpredictable if the vectors point in opposite directions.
364 * Does not clamp t between 0 and 1.
366 static inline void vmathSoaV3Slerp( VmathSoaVector3 *result, vec_float4 t, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 );
369 * Conditionally select between two 3-D vectors
371 * This function uses a conditional select instruction to avoid a branch.
373 static inline void vmathSoaV3Select( VmathSoaVector3 *result, const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_uint4 select1 );
376 * Load four three-float 3-D vectors, stored in three quadwords
378 static inline void vmathSoaV3LoadXYZArray( VmathSoaVector3 *vec, const vec_float4 *threeQuads );
381 * Store four slots of an SoA 3-D vector in three quadwords
383 static inline void vmathSoaV3StoreXYZArray( const VmathSoaVector3 *vec, vec_float4 *threeQuads );
386 * Store eight slots of two SoA 3-D vectors as half-floats
388 static inline void vmathSoaV3StoreHalfFloats( const VmathSoaVector3 *vec0, const VmathSoaVector3 *vec1, vec_ushort8 *threeQuads );
390 #ifdef _VECTORMATH_DEBUG
395 * Function is only defined when _VECTORMATH_DEBUG is defined.
397 static inline void vmathSoaV3Print( const VmathSoaVector3 *vec );
400 * Print a 3-D vector and an associated string identifier
402 * Function is only defined when _VECTORMATH_DEBUG is defined.
404 static inline void vmathSoaV3Prints( const VmathSoaVector3 *vec, const char *name );
411 static inline void vmathSoaV4Copy( VmathSoaVector4 *result, const VmathSoaVector4 *vec );
414 * Construct a 4-D vector from x, y, z, and w elements
416 static inline void vmathSoaV4MakeFromElems( VmathSoaVector4 *result, vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w );
419 * Construct a 4-D vector from a 3-D vector and a scalar
421 static inline void vmathSoaV4MakeFromV3Scalar( VmathSoaVector4 *result, const VmathSoaVector3 *xyz, vec_float4 w );
424 * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0
426 static inline void vmathSoaV4MakeFromV3( VmathSoaVector4 *result, const VmathSoaVector3 *vec );
429 * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1
431 static inline void vmathSoaV4MakeFromP3( VmathSoaVector4 *result, const VmathSoaPoint3 *pnt );
434 * Copy elements from a quaternion into a 4-D vector
436 static inline void vmathSoaV4MakeFromQ( VmathSoaVector4 *result, const VmathSoaQuat *quat );
439 * Set all elements of a 4-D vector to the same scalar value
441 static inline void vmathSoaV4MakeFromScalar( VmathSoaVector4 *result, vec_float4 scalar );
444 * Replicate an AoS 4-D vector
446 static inline void vmathSoaV4MakeFromAos( VmathSoaVector4 *result, const VmathVector4 *vec );
449 * Insert four AoS 4-D vectors
451 static inline void vmathSoaV4MakeFrom4Aos( VmathSoaVector4 *result, const VmathVector4 *vec0, const VmathVector4 *vec1, const VmathVector4 *vec2, const VmathVector4 *vec3 );
454 * Extract four AoS 4-D vectors
456 static inline void vmathSoaV4Get4Aos( const VmathSoaVector4 *vec, VmathVector4 *result0, VmathVector4 *result1, VmathVector4 *result2, VmathVector4 *result3 );
459 * Set the x, y, and z elements of a 4-D vector
461 * This function does not change the w element.
463 static inline void vmathSoaV4SetXYZ( VmathSoaVector4 *result, const VmathSoaVector3 *vec );
466 * Get the x, y, and z elements of a 4-D vector
468 static inline void vmathSoaV4GetXYZ( VmathSoaVector3 *result, const VmathSoaVector4 *vec );
471 * Set the x element of a 4-D vector
473 static inline void vmathSoaV4SetX( VmathSoaVector4 *result, vec_float4 x );
476 * Set the y element of a 4-D vector
478 static inline void vmathSoaV4SetY( VmathSoaVector4 *result, vec_float4 y );
481 * Set the z element of a 4-D vector
483 static inline void vmathSoaV4SetZ( VmathSoaVector4 *result, vec_float4 z );
486 * Set the w element of a 4-D vector
488 static inline void vmathSoaV4SetW( VmathSoaVector4 *result, vec_float4 w );
491 * Get the x element of a 4-D vector
493 static inline vec_float4 vmathSoaV4GetX( const VmathSoaVector4 *vec );
496 * Get the y element of a 4-D vector
498 static inline vec_float4 vmathSoaV4GetY( const VmathSoaVector4 *vec );
501 * Get the z element of a 4-D vector
503 static inline vec_float4 vmathSoaV4GetZ( const VmathSoaVector4 *vec );
506 * Get the w element of a 4-D vector
508 static inline vec_float4 vmathSoaV4GetW( const VmathSoaVector4 *vec );
511 * Set an x, y, z, or w element of a 4-D vector by index
513 static inline void vmathSoaV4SetElem( VmathSoaVector4 *result, int idx, vec_float4 value );
516 * Get an x, y, z, or w element of a 4-D vector by index
518 static inline vec_float4 vmathSoaV4GetElem( const VmathSoaVector4 *vec, int idx );
521 * Add two 4-D vectors
523 static inline void vmathSoaV4Add( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 );
526 * Subtract a 4-D vector from another 4-D vector
528 static inline void vmathSoaV4Sub( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 );
531 * Multiply a 4-D vector by a scalar
533 static inline void vmathSoaV4ScalarMul( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar );
536 * Divide a 4-D vector by a scalar
538 static inline void vmathSoaV4ScalarDiv( VmathSoaVector4 *result, const VmathSoaVector4 *vec, vec_float4 scalar );
541 * Negate all elements of a 4-D vector
543 static inline void vmathSoaV4Neg( VmathSoaVector4 *result, const VmathSoaVector4 *vec );
548 static inline void vmathSoaV4MakeXAxis( VmathSoaVector4 *result );
553 static inline void vmathSoaV4MakeYAxis( VmathSoaVector4 *result );
558 static inline void vmathSoaV4MakeZAxis( VmathSoaVector4 *result );
563 static inline void vmathSoaV4MakeWAxis( VmathSoaVector4 *result );
566 * Multiply two 4-D vectors per element
568 static inline void vmathSoaV4MulPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 );
571 * Divide two 4-D vectors per element
573 * Floating-point behavior matches standard library function divf4.
575 static inline void vmathSoaV4DivPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 );
578 * Compute the reciprocal of a 4-D vector per element
580 * Floating-point behavior matches standard library function recipf4.
582 static inline void vmathSoaV4RecipPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec );
585 * Compute the square root of a 4-D vector per element
587 * Floating-point behavior matches standard library function sqrtf4.
589 static inline void vmathSoaV4SqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec );
592 * Compute the reciprocal square root of a 4-D vector per element
594 * Floating-point behavior matches standard library function rsqrtf4.
596 static inline void vmathSoaV4RsqrtPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec );
599 * Compute the absolute value of a 4-D vector per element
601 static inline void vmathSoaV4AbsPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec );
604 * Copy sign from one 4-D vector to another, per element
606 static inline void vmathSoaV4CopySignPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 );
609 * Maximum of two 4-D vectors per element
611 static inline void vmathSoaV4MaxPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 );
614 * Minimum of two 4-D vectors per element
616 static inline void vmathSoaV4MinPerElem( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 );
619 * Maximum element of a 4-D vector
621 static inline vec_float4 vmathSoaV4MaxElem( const VmathSoaVector4 *vec );
624 * Minimum element of a 4-D vector
626 static inline vec_float4 vmathSoaV4MinElem( const VmathSoaVector4 *vec );
629 * Compute the sum of all elements of a 4-D vector
631 static inline vec_float4 vmathSoaV4Sum( const VmathSoaVector4 *vec );
634 * Compute the dot product of two 4-D vectors
636 static inline vec_float4 vmathSoaV4Dot( const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 );
639 * Compute the square of the length of a 4-D vector
641 static inline vec_float4 vmathSoaV4LengthSqr( const VmathSoaVector4 *vec );
644 * Compute the length of a 4-D vector
646 static inline vec_float4 vmathSoaV4Length( const VmathSoaVector4 *vec );
649 * Normalize a 4-D vector
651 * The result is unpredictable when all elements of vec are at or near zero.
653 static inline void vmathSoaV4Normalize( VmathSoaVector4 *result, const VmathSoaVector4 *vec );
656 * Outer product of two 4-D vectors
658 static inline void vmathSoaV4Outer( VmathSoaMatrix4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 );
661 * Linear interpolation between two 4-D vectors
663 * Does not clamp t between 0 and 1.
665 static inline void vmathSoaV4Lerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1 );
668 * Spherical linear interpolation between two 4-D vectors
670 * The result is unpredictable if the vectors point in opposite directions.
671 * Does not clamp t between 0 and 1.
673 static inline void vmathSoaV4Slerp( VmathSoaVector4 *result, vec_float4 t, const VmathSoaVector4 *unitVec0, const VmathSoaVector4 *unitVec1 );
676 * Conditionally select between two 4-D vectors
678 * This function uses a conditional select instruction to avoid a branch.
680 static inline void vmathSoaV4Select( VmathSoaVector4 *result, const VmathSoaVector4 *vec0, const VmathSoaVector4 *vec1, vec_uint4 select1 );
683 * Store four slots of an SoA 4-D vector as half-floats
685 static inline void vmathSoaV4StoreHalfFloats( const VmathSoaVector4 *vec, vec_ushort8 *twoQuads );
687 #ifdef _VECTORMATH_DEBUG
692 * Function is only defined when _VECTORMATH_DEBUG is defined.
694 static inline void vmathSoaV4Print( const VmathSoaVector4 *vec );
697 * Print a 4-D vector and an associated string identifier
699 * Function is only defined when _VECTORMATH_DEBUG is defined.
701 static inline void vmathSoaV4Prints( const VmathSoaVector4 *vec, const char *name );
708 static inline void vmathSoaP3Copy( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt );
711 * Construct a 3-D point from x, y, and z elements
713 static inline void vmathSoaP3MakeFromElems( VmathSoaPoint3 *result, vec_float4 x, vec_float4 y, vec_float4 z );
716 * Copy elements from a 3-D vector into a 3-D point
718 static inline void vmathSoaP3MakeFromV3( VmathSoaPoint3 *result, const VmathSoaVector3 *vec );
721 * Set all elements of a 3-D point to the same scalar value
723 static inline void vmathSoaP3MakeFromScalar( VmathSoaPoint3 *result, vec_float4 scalar );
726 * Replicate an AoS 3-D point
728 static inline void vmathSoaP3MakeFromAos( VmathSoaPoint3 *result, const VmathPoint3 *pnt );
731 * Insert four AoS 3-D points
733 static inline void vmathSoaP3MakeFrom4Aos( VmathSoaPoint3 *result, const VmathPoint3 *pnt0, const VmathPoint3 *pnt1, const VmathPoint3 *pnt2, const VmathPoint3 *pnt3 );
736 * Extract four AoS 3-D points
738 static inline void vmathSoaP3Get4Aos( const VmathSoaPoint3 *pnt, VmathPoint3 *result0, VmathPoint3 *result1, VmathPoint3 *result2, VmathPoint3 *result3 );
741 * Set the x element of a 3-D point
743 static inline void vmathSoaP3SetX( VmathSoaPoint3 *result, vec_float4 x );
746 * Set the y element of a 3-D point
748 static inline void vmathSoaP3SetY( VmathSoaPoint3 *result, vec_float4 y );
751 * Set the z element of a 3-D point
753 static inline void vmathSoaP3SetZ( VmathSoaPoint3 *result, vec_float4 z );
756 * Get the x element of a 3-D point
758 static inline vec_float4 vmathSoaP3GetX( const VmathSoaPoint3 *pnt );
761 * Get the y element of a 3-D point
763 static inline vec_float4 vmathSoaP3GetY( const VmathSoaPoint3 *pnt );
766 * Get the z element of a 3-D point
768 static inline vec_float4 vmathSoaP3GetZ( const VmathSoaPoint3 *pnt );
771 * Set an x, y, or z element of a 3-D point by index
773 static inline void vmathSoaP3SetElem( VmathSoaPoint3 *result, int idx, vec_float4 value );
776 * Get an x, y, or z element of a 3-D point by index
778 static inline vec_float4 vmathSoaP3GetElem( const VmathSoaPoint3 *pnt, int idx );
781 * Subtract a 3-D point from another 3-D point
783 static inline void vmathSoaP3Sub( VmathSoaVector3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 );
786 * Add a 3-D point to a 3-D vector
788 static inline void vmathSoaP3AddV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec );
791 * Subtract a 3-D vector from a 3-D point
793 static inline void vmathSoaP3SubV3( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *vec );
796 * Multiply two 3-D points per element
798 static inline void vmathSoaP3MulPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 );
801 * Divide two 3-D points per element
803 * Floating-point behavior matches standard library function divf4.
805 static inline void vmathSoaP3DivPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 );
808 * Compute the reciprocal of a 3-D point per element
810 * Floating-point behavior matches standard library function recipf4.
812 static inline void vmathSoaP3RecipPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt );
815 * Compute the square root of a 3-D point per element
817 * Floating-point behavior matches standard library function sqrtf4.
819 static inline void vmathSoaP3SqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt );
822 * Compute the reciprocal square root of a 3-D point per element
824 * Floating-point behavior matches standard library function rsqrtf4.
826 static inline void vmathSoaP3RsqrtPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt );
829 * Compute the absolute value of a 3-D point per element
831 static inline void vmathSoaP3AbsPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt );
834 * Copy sign from one 3-D point to another, per element
836 static inline void vmathSoaP3CopySignPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 );
839 * Maximum of two 3-D points per element
841 static inline void vmathSoaP3MaxPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 );
844 * Minimum of two 3-D points per element
846 static inline void vmathSoaP3MinPerElem( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 );
849 * Maximum element of a 3-D point
851 static inline vec_float4 vmathSoaP3MaxElem( const VmathSoaPoint3 *pnt );
854 * Minimum element of a 3-D point
856 static inline vec_float4 vmathSoaP3MinElem( const VmathSoaPoint3 *pnt );
859 * Compute the sum of all elements of a 3-D point
861 static inline vec_float4 vmathSoaP3Sum( const VmathSoaPoint3 *pnt );
864 * Apply uniform scale to a 3-D point
866 static inline void vmathSoaP3Scale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, vec_float4 scaleVal );
869 * Apply non-uniform scale to a 3-D point
871 static inline void vmathSoaP3NonUniformScale( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt, const VmathSoaVector3 *scaleVec );
874 * Scalar projection of a 3-D point on a unit-length 3-D vector
876 static inline vec_float4 vmathSoaP3Projection( const VmathSoaPoint3 *pnt, const VmathSoaVector3 *unitVec );
879 * Compute the square of the distance of a 3-D point from the coordinate-system origin
881 static inline vec_float4 vmathSoaP3DistSqrFromOrigin( const VmathSoaPoint3 *pnt );
884 * Compute the distance of a 3-D point from the coordinate-system origin
886 static inline vec_float4 vmathSoaP3DistFromOrigin( const VmathSoaPoint3 *pnt );
889 * Compute the square of the distance between two 3-D points
891 static inline vec_float4 vmathSoaP3DistSqr( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 );
894 * Compute the distance between two 3-D points
896 static inline vec_float4 vmathSoaP3Dist( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 );
899 * Linear interpolation between two 3-D points
901 * Does not clamp t between 0 and 1.
903 static inline void vmathSoaP3Lerp( VmathSoaPoint3 *result, vec_float4 t, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1 );
906 * Conditionally select between two 3-D points
908 * This function uses a conditional select instruction to avoid a branch.
910 static inline void vmathSoaP3Select( VmathSoaPoint3 *result, const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_uint4 select1 );
913 * Load four three-float 3-D points, stored in three quadwords
915 static inline void vmathSoaP3LoadXYZArray( VmathSoaPoint3 *pnt, const vec_float4 *threeQuads );
918 * Store four slots of an SoA 3-D point in three quadwords
920 static inline void vmathSoaP3StoreXYZArray( const VmathSoaPoint3 *pnt, vec_float4 *threeQuads );
923 * Store eight slots of two SoA 3-D points as half-floats
925 static inline void vmathSoaP3StoreHalfFloats( const VmathSoaPoint3 *pnt0, const VmathSoaPoint3 *pnt1, vec_ushort8 *threeQuads );
927 #ifdef _VECTORMATH_DEBUG
932 * Function is only defined when _VECTORMATH_DEBUG is defined.
934 static inline void vmathSoaP3Print( const VmathSoaPoint3 *pnt );
937 * Print a 3-D point and an associated string identifier
939 * Function is only defined when _VECTORMATH_DEBUG is defined.
941 static inline void vmathSoaP3Prints( const VmathSoaPoint3 *pnt, const char *name );
948 static inline void vmathSoaQCopy( VmathSoaQuat *result, const VmathSoaQuat *quat );
951 * Construct a quaternion from x, y, z, and w elements
953 static inline void vmathSoaQMakeFromElems( VmathSoaQuat *result, vec_float4 x, vec_float4 y, vec_float4 z, vec_float4 w );
956 * Construct a quaternion from a 3-D vector and a scalar
958 static inline void vmathSoaQMakeFromV3Scalar( VmathSoaQuat *result, const VmathSoaVector3 *xyz, vec_float4 w );
961 * Copy elements from a 4-D vector into a quaternion
963 static inline void vmathSoaQMakeFromV4( VmathSoaQuat *result, const VmathSoaVector4 *vec );
966 * Convert a rotation matrix to a unit-length quaternion
968 static inline void vmathSoaQMakeFromM3( VmathSoaQuat *result, const VmathSoaMatrix3 *rotMat );
971 * Set all elements of a quaternion to the same scalar value
973 static inline void vmathSoaQMakeFromScalar( VmathSoaQuat *result, vec_float4 scalar );
976 * Replicate an AoS quaternion
978 static inline void vmathSoaQMakeFromAos( VmathSoaQuat *result, const VmathQuat *quat );
981 * Insert four AoS quaternions
983 static inline void vmathSoaQMakeFrom4Aos( VmathSoaQuat *result, const VmathQuat *quat0, const VmathQuat *quat1, const VmathQuat *quat2, const VmathQuat *quat3 );
986 * Extract four AoS quaternions
988 static inline void vmathSoaQGet4Aos( const VmathSoaQuat *quat, VmathQuat *result0, VmathQuat *result1, VmathQuat *result2, VmathQuat *result3 );
991 * Set the x, y, and z elements of a quaternion
993 * This function does not change the w element.
995 static inline void vmathSoaQSetXYZ( VmathSoaQuat *result, const VmathSoaVector3 *vec );
998 * Get the x, y, and z elements of a quaternion
1000 static inline void vmathSoaQGetXYZ( VmathSoaVector3 *result, const VmathSoaQuat *quat );
1003 * Set the x element of a quaternion
1005 static inline void vmathSoaQSetX( VmathSoaQuat *result, vec_float4 x );
1008 * Set the y element of a quaternion
1010 static inline void vmathSoaQSetY( VmathSoaQuat *result, vec_float4 y );
1013 * Set the z element of a quaternion
1015 static inline void vmathSoaQSetZ( VmathSoaQuat *result, vec_float4 z );
1018 * Set the w element of a quaternion
1020 static inline void vmathSoaQSetW( VmathSoaQuat *result, vec_float4 w );
1023 * Get the x element of a quaternion
1025 static inline vec_float4 vmathSoaQGetX( const VmathSoaQuat *quat );
1028 * Get the y element of a quaternion
1030 static inline vec_float4 vmathSoaQGetY( const VmathSoaQuat *quat );
1033 * Get the z element of a quaternion
1035 static inline vec_float4 vmathSoaQGetZ( const VmathSoaQuat *quat );
1038 * Get the w element of a quaternion
1040 static inline vec_float4 vmathSoaQGetW( const VmathSoaQuat *quat );
1043 * Set an x, y, z, or w element of a quaternion by index
1045 static inline void vmathSoaQSetElem( VmathSoaQuat *result, int idx, vec_float4 value );
1048 * Get an x, y, z, or w element of a quaternion by index
1050 static inline vec_float4 vmathSoaQGetElem( const VmathSoaQuat *quat, int idx );
1053 * Add two quaternions
1055 static inline void vmathSoaQAdd( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 );
1058 * Subtract a quaternion from another quaternion
1060 static inline void vmathSoaQSub( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 );
1063 * Multiply two quaternions
1065 static inline void vmathSoaQMul( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 );
1068 * Multiply a quaternion by a scalar
1070 static inline void vmathSoaQScalarMul( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar );
1073 * Divide a quaternion by a scalar
1075 static inline void vmathSoaQScalarDiv( VmathSoaQuat *result, const VmathSoaQuat *quat, vec_float4 scalar );
1078 * Negate all elements of a quaternion
1080 static inline void vmathSoaQNeg( VmathSoaQuat *result, const VmathSoaQuat *quat );
1083 * Construct an identity quaternion
1085 static inline void vmathSoaQMakeIdentity( VmathSoaQuat *result );
1088 * Construct a quaternion to rotate between two unit-length 3-D vectors
1090 * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions.
1092 static inline void vmathSoaQMakeRotationArc( VmathSoaQuat *result, const VmathSoaVector3 *unitVec0, const VmathSoaVector3 *unitVec1 );
1095 * Construct a quaternion to rotate around a unit-length 3-D vector
1097 static inline void vmathSoaQMakeRotationAxis( VmathSoaQuat *result, vec_float4 radians, const VmathSoaVector3 *unitVec );
1100 * Construct a quaternion to rotate around the x axis
1102 static inline void vmathSoaQMakeRotationX( VmathSoaQuat *result, vec_float4 radians );
1105 * Construct a quaternion to rotate around the y axis
1107 static inline void vmathSoaQMakeRotationY( VmathSoaQuat *result, vec_float4 radians );
1110 * Construct a quaternion to rotate around the z axis
1112 static inline void vmathSoaQMakeRotationZ( VmathSoaQuat *result, vec_float4 radians );
1115 * Compute the conjugate of a quaternion
1117 static inline void vmathSoaQConj( VmathSoaQuat *result, const VmathSoaQuat *quat );
1120 * Use a unit-length quaternion to rotate a 3-D vector
1122 static inline void vmathSoaQRotate( VmathSoaVector3 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *vec );
1125 * Compute the dot product of two quaternions
1127 static inline vec_float4 vmathSoaQDot( const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 );
1130 * Compute the norm of a quaternion
1132 static inline vec_float4 vmathSoaQNorm( const VmathSoaQuat *quat );
1135 * Compute the length of a quaternion
1137 static inline vec_float4 vmathSoaQLength( const VmathSoaQuat *quat );
1140 * Normalize a quaternion
1142 * The result is unpredictable when all elements of quat are at or near zero.
1144 static inline void vmathSoaQNormalize( VmathSoaQuat *result, const VmathSoaQuat *quat );
1147 * Linear interpolation between two quaternions
1149 * Does not clamp t between 0 and 1.
1151 static inline void vmathSoaQLerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1 );
1154 * Spherical linear interpolation between two quaternions
1156 * Interpolates along the shortest path between orientations.
1157 * Does not clamp t between 0 and 1.
1159 static inline void vmathSoaQSlerp( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1 );
1162 * Spherical quadrangle interpolation
1164 static inline void vmathSoaQSquad( VmathSoaQuat *result, vec_float4 t, const VmathSoaQuat *unitQuat0, const VmathSoaQuat *unitQuat1, const VmathSoaQuat *unitQuat2, const VmathSoaQuat *unitQuat3 );
1167 * Conditionally select between two quaternions
1169 * This function uses a conditional select instruction to avoid a branch.
1171 static inline void vmathSoaQSelect( VmathSoaQuat *result, const VmathSoaQuat *quat0, const VmathSoaQuat *quat1, vec_uint4 select1 );
1173 #ifdef _VECTORMATH_DEBUG
1176 * Print a quaternion
1178 * Function is only defined when _VECTORMATH_DEBUG is defined.
1180 static inline void vmathSoaQPrint( const VmathSoaQuat *quat );
1183 * Print a quaternion and an associated string identifier
1185 * Function is only defined when _VECTORMATH_DEBUG is defined.
1187 static inline void vmathSoaQPrints( const VmathSoaQuat *quat, const char *name );
1194 static inline void vmathSoaM3Copy( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat );
1197 * Construct a 3x3 matrix containing the specified columns
1199 static inline void vmathSoaM3MakeFromCols( VmathSoaMatrix3 *result, const VmathSoaVector3 *col0, const VmathSoaVector3 *col1, const VmathSoaVector3 *col2 );
1202 * Construct a 3x3 rotation matrix from a unit-length quaternion
1204 static inline void vmathSoaM3MakeFromQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat );
1207 * Set all elements of a 3x3 matrix to the same scalar value
1209 static inline void vmathSoaM3MakeFromScalar( VmathSoaMatrix3 *result, vec_float4 scalar );
1212 * Replicate an AoS 3x3 matrix
1214 static inline void vmathSoaM3MakeFromAos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat );
1217 * Insert four AoS 3x3 matrices
1219 static inline void vmathSoaM3MakeFrom4Aos( VmathSoaMatrix3 *result, const VmathMatrix3 *mat0, const VmathMatrix3 *mat1, const VmathMatrix3 *mat2, const VmathMatrix3 *mat3 );
1222 * Extract four AoS 3x3 matrices
1224 static inline void vmathSoaM3Get4Aos( const VmathSoaMatrix3 *mat, VmathMatrix3 *result0, VmathMatrix3 *result1, VmathMatrix3 *result2, VmathMatrix3 *result3 );
1227 * Set column 0 of a 3x3 matrix
1229 static inline void vmathSoaM3SetCol0( VmathSoaMatrix3 *result, const VmathSoaVector3 *col0 );
1232 * Set column 1 of a 3x3 matrix
1234 static inline void vmathSoaM3SetCol1( VmathSoaMatrix3 *result, const VmathSoaVector3 *col1 );
1237 * Set column 2 of a 3x3 matrix
1239 static inline void vmathSoaM3SetCol2( VmathSoaMatrix3 *result, const VmathSoaVector3 *col2 );
1242 * Get column 0 of a 3x3 matrix
1244 static inline void vmathSoaM3GetCol0( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat );
1247 * Get column 1 of a 3x3 matrix
1249 static inline void vmathSoaM3GetCol1( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat );
1252 * Get column 2 of a 3x3 matrix
1254 static inline void vmathSoaM3GetCol2( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat );
1257 * Set the column of a 3x3 matrix referred to by the specified index
1259 static inline void vmathSoaM3SetCol( VmathSoaMatrix3 *result, int col, const VmathSoaVector3 *vec );
1262 * Set the row of a 3x3 matrix referred to by the specified index
1264 static inline void vmathSoaM3SetRow( VmathSoaMatrix3 *result, int row, const VmathSoaVector3 *vec );
1267 * Get the column of a 3x3 matrix referred to by the specified index
1269 static inline void vmathSoaM3GetCol( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int col );
1272 * Get the row of a 3x3 matrix referred to by the specified index
1274 static inline void vmathSoaM3GetRow( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, int row );
1277 * Set the element of a 3x3 matrix referred to by column and row indices
1279 static inline void vmathSoaM3SetElem( VmathSoaMatrix3 *result, int col, int row, vec_float4 val );
1282 * Get the element of a 3x3 matrix referred to by column and row indices
1284 static inline vec_float4 vmathSoaM3GetElem( const VmathSoaMatrix3 *mat, int col, int row );
1287 * Add two 3x3 matrices
1289 static inline void vmathSoaM3Add( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 );
1292 * Subtract a 3x3 matrix from another 3x3 matrix
1294 static inline void vmathSoaM3Sub( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 );
1297 * Negate all elements of a 3x3 matrix
1299 static inline void vmathSoaM3Neg( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat );
1302 * Multiply a 3x3 matrix by a scalar
1304 static inline void vmathSoaM3ScalarMul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, vec_float4 scalar );
1307 * Multiply a 3x3 matrix by a 3-D vector
1309 static inline void vmathSoaM3MulV3( VmathSoaVector3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *vec );
1312 * Multiply two 3x3 matrices
1314 static inline void vmathSoaM3Mul( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 );
1317 * Construct an identity 3x3 matrix
1319 static inline void vmathSoaM3MakeIdentity( VmathSoaMatrix3 *result );
1322 * Construct a 3x3 matrix to rotate around the x axis
1324 static inline void vmathSoaM3MakeRotationX( VmathSoaMatrix3 *result, vec_float4 radians );
1327 * Construct a 3x3 matrix to rotate around the y axis
1329 static inline void vmathSoaM3MakeRotationY( VmathSoaMatrix3 *result, vec_float4 radians );
1332 * Construct a 3x3 matrix to rotate around the z axis
1334 static inline void vmathSoaM3MakeRotationZ( VmathSoaMatrix3 *result, vec_float4 radians );
1337 * Construct a 3x3 matrix to rotate around the x, y, and z axes
1339 static inline void vmathSoaM3MakeRotationZYX( VmathSoaMatrix3 *result, const VmathSoaVector3 *radiansXYZ );
1342 * Construct a 3x3 matrix to rotate around a unit-length 3-D vector
1344 static inline void vmathSoaM3MakeRotationAxis( VmathSoaMatrix3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec );
1347 * Construct a rotation matrix from a unit-length quaternion
1349 static inline void vmathSoaM3MakeRotationQ( VmathSoaMatrix3 *result, const VmathSoaQuat *unitQuat );
1352 * Construct a 3x3 matrix to perform scaling
1354 static inline void vmathSoaM3MakeScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec );
1357 * Append (post-multiply) a scale transformation to a 3x3 matrix
1359 * Faster than creating and multiplying a scale transformation matrix.
1361 static inline void vmathSoaM3AppendScale( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *scaleVec );
1364 * Prepend (pre-multiply) a scale transformation to a 3x3 matrix
1366 * Faster than creating and multiplying a scale transformation matrix.
1368 static inline void vmathSoaM3PrependScale( VmathSoaMatrix3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix3 *mat );
1371 * Multiply two 3x3 matrices per element
1373 static inline void vmathSoaM3MulPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1 );
1376 * Compute the absolute value of a 3x3 matrix per element
1378 static inline void vmathSoaM3AbsPerElem( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat );
1381 * Transpose of a 3x3 matrix
1383 static inline void vmathSoaM3Transpose( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat );
1386 * Compute the inverse of a 3x3 matrix
1388 * Result is unpredictable when the determinant of mat is equal to or near 0.
1390 static inline void vmathSoaM3Inverse( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat );
1393 * Determinant of a 3x3 matrix
1395 static inline vec_float4 vmathSoaM3Determinant( const VmathSoaMatrix3 *mat );
1398 * Conditionally select between two 3x3 matrices
1400 * This function uses a conditional select instruction to avoid a branch.
1402 static inline void vmathSoaM3Select( VmathSoaMatrix3 *result, const VmathSoaMatrix3 *mat0, const VmathSoaMatrix3 *mat1, vec_uint4 select1 );
1404 #ifdef _VECTORMATH_DEBUG
1407 * Print a 3x3 matrix
1409 * Function is only defined when _VECTORMATH_DEBUG is defined.
1411 static inline void vmathSoaM3Print( const VmathSoaMatrix3 *mat );
1414 * Print a 3x3 matrix and an associated string identifier
1416 * Function is only defined when _VECTORMATH_DEBUG is defined.
1418 static inline void vmathSoaM3Prints( const VmathSoaMatrix3 *mat, const char *name );
1425 static inline void vmathSoaM4Copy( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat );
1428 * Construct a 4x4 matrix containing the specified columns
1430 static inline void vmathSoaM4MakeFromCols( VmathSoaMatrix4 *result, const VmathSoaVector4 *col0, const VmathSoaVector4 *col1, const VmathSoaVector4 *col2, const VmathSoaVector4 *col3 );
1433 * Construct a 4x4 matrix from a 3x4 transformation matrix
1435 static inline void vmathSoaM4MakeFromT3( VmathSoaMatrix4 *result, const VmathSoaTransform3 *mat );
1438 * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector
1440 static inline void vmathSoaM4MakeFromM3V3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat, const VmathSoaVector3 *translateVec );
1443 * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector
1445 static inline void vmathSoaM4MakeFromQV3( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec );
1448 * Set all elements of a 4x4 matrix to the same scalar value
1450 static inline void vmathSoaM4MakeFromScalar( VmathSoaMatrix4 *result, vec_float4 scalar );
1453 * Replicate an AoS 4x4 matrix
1455 static inline void vmathSoaM4MakeFromAos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat );
1458 * Insert four AoS 4x4 matrices
1460 static inline void vmathSoaM4MakeFrom4Aos( VmathSoaMatrix4 *result, const VmathMatrix4 *mat0, const VmathMatrix4 *mat1, const VmathMatrix4 *mat2, const VmathMatrix4 *mat3 );
1463 * Extract four AoS 4x4 matrices
1465 static inline void vmathSoaM4Get4Aos( const VmathSoaMatrix4 *mat, VmathMatrix4 *result0, VmathMatrix4 *result1, VmathMatrix4 *result2, VmathMatrix4 *result3 );
1468 * Set the upper-left 3x3 submatrix
1470 * This function does not change the bottom row elements.
1472 static inline void vmathSoaM4SetUpper3x3( VmathSoaMatrix4 *result, const VmathSoaMatrix3 *mat3 );
1475 * Get the upper-left 3x3 submatrix of a 4x4 matrix
1477 static inline void vmathSoaM4GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaMatrix4 *mat );
1480 * Set translation component
1482 * This function does not change the bottom row elements.
1484 static inline void vmathSoaM4SetTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec );
1487 * Get the translation component of a 4x4 matrix
1489 static inline void vmathSoaM4GetTranslation( VmathSoaVector3 *result, const VmathSoaMatrix4 *mat );
1492 * Set column 0 of a 4x4 matrix
1494 static inline void vmathSoaM4SetCol0( VmathSoaMatrix4 *result, const VmathSoaVector4 *col0 );
1497 * Set column 1 of a 4x4 matrix
1499 static inline void vmathSoaM4SetCol1( VmathSoaMatrix4 *result, const VmathSoaVector4 *col1 );
1502 * Set column 2 of a 4x4 matrix
1504 static inline void vmathSoaM4SetCol2( VmathSoaMatrix4 *result, const VmathSoaVector4 *col2 );
1507 * Set column 3 of a 4x4 matrix
1509 static inline void vmathSoaM4SetCol3( VmathSoaMatrix4 *result, const VmathSoaVector4 *col3 );
1512 * Get column 0 of a 4x4 matrix
1514 static inline void vmathSoaM4GetCol0( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat );
1517 * Get column 1 of a 4x4 matrix
1519 static inline void vmathSoaM4GetCol1( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat );
1522 * Get column 2 of a 4x4 matrix
1524 static inline void vmathSoaM4GetCol2( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat );
1527 * Get column 3 of a 4x4 matrix
1529 static inline void vmathSoaM4GetCol3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat );
1532 * Set the column of a 4x4 matrix referred to by the specified index
1534 static inline void vmathSoaM4SetCol( VmathSoaMatrix4 *result, int col, const VmathSoaVector4 *vec );
1537 * Set the row of a 4x4 matrix referred to by the specified index
1539 static inline void vmathSoaM4SetRow( VmathSoaMatrix4 *result, int row, const VmathSoaVector4 *vec );
1542 * Get the column of a 4x4 matrix referred to by the specified index
1544 static inline void vmathSoaM4GetCol( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int col );
1547 * Get the row of a 4x4 matrix referred to by the specified index
1549 static inline void vmathSoaM4GetRow( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, int row );
1552 * Set the element of a 4x4 matrix referred to by column and row indices
1554 static inline void vmathSoaM4SetElem( VmathSoaMatrix4 *result, int col, int row, vec_float4 val );
1557 * Get the element of a 4x4 matrix referred to by column and row indices
1559 static inline vec_float4 vmathSoaM4GetElem( const VmathSoaMatrix4 *mat, int col, int row );
1562 * Add two 4x4 matrices
1564 static inline void vmathSoaM4Add( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 );
1567 * Subtract a 4x4 matrix from another 4x4 matrix
1569 static inline void vmathSoaM4Sub( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 );
1572 * Negate all elements of a 4x4 matrix
1574 static inline void vmathSoaM4Neg( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat );
1577 * Multiply a 4x4 matrix by a scalar
1579 static inline void vmathSoaM4ScalarMul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, vec_float4 scalar );
1582 * Multiply a 4x4 matrix by a 4-D vector
1584 static inline void vmathSoaM4MulV4( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector4 *vec );
1587 * Multiply a 4x4 matrix by a 3-D vector
1589 static inline void vmathSoaM4MulV3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *vec );
1592 * Multiply a 4x4 matrix by a 3-D point
1594 static inline void vmathSoaM4MulP3( VmathSoaVector4 *result, const VmathSoaMatrix4 *mat, const VmathSoaPoint3 *pnt );
1597 * Multiply two 4x4 matrices
1599 static inline void vmathSoaM4Mul( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 );
1602 * Multiply a 4x4 matrix by a 3x4 transformation matrix
1604 static inline void vmathSoaM4MulT3( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaTransform3 *tfrm );
1607 * Construct an identity 4x4 matrix
1609 static inline void vmathSoaM4MakeIdentity( VmathSoaMatrix4 *result );
1612 * Construct a 4x4 matrix to rotate around the x axis
1614 static inline void vmathSoaM4MakeRotationX( VmathSoaMatrix4 *result, vec_float4 radians );
1617 * Construct a 4x4 matrix to rotate around the y axis
1619 static inline void vmathSoaM4MakeRotationY( VmathSoaMatrix4 *result, vec_float4 radians );
1622 * Construct a 4x4 matrix to rotate around the z axis
1624 static inline void vmathSoaM4MakeRotationZ( VmathSoaMatrix4 *result, vec_float4 radians );
1627 * Construct a 4x4 matrix to rotate around the x, y, and z axes
1629 static inline void vmathSoaM4MakeRotationZYX( VmathSoaMatrix4 *result, const VmathSoaVector3 *radiansXYZ );
1632 * Construct a 4x4 matrix to rotate around a unit-length 3-D vector
1634 static inline void vmathSoaM4MakeRotationAxis( VmathSoaMatrix4 *result, vec_float4 radians, const VmathSoaVector3 *unitVec );
1637 * Construct a rotation matrix from a unit-length quaternion
1639 static inline void vmathSoaM4MakeRotationQ( VmathSoaMatrix4 *result, const VmathSoaQuat *unitQuat );
1642 * Construct a 4x4 matrix to perform scaling
1644 static inline void vmathSoaM4MakeScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec );
1647 * Construct a 4x4 matrix to perform translation
1649 static inline void vmathSoaM4MakeTranslation( VmathSoaMatrix4 *result, const VmathSoaVector3 *translateVec );
1652 * Construct viewing matrix based on eye position, position looked at, and up direction
1654 static inline void vmathSoaM4MakeLookAt( VmathSoaMatrix4 *result, const VmathSoaPoint3 *eyePos, const VmathSoaPoint3 *lookAtPos, const VmathSoaVector3 *upVec );
1657 * Construct a perspective projection matrix
1659 static inline void vmathSoaM4MakePerspective( VmathSoaMatrix4 *result, vec_float4 fovyRadians, vec_float4 aspect, vec_float4 zNear, vec_float4 zFar );
1662 * Construct a perspective projection matrix based on frustum
1664 static inline void vmathSoaM4MakeFrustum( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar );
1667 * Construct an orthographic projection matrix
1669 static inline void vmathSoaM4MakeOrthographic( VmathSoaMatrix4 *result, vec_float4 left, vec_float4 right, vec_float4 bottom, vec_float4 top, vec_float4 zNear, vec_float4 zFar );
1672 * Append (post-multiply) a scale transformation to a 4x4 matrix
1674 * Faster than creating and multiplying a scale transformation matrix.
1676 static inline void vmathSoaM4AppendScale( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat, const VmathSoaVector3 *scaleVec );
1679 * Prepend (pre-multiply) a scale transformation to a 4x4 matrix
1681 * Faster than creating and multiplying a scale transformation matrix.
1683 static inline void vmathSoaM4PrependScale( VmathSoaMatrix4 *result, const VmathSoaVector3 *scaleVec, const VmathSoaMatrix4 *mat );
1686 * Multiply two 4x4 matrices per element
1688 static inline void vmathSoaM4MulPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1 );
1691 * Compute the absolute value of a 4x4 matrix per element
1693 static inline void vmathSoaM4AbsPerElem( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat );
1696 * Transpose of a 4x4 matrix
1698 static inline void vmathSoaM4Transpose( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat );
1701 * Compute the inverse of a 4x4 matrix
1703 * Result is unpredictable when the determinant of mat is equal to or near 0.
1705 static inline void vmathSoaM4Inverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat );
1708 * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix
1710 * 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.
1712 static inline void vmathSoaM4AffineInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat );
1715 * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix
1717 * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions.
1719 static inline void vmathSoaM4OrthoInverse( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat );
1722 * Determinant of a 4x4 matrix
1724 static inline vec_float4 vmathSoaM4Determinant( const VmathSoaMatrix4 *mat );
1727 * Conditionally select between two 4x4 matrices
1729 * This function uses a conditional select instruction to avoid a branch.
1731 static inline void vmathSoaM4Select( VmathSoaMatrix4 *result, const VmathSoaMatrix4 *mat0, const VmathSoaMatrix4 *mat1, vec_uint4 select1 );
1733 #ifdef _VECTORMATH_DEBUG
1736 * Print a 4x4 matrix
1738 * Function is only defined when _VECTORMATH_DEBUG is defined.
1740 static inline void vmathSoaM4Print( const VmathSoaMatrix4 *mat );
1743 * Print a 4x4 matrix and an associated string identifier
1745 * Function is only defined when _VECTORMATH_DEBUG is defined.
1747 static inline void vmathSoaM4Prints( const VmathSoaMatrix4 *mat, const char *name );
1752 * Copy a 3x4 transformation matrix
1754 static inline void vmathSoaT3Copy( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm );
1757 * Construct a 3x4 transformation matrix containing the specified columns
1759 static inline void vmathSoaT3MakeFromCols( VmathSoaTransform3 *result, const VmathSoaVector3 *col0, const VmathSoaVector3 *col1, const VmathSoaVector3 *col2, const VmathSoaVector3 *col3 );
1762 * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector
1764 static inline void vmathSoaT3MakeFromM3V3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *tfrm, const VmathSoaVector3 *translateVec );
1767 * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector
1769 static inline void vmathSoaT3MakeFromQV3( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat, const VmathSoaVector3 *translateVec );
1772 * Set all elements of a 3x4 transformation matrix to the same scalar value
1774 static inline void vmathSoaT3MakeFromScalar( VmathSoaTransform3 *result, vec_float4 scalar );
1777 * Replicate an AoS 3x4 transformation matrix
1779 static inline void vmathSoaT3MakeFromAos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm );
1782 * Insert four AoS 3x4 transformation matrices
1784 static inline void vmathSoaT3MakeFrom4Aos( VmathSoaTransform3 *result, const VmathTransform3 *tfrm0, const VmathTransform3 *tfrm1, const VmathTransform3 *tfrm2, const VmathTransform3 *tfrm3 );
1787 * Extract four AoS 3x4 transformation matrices
1789 static inline void vmathSoaT3Get4Aos( const VmathSoaTransform3 *tfrm, VmathTransform3 *result0, VmathTransform3 *result1, VmathTransform3 *result2, VmathTransform3 *result3 );
1792 * Set the upper-left 3x3 submatrix
1794 static inline void vmathSoaT3SetUpper3x3( VmathSoaTransform3 *result, const VmathSoaMatrix3 *mat3 );
1797 * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix
1799 static inline void vmathSoaT3GetUpper3x3( VmathSoaMatrix3 *result, const VmathSoaTransform3 *tfrm );
1802 * Set translation component
1804 static inline void vmathSoaT3SetTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec );
1807 * Get the translation component of a 3x4 transformation matrix
1809 static inline void vmathSoaT3GetTranslation( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm );
1812 * Set column 0 of a 3x4 transformation matrix
1814 static inline void vmathSoaT3SetCol0( VmathSoaTransform3 *result, const VmathSoaVector3 *col0 );
1817 * Set column 1 of a 3x4 transformation matrix
1819 static inline void vmathSoaT3SetCol1( VmathSoaTransform3 *result, const VmathSoaVector3 *col1 );
1822 * Set column 2 of a 3x4 transformation matrix
1824 static inline void vmathSoaT3SetCol2( VmathSoaTransform3 *result, const VmathSoaVector3 *col2 );
1827 * Set column 3 of a 3x4 transformation matrix
1829 static inline void vmathSoaT3SetCol3( VmathSoaTransform3 *result, const VmathSoaVector3 *col3 );
1832 * Get column 0 of a 3x4 transformation matrix
1834 static inline void vmathSoaT3GetCol0( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm );
1837 * Get column 1 of a 3x4 transformation matrix
1839 static inline void vmathSoaT3GetCol1( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm );
1842 * Get column 2 of a 3x4 transformation matrix
1844 static inline void vmathSoaT3GetCol2( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm );
1847 * Get column 3 of a 3x4 transformation matrix
1849 static inline void vmathSoaT3GetCol3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm );
1852 * Set the column of a 3x4 transformation matrix referred to by the specified index
1854 static inline void vmathSoaT3SetCol( VmathSoaTransform3 *result, int col, const VmathSoaVector3 *vec );
1857 * Set the row of a 3x4 transformation matrix referred to by the specified index
1859 static inline void vmathSoaT3SetRow( VmathSoaTransform3 *result, int row, const VmathSoaVector4 *vec );
1862 * Get the column of a 3x4 transformation matrix referred to by the specified index
1864 static inline void vmathSoaT3GetCol( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, int col );
1867 * Get the row of a 3x4 transformation matrix referred to by the specified index
1869 static inline void vmathSoaT3GetRow( VmathSoaVector4 *result, const VmathSoaTransform3 *tfrm, int row );
1872 * Set the element of a 3x4 transformation matrix referred to by column and row indices
1874 static inline void vmathSoaT3SetElem( VmathSoaTransform3 *result, int col, int row, vec_float4 val );
1877 * Get the element of a 3x4 transformation matrix referred to by column and row indices
1879 static inline vec_float4 vmathSoaT3GetElem( const VmathSoaTransform3 *tfrm, int col, int row );
1882 * Multiply a 3x4 transformation matrix by a 3-D vector
1884 static inline void vmathSoaT3MulV3( VmathSoaVector3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *vec );
1887 * Multiply a 3x4 transformation matrix by a 3-D point
1889 static inline void vmathSoaT3MulP3( VmathSoaPoint3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaPoint3 *pnt );
1892 * Multiply two 3x4 transformation matrices
1894 static inline void vmathSoaT3Mul( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 );
1897 * Construct an identity 3x4 transformation matrix
1899 static inline void vmathSoaT3MakeIdentity( VmathSoaTransform3 *result );
1902 * Construct a 3x4 transformation matrix to rotate around the x axis
1904 static inline void vmathSoaT3MakeRotationX( VmathSoaTransform3 *result, vec_float4 radians );
1907 * Construct a 3x4 transformation matrix to rotate around the y axis
1909 static inline void vmathSoaT3MakeRotationY( VmathSoaTransform3 *result, vec_float4 radians );
1912 * Construct a 3x4 transformation matrix to rotate around the z axis
1914 static inline void vmathSoaT3MakeRotationZ( VmathSoaTransform3 *result, vec_float4 radians );
1917 * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes
1919 static inline void vmathSoaT3MakeRotationZYX( VmathSoaTransform3 *result, const VmathSoaVector3 *radiansXYZ );
1922 * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector
1924 static inline void vmathSoaT3MakeRotationAxis( VmathSoaTransform3 *result, vec_float4 radians, const VmathSoaVector3 *unitVec );
1927 * Construct a rotation matrix from a unit-length quaternion
1929 static inline void vmathSoaT3MakeRotationQ( VmathSoaTransform3 *result, const VmathSoaQuat *unitQuat );
1932 * Construct a 3x4 transformation matrix to perform scaling
1934 static inline void vmathSoaT3MakeScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec );
1937 * Construct a 3x4 transformation matrix to perform translation
1939 static inline void vmathSoaT3MakeTranslation( VmathSoaTransform3 *result, const VmathSoaVector3 *translateVec );
1942 * Append (post-multiply) a scale transformation to a 3x4 transformation matrix
1944 * Faster than creating and multiplying a scale transformation matrix.
1946 static inline void vmathSoaT3AppendScale( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm, const VmathSoaVector3 *scaleVec );
1949 * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix
1951 * Faster than creating and multiplying a scale transformation matrix.
1953 static inline void vmathSoaT3PrependScale( VmathSoaTransform3 *result, const VmathSoaVector3 *scaleVec, const VmathSoaTransform3 *tfrm );
1956 * Multiply two 3x4 transformation matrices per element
1958 static inline void vmathSoaT3MulPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1 );
1961 * Compute the absolute value of a 3x4 transformation matrix per element
1963 static inline void vmathSoaT3AbsPerElem( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm );
1966 * Inverse of a 3x4 transformation matrix
1968 * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0.
1970 static inline void vmathSoaT3Inverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm );
1973 * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix
1975 * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions.
1977 static inline void vmathSoaT3OrthoInverse( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm );
1980 * Conditionally select between two 3x4 transformation matrices
1982 * This function uses a conditional select instruction to avoid a branch.
1984 static inline void vmathSoaT3Select( VmathSoaTransform3 *result, const VmathSoaTransform3 *tfrm0, const VmathSoaTransform3 *tfrm1, vec_uint4 select1 );
1986 #ifdef _VECTORMATH_DEBUG
1989 * Print a 3x4 transformation matrix
1991 * Function is only defined when _VECTORMATH_DEBUG is defined.
1993 static inline void vmathSoaT3Print( const VmathSoaTransform3 *tfrm );
1996 * Print a 3x4 transformation matrix and an associated string identifier
1998 * Function is only defined when _VECTORMATH_DEBUG is defined.
2000 static inline void vmathSoaT3Prints( const VmathSoaTransform3 *tfrm, const char *name );
2006 #endif /* __cplusplus */
2008 #include "vec_soa.h"
2009 #include "quat_soa.h"
2010 #include "mat_soa.h"