Initialize libbullet git in 2.0_beta.
[platform/upstream/libbullet.git] / Extras / vectormathlibrary / include / vectormath / spu / c / vectormath_aos_v.h
1 /*
2    Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
3    All rights reserved.
4
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.
16
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.
28 */
29
30 #ifndef _VECTORMATH_AOS_C_V_SPU_H
31 #define _VECTORMATH_AOS_C_V_SPU_H
32
33 #include <math.h>
34 #include <spu_intrinsics.h>
35
36 #ifdef _VECTORMATH_DEBUG
37 #endif
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif /* __cplusplus */
42
43 #ifndef _VECTORMATH_AOS_C_TYPES_H
44 #define _VECTORMATH_AOS_C_TYPES_H
45
46 /* A 3-D vector in array-of-structures format
47  */
48 typedef struct _VmathVector3
49 {
50     vec_float4 vec128;
51 } VmathVector3;
52
53 /* A 4-D vector in array-of-structures format
54  */
55 typedef struct _VmathVector4
56 {
57     vec_float4 vec128;
58 } VmathVector4;
59
60 /* A 3-D point in array-of-structures format
61  */
62 typedef struct _VmathPoint3
63 {
64     vec_float4 vec128;
65 } VmathPoint3;
66
67 /* A quaternion in array-of-structures format
68  */
69 typedef struct _VmathQuat
70 {
71     vec_float4 vec128;
72 } VmathQuat;
73
74 /* A 3x3 matrix in array-of-structures format
75  */
76 typedef struct _VmathMatrix3
77 {
78     VmathVector3 col0;
79     VmathVector3 col1;
80     VmathVector3 col2;
81 } VmathMatrix3;
82
83 /* A 4x4 matrix in array-of-structures format
84  */
85 typedef struct _VmathMatrix4
86 {
87     VmathVector4 col0;
88     VmathVector4 col1;
89     VmathVector4 col2;
90     VmathVector4 col3;
91 } VmathMatrix4;
92
93 /* A 3x4 transformation matrix in array-of-structures format
94  */
95 typedef struct _VmathTransform3
96 {
97     VmathVector3 col0;
98     VmathVector3 col1;
99     VmathVector3 col2;
100     VmathVector3 col3;
101 } VmathTransform3;
102
103 #endif
104
105 /*
106  * Construct a 3-D vector from x, y, and z elements
107  */
108 static inline VmathVector3 vmathV3MakeFromElems_V( float x, float y, float z );
109
110 /*
111  * Copy elements from a 3-D point into a 3-D vector
112  */
113 static inline VmathVector3 vmathV3MakeFromP3_V( VmathPoint3 pnt );
114
115 /*
116  * Set all elements of a 3-D vector to the same scalar value
117  */
118 static inline VmathVector3 vmathV3MakeFromScalar_V( float scalar );
119
120 /*
121  * Set vector float data in a 3-D vector
122  */
123 static inline VmathVector3 vmathV3MakeFrom128_V( vec_float4 vf4 );
124
125 /*
126  * Get vector float data from a 3-D vector
127  */
128 static inline vec_float4 vmathV3Get128_V( VmathVector3 vec );
129
130 /*
131  * Set the x element of a 3-D vector
132  */
133 static inline void vmathV3SetX_V( VmathVector3 *result, float x );
134
135 /*
136  * Set the y element of a 3-D vector
137  */
138 static inline void vmathV3SetY_V( VmathVector3 *result, float y );
139
140 /*
141  * Set the z element of a 3-D vector
142  */
143 static inline void vmathV3SetZ_V( VmathVector3 *result, float z );
144
145 /*
146  * Get the x element of a 3-D vector
147  */
148 static inline float vmathV3GetX_V( VmathVector3 vec );
149
150 /*
151  * Get the y element of a 3-D vector
152  */
153 static inline float vmathV3GetY_V( VmathVector3 vec );
154
155 /*
156  * Get the z element of a 3-D vector
157  */
158 static inline float vmathV3GetZ_V( VmathVector3 vec );
159
160 /*
161  * Set an x, y, or z element of a 3-D vector by index
162  */
163 static inline void vmathV3SetElem_V( VmathVector3 *result, int idx, float value );
164
165 /*
166  * Get an x, y, or z element of a 3-D vector by index
167  */
168 static inline float vmathV3GetElem_V( VmathVector3 vec, int idx );
169
170 /*
171  * Add two 3-D vectors
172  */
173 static inline VmathVector3 vmathV3Add_V( VmathVector3 vec0, VmathVector3 vec1 );
174
175 /*
176  * Subtract a 3-D vector from another 3-D vector
177  */
178 static inline VmathVector3 vmathV3Sub_V( VmathVector3 vec0, VmathVector3 vec1 );
179
180 /*
181  * Add a 3-D vector to a 3-D point
182  */
183 static inline VmathPoint3 vmathV3AddP3_V( VmathVector3 vec, VmathPoint3 pnt );
184
185 /*
186  * Multiply a 3-D vector by a scalar
187  */
188 static inline VmathVector3 vmathV3ScalarMul_V( VmathVector3 vec, float scalar );
189
190 /*
191  * Divide a 3-D vector by a scalar
192  */
193 static inline VmathVector3 vmathV3ScalarDiv_V( VmathVector3 vec, float scalar );
194
195 /*
196  * Negate all elements of a 3-D vector
197  */
198 static inline VmathVector3 vmathV3Neg_V( VmathVector3 vec );
199
200 /*
201  * Construct x axis
202  */
203 static inline VmathVector3 vmathV3MakeXAxis_V( );
204
205 /*
206  * Construct y axis
207  */
208 static inline VmathVector3 vmathV3MakeYAxis_V( );
209
210 /*
211  * Construct z axis
212  */
213 static inline VmathVector3 vmathV3MakeZAxis_V( );
214
215 /*
216  * Multiply two 3-D vectors per element
217  */
218 static inline VmathVector3 vmathV3MulPerElem_V( VmathVector3 vec0, VmathVector3 vec1 );
219
220 /*
221  * Divide two 3-D vectors per element
222  * NOTE: 
223  * Floating-point behavior matches standard library function divf4.
224  */
225 static inline VmathVector3 vmathV3DivPerElem_V( VmathVector3 vec0, VmathVector3 vec1 );
226
227 /*
228  * Compute the reciprocal of a 3-D vector per element
229  * NOTE: 
230  * Floating-point behavior matches standard library function recipf4.
231  */
232 static inline VmathVector3 vmathV3RecipPerElem_V( VmathVector3 vec );
233
234 /*
235  * Compute the square root of a 3-D vector per element
236  * NOTE: 
237  * Floating-point behavior matches standard library function sqrtf4.
238  */
239 static inline VmathVector3 vmathV3SqrtPerElem_V( VmathVector3 vec );
240
241 /*
242  * Compute the reciprocal square root of a 3-D vector per element
243  * NOTE: 
244  * Floating-point behavior matches standard library function rsqrtf4.
245  */
246 static inline VmathVector3 vmathV3RsqrtPerElem_V( VmathVector3 vec );
247
248 /*
249  * Compute the absolute value of a 3-D vector per element
250  */
251 static inline VmathVector3 vmathV3AbsPerElem_V( VmathVector3 vec );
252
253 /*
254  * Copy sign from one 3-D vector to another, per element
255  */
256 static inline VmathVector3 vmathV3CopySignPerElem_V( VmathVector3 vec0, VmathVector3 vec1 );
257
258 /*
259  * Maximum of two 3-D vectors per element
260  */
261 static inline VmathVector3 vmathV3MaxPerElem_V( VmathVector3 vec0, VmathVector3 vec1 );
262
263 /*
264  * Minimum of two 3-D vectors per element
265  */
266 static inline VmathVector3 vmathV3MinPerElem_V( VmathVector3 vec0, VmathVector3 vec1 );
267
268 /*
269  * Maximum element of a 3-D vector
270  */
271 static inline float vmathV3MaxElem_V( VmathVector3 vec );
272
273 /*
274  * Minimum element of a 3-D vector
275  */
276 static inline float vmathV3MinElem_V( VmathVector3 vec );
277
278 /*
279  * Compute the sum of all elements of a 3-D vector
280  */
281 static inline float vmathV3Sum_V( VmathVector3 vec );
282
283 /*
284  * Compute the dot product of two 3-D vectors
285  */
286 static inline float vmathV3Dot_V( VmathVector3 vec0, VmathVector3 vec1 );
287
288 /*
289  * Compute the square of the length of a 3-D vector
290  */
291 static inline float vmathV3LengthSqr_V( VmathVector3 vec );
292
293 /*
294  * Compute the length of a 3-D vector
295  */
296 static inline float vmathV3Length_V( VmathVector3 vec );
297
298 /*
299  * Normalize a 3-D vector
300  * NOTE: 
301  * The result is unpredictable when all elements of vec are at or near zero.
302  */
303 static inline VmathVector3 vmathV3Normalize_V( VmathVector3 vec );
304
305 /*
306  * Compute cross product of two 3-D vectors
307  */
308 static inline VmathVector3 vmathV3Cross_V( VmathVector3 vec0, VmathVector3 vec1 );
309
310 /*
311  * Outer product of two 3-D vectors
312  */
313 static inline VmathMatrix3 vmathV3Outer_V( VmathVector3 vec0, VmathVector3 vec1 );
314
315 /*
316  * Pre-multiply a row vector by a 3x3 matrix
317  * NOTE: 
318  * Slower than column post-multiply.
319  */
320 static inline VmathVector3 vmathV3RowMul_V( VmathVector3 vec, VmathMatrix3 mat );
321
322 /*
323  * Cross-product matrix of a 3-D vector
324  */
325 static inline VmathMatrix3 vmathV3CrossMatrix_V( VmathVector3 vec );
326
327 /*
328  * Create cross-product matrix and multiply
329  * NOTE: 
330  * Faster than separately creating a cross-product matrix and multiplying.
331  */
332 static inline VmathMatrix3 vmathV3CrossMatrixMul_V( VmathVector3 vec, VmathMatrix3 mat );
333
334 /*
335  * Linear interpolation between two 3-D vectors
336  * NOTE: 
337  * Does not clamp t between 0 and 1.
338  */
339 static inline VmathVector3 vmathV3Lerp_V( float t, VmathVector3 vec0, VmathVector3 vec1 );
340
341 /*
342  * Spherical linear interpolation between two 3-D vectors
343  * NOTE: 
344  * The result is unpredictable if the vectors point in opposite directions.
345  * Does not clamp t between 0 and 1.
346  */
347 static inline VmathVector3 vmathV3Slerp_V( float t, VmathVector3 unitVec0, VmathVector3 unitVec1 );
348
349 /*
350  * Conditionally select between two 3-D vectors
351  * NOTE: 
352  * This function uses a conditional select instruction to avoid a branch.
353  */
354 static inline VmathVector3 vmathV3Select_V( VmathVector3 vec0, VmathVector3 vec1, unsigned int select1 );
355
356 /*
357  * Store x, y, and z elements of a 3-D vector in the first three words of a quadword.
358  * The value of the fourth word (the word with the highest address) remains unchanged
359  */
360 static inline void vmathV3StoreXYZ_V( VmathVector3 vec, vec_float4 *quad );
361
362 /*
363  * Load four three-float 3-D vectors, stored in three quadwords
364  */
365 static inline void vmathV3LoadXYZArray_V( VmathVector3 *vec0, VmathVector3 *vec1, VmathVector3 *vec2, VmathVector3 *vec3, const vec_float4 *threeQuads );
366
367 /*
368  * Store four 3-D vectors in three quadwords
369  */
370 static inline void vmathV3StoreXYZArray_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, vec_float4 *threeQuads );
371
372 /*
373  * Store eight 3-D vectors as half-floats
374  */
375 static inline void vmathV3StoreHalfFloats_V( VmathVector3 vec0, VmathVector3 vec1, VmathVector3 vec2, VmathVector3 vec3, VmathVector3 vec4, VmathVector3 vec5, VmathVector3 vec6, VmathVector3 vec7, vec_ushort8 *threeQuads );
376
377 #ifdef _VECTORMATH_DEBUG
378
379 /*
380  * Print a 3-D vector
381  * NOTE: 
382  * Function is only defined when _VECTORMATH_DEBUG is defined.
383  */
384 static inline void vmathV3Print_V( VmathVector3 vec );
385
386 /*
387  * Print a 3-D vector and an associated string identifier
388  * NOTE: 
389  * Function is only defined when _VECTORMATH_DEBUG is defined.
390  */
391 static inline void vmathV3Prints_V( VmathVector3 vec, const char *name );
392
393 #endif
394
395 /*
396  * Construct a 4-D vector from x, y, z, and w elements
397  */
398 static inline VmathVector4 vmathV4MakeFromElems_V( float x, float y, float z, float w );
399
400 /*
401  * Construct a 4-D vector from a 3-D vector and a scalar
402  */
403 static inline VmathVector4 vmathV4MakeFromV3Scalar_V( VmathVector3 xyz, float w );
404
405 /*
406  * Copy x, y, and z from a 3-D vector into a 4-D vector, and set w to 0
407  */
408 static inline VmathVector4 vmathV4MakeFromV3_V( VmathVector3 vec );
409
410 /*
411  * Copy x, y, and z from a 3-D point into a 4-D vector, and set w to 1
412  */
413 static inline VmathVector4 vmathV4MakeFromP3_V( VmathPoint3 pnt );
414
415 /*
416  * Copy elements from a quaternion into a 4-D vector
417  */
418 static inline VmathVector4 vmathV4MakeFromQ_V( VmathQuat quat );
419
420 /*
421  * Set all elements of a 4-D vector to the same scalar value
422  */
423 static inline VmathVector4 vmathV4MakeFromScalar_V( float scalar );
424
425 /*
426  * Set vector float data in a 4-D vector
427  */
428 static inline VmathVector4 vmathV4MakeFrom128_V( vec_float4 vf4 );
429
430 /*
431  * Get vector float data from a 4-D vector
432  */
433 static inline vec_float4 vmathV4Get128_V( VmathVector4 vec );
434
435 /*
436  * Set the x, y, and z elements of a 4-D vector
437  * NOTE: 
438  * This function does not change the w element.
439  */
440 static inline void vmathV4SetXYZ_V( VmathVector4 *result, VmathVector3 vec );
441
442 /*
443  * Get the x, y, and z elements of a 4-D vector
444  */
445 static inline VmathVector3 vmathV4GetXYZ_V( VmathVector4 vec );
446
447 /*
448  * Set the x element of a 4-D vector
449  */
450 static inline void vmathV4SetX_V( VmathVector4 *result, float x );
451
452 /*
453  * Set the y element of a 4-D vector
454  */
455 static inline void vmathV4SetY_V( VmathVector4 *result, float y );
456
457 /*
458  * Set the z element of a 4-D vector
459  */
460 static inline void vmathV4SetZ_V( VmathVector4 *result, float z );
461
462 /*
463  * Set the w element of a 4-D vector
464  */
465 static inline void vmathV4SetW_V( VmathVector4 *result, float w );
466
467 /*
468  * Get the x element of a 4-D vector
469  */
470 static inline float vmathV4GetX_V( VmathVector4 vec );
471
472 /*
473  * Get the y element of a 4-D vector
474  */
475 static inline float vmathV4GetY_V( VmathVector4 vec );
476
477 /*
478  * Get the z element of a 4-D vector
479  */
480 static inline float vmathV4GetZ_V( VmathVector4 vec );
481
482 /*
483  * Get the w element of a 4-D vector
484  */
485 static inline float vmathV4GetW_V( VmathVector4 vec );
486
487 /*
488  * Set an x, y, z, or w element of a 4-D vector by index
489  */
490 static inline void vmathV4SetElem_V( VmathVector4 *result, int idx, float value );
491
492 /*
493  * Get an x, y, z, or w element of a 4-D vector by index
494  */
495 static inline float vmathV4GetElem_V( VmathVector4 vec, int idx );
496
497 /*
498  * Add two 4-D vectors
499  */
500 static inline VmathVector4 vmathV4Add_V( VmathVector4 vec0, VmathVector4 vec1 );
501
502 /*
503  * Subtract a 4-D vector from another 4-D vector
504  */
505 static inline VmathVector4 vmathV4Sub_V( VmathVector4 vec0, VmathVector4 vec1 );
506
507 /*
508  * Multiply a 4-D vector by a scalar
509  */
510 static inline VmathVector4 vmathV4ScalarMul_V( VmathVector4 vec, float scalar );
511
512 /*
513  * Divide a 4-D vector by a scalar
514  */
515 static inline VmathVector4 vmathV4ScalarDiv_V( VmathVector4 vec, float scalar );
516
517 /*
518  * Negate all elements of a 4-D vector
519  */
520 static inline VmathVector4 vmathV4Neg_V( VmathVector4 vec );
521
522 /*
523  * Construct x axis
524  */
525 static inline VmathVector4 vmathV4MakeXAxis_V( );
526
527 /*
528  * Construct y axis
529  */
530 static inline VmathVector4 vmathV4MakeYAxis_V( );
531
532 /*
533  * Construct z axis
534  */
535 static inline VmathVector4 vmathV4MakeZAxis_V( );
536
537 /*
538  * Construct w axis
539  */
540 static inline VmathVector4 vmathV4MakeWAxis_V( );
541
542 /*
543  * Multiply two 4-D vectors per element
544  */
545 static inline VmathVector4 vmathV4MulPerElem_V( VmathVector4 vec0, VmathVector4 vec1 );
546
547 /*
548  * Divide two 4-D vectors per element
549  * NOTE: 
550  * Floating-point behavior matches standard library function divf4.
551  */
552 static inline VmathVector4 vmathV4DivPerElem_V( VmathVector4 vec0, VmathVector4 vec1 );
553
554 /*
555  * Compute the reciprocal of a 4-D vector per element
556  * NOTE: 
557  * Floating-point behavior matches standard library function recipf4.
558  */
559 static inline VmathVector4 vmathV4RecipPerElem_V( VmathVector4 vec );
560
561 /*
562  * Compute the square root of a 4-D vector per element
563  * NOTE: 
564  * Floating-point behavior matches standard library function sqrtf4.
565  */
566 static inline VmathVector4 vmathV4SqrtPerElem_V( VmathVector4 vec );
567
568 /*
569  * Compute the reciprocal square root of a 4-D vector per element
570  * NOTE: 
571  * Floating-point behavior matches standard library function rsqrtf4.
572  */
573 static inline VmathVector4 vmathV4RsqrtPerElem_V( VmathVector4 vec );
574
575 /*
576  * Compute the absolute value of a 4-D vector per element
577  */
578 static inline VmathVector4 vmathV4AbsPerElem_V( VmathVector4 vec );
579
580 /*
581  * Copy sign from one 4-D vector to another, per element
582  */
583 static inline VmathVector4 vmathV4CopySignPerElem_V( VmathVector4 vec0, VmathVector4 vec1 );
584
585 /*
586  * Maximum of two 4-D vectors per element
587  */
588 static inline VmathVector4 vmathV4MaxPerElem_V( VmathVector4 vec0, VmathVector4 vec1 );
589
590 /*
591  * Minimum of two 4-D vectors per element
592  */
593 static inline VmathVector4 vmathV4MinPerElem_V( VmathVector4 vec0, VmathVector4 vec1 );
594
595 /*
596  * Maximum element of a 4-D vector
597  */
598 static inline float vmathV4MaxElem_V( VmathVector4 vec );
599
600 /*
601  * Minimum element of a 4-D vector
602  */
603 static inline float vmathV4MinElem_V( VmathVector4 vec );
604
605 /*
606  * Compute the sum of all elements of a 4-D vector
607  */
608 static inline float vmathV4Sum_V( VmathVector4 vec );
609
610 /*
611  * Compute the dot product of two 4-D vectors
612  */
613 static inline float vmathV4Dot_V( VmathVector4 vec0, VmathVector4 vec1 );
614
615 /*
616  * Compute the square of the length of a 4-D vector
617  */
618 static inline float vmathV4LengthSqr_V( VmathVector4 vec );
619
620 /*
621  * Compute the length of a 4-D vector
622  */
623 static inline float vmathV4Length_V( VmathVector4 vec );
624
625 /*
626  * Normalize a 4-D vector
627  * NOTE: 
628  * The result is unpredictable when all elements of vec are at or near zero.
629  */
630 static inline VmathVector4 vmathV4Normalize_V( VmathVector4 vec );
631
632 /*
633  * Outer product of two 4-D vectors
634  */
635 static inline VmathMatrix4 vmathV4Outer_V( VmathVector4 vec0, VmathVector4 vec1 );
636
637 /*
638  * Linear interpolation between two 4-D vectors
639  * NOTE: 
640  * Does not clamp t between 0 and 1.
641  */
642 static inline VmathVector4 vmathV4Lerp_V( float t, VmathVector4 vec0, VmathVector4 vec1 );
643
644 /*
645  * Spherical linear interpolation between two 4-D vectors
646  * NOTE: 
647  * The result is unpredictable if the vectors point in opposite directions.
648  * Does not clamp t between 0 and 1.
649  */
650 static inline VmathVector4 vmathV4Slerp_V( float t, VmathVector4 unitVec0, VmathVector4 unitVec1 );
651
652 /*
653  * Conditionally select between two 4-D vectors
654  * NOTE: 
655  * This function uses a conditional select instruction to avoid a branch.
656  */
657 static inline VmathVector4 vmathV4Select_V( VmathVector4 vec0, VmathVector4 vec1, unsigned int select1 );
658
659 /*
660  * Store four 4-D vectors as half-floats
661  */
662 static inline void vmathV4StoreHalfFloats_V( VmathVector4 vec0, VmathVector4 vec1, VmathVector4 vec2, VmathVector4 vec3, vec_ushort8 *twoQuads );
663
664 #ifdef _VECTORMATH_DEBUG
665
666 /*
667  * Print a 4-D vector
668  * NOTE: 
669  * Function is only defined when _VECTORMATH_DEBUG is defined.
670  */
671 static inline void vmathV4Print_V( VmathVector4 vec );
672
673 /*
674  * Print a 4-D vector and an associated string identifier
675  * NOTE: 
676  * Function is only defined when _VECTORMATH_DEBUG is defined.
677  */
678 static inline void vmathV4Prints_V( VmathVector4 vec, const char *name );
679
680 #endif
681
682 /*
683  * Construct a 3-D point from x, y, and z elements
684  */
685 static inline VmathPoint3 vmathP3MakeFromElems_V( float x, float y, float z );
686
687 /*
688  * Copy elements from a 3-D vector into a 3-D point
689  */
690 static inline VmathPoint3 vmathP3MakeFromV3_V( VmathVector3 vec );
691
692 /*
693  * Set all elements of a 3-D point to the same scalar value
694  */
695 static inline VmathPoint3 vmathP3MakeFromScalar_V( float scalar );
696
697 /*
698  * Set vector float data in a 3-D point
699  */
700 static inline VmathPoint3 vmathP3MakeFrom128_V( vec_float4 vf4 );
701
702 /*
703  * Get vector float data from a 3-D point
704  */
705 static inline vec_float4 vmathP3Get128_V( VmathPoint3 pnt );
706
707 /*
708  * Set the x element of a 3-D point
709  */
710 static inline void vmathP3SetX_V( VmathPoint3 *result, float x );
711
712 /*
713  * Set the y element of a 3-D point
714  */
715 static inline void vmathP3SetY_V( VmathPoint3 *result, float y );
716
717 /*
718  * Set the z element of a 3-D point
719  */
720 static inline void vmathP3SetZ_V( VmathPoint3 *result, float z );
721
722 /*
723  * Get the x element of a 3-D point
724  */
725 static inline float vmathP3GetX_V( VmathPoint3 pnt );
726
727 /*
728  * Get the y element of a 3-D point
729  */
730 static inline float vmathP3GetY_V( VmathPoint3 pnt );
731
732 /*
733  * Get the z element of a 3-D point
734  */
735 static inline float vmathP3GetZ_V( VmathPoint3 pnt );
736
737 /*
738  * Set an x, y, or z element of a 3-D point by index
739  */
740 static inline void vmathP3SetElem_V( VmathPoint3 *result, int idx, float value );
741
742 /*
743  * Get an x, y, or z element of a 3-D point by index
744  */
745 static inline float vmathP3GetElem_V( VmathPoint3 pnt, int idx );
746
747 /*
748  * Subtract a 3-D point from another 3-D point
749  */
750 static inline VmathVector3 vmathP3Sub_V( VmathPoint3 pnt0, VmathPoint3 pnt1 );
751
752 /*
753  * Add a 3-D point to a 3-D vector
754  */
755 static inline VmathPoint3 vmathP3AddV3_V( VmathPoint3 pnt, VmathVector3 vec );
756
757 /*
758  * Subtract a 3-D vector from a 3-D point
759  */
760 static inline VmathPoint3 vmathP3SubV3_V( VmathPoint3 pnt, VmathVector3 vec );
761
762 /*
763  * Multiply two 3-D points per element
764  */
765 static inline VmathPoint3 vmathP3MulPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 );
766
767 /*
768  * Divide two 3-D points per element
769  * NOTE: 
770  * Floating-point behavior matches standard library function divf4.
771  */
772 static inline VmathPoint3 vmathP3DivPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 );
773
774 /*
775  * Compute the reciprocal of a 3-D point per element
776  * NOTE: 
777  * Floating-point behavior matches standard library function recipf4.
778  */
779 static inline VmathPoint3 vmathP3RecipPerElem_V( VmathPoint3 pnt );
780
781 /*
782  * Compute the square root of a 3-D point per element
783  * NOTE: 
784  * Floating-point behavior matches standard library function sqrtf4.
785  */
786 static inline VmathPoint3 vmathP3SqrtPerElem_V( VmathPoint3 pnt );
787
788 /*
789  * Compute the reciprocal square root of a 3-D point per element
790  * NOTE: 
791  * Floating-point behavior matches standard library function rsqrtf4.
792  */
793 static inline VmathPoint3 vmathP3RsqrtPerElem_V( VmathPoint3 pnt );
794
795 /*
796  * Compute the absolute value of a 3-D point per element
797  */
798 static inline VmathPoint3 vmathP3AbsPerElem_V( VmathPoint3 pnt );
799
800 /*
801  * Copy sign from one 3-D point to another, per element
802  */
803 static inline VmathPoint3 vmathP3CopySignPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 );
804
805 /*
806  * Maximum of two 3-D points per element
807  */
808 static inline VmathPoint3 vmathP3MaxPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 );
809
810 /*
811  * Minimum of two 3-D points per element
812  */
813 static inline VmathPoint3 vmathP3MinPerElem_V( VmathPoint3 pnt0, VmathPoint3 pnt1 );
814
815 /*
816  * Maximum element of a 3-D point
817  */
818 static inline float vmathP3MaxElem_V( VmathPoint3 pnt );
819
820 /*
821  * Minimum element of a 3-D point
822  */
823 static inline float vmathP3MinElem_V( VmathPoint3 pnt );
824
825 /*
826  * Compute the sum of all elements of a 3-D point
827  */
828 static inline float vmathP3Sum_V( VmathPoint3 pnt );
829
830 /*
831  * Apply uniform scale to a 3-D point
832  */
833 static inline VmathPoint3 vmathP3Scale_V( VmathPoint3 pnt, float scaleVal );
834
835 /*
836  * Apply non-uniform scale to a 3-D point
837  */
838 static inline VmathPoint3 vmathP3NonUniformScale_V( VmathPoint3 pnt, VmathVector3 scaleVec );
839
840 /*
841  * Scalar projection of a 3-D point on a unit-length 3-D vector
842  */
843 static inline float vmathP3Projection_V( VmathPoint3 pnt, VmathVector3 unitVec );
844
845 /*
846  * Compute the square of the distance of a 3-D point from the coordinate-system origin
847  */
848 static inline float vmathP3DistSqrFromOrigin_V( VmathPoint3 pnt );
849
850 /*
851  * Compute the distance of a 3-D point from the coordinate-system origin
852  */
853 static inline float vmathP3DistFromOrigin_V( VmathPoint3 pnt );
854
855 /*
856  * Compute the square of the distance between two 3-D points
857  */
858 static inline float vmathP3DistSqr_V( VmathPoint3 pnt0, VmathPoint3 pnt1 );
859
860 /*
861  * Compute the distance between two 3-D points
862  */
863 static inline float vmathP3Dist_V( VmathPoint3 pnt0, VmathPoint3 pnt1 );
864
865 /*
866  * Linear interpolation between two 3-D points
867  * NOTE: 
868  * Does not clamp t between 0 and 1.
869  */
870 static inline VmathPoint3 vmathP3Lerp_V( float t, VmathPoint3 pnt0, VmathPoint3 pnt1 );
871
872 /*
873  * Conditionally select between two 3-D points
874  * NOTE: 
875  * This function uses a conditional select instruction to avoid a branch.
876  */
877 static inline VmathPoint3 vmathP3Select_V( VmathPoint3 pnt0, VmathPoint3 pnt1, unsigned int select1 );
878
879 /*
880  * Store x, y, and z elements of a 3-D point in the first three words of a quadword.
881  * The value of the fourth word (the word with the highest address) remains unchanged
882  */
883 static inline void vmathP3StoreXYZ_V( VmathPoint3 pnt, vec_float4 *quad );
884
885 /*
886  * Load four three-float 3-D points, stored in three quadwords
887  */
888 static inline void vmathP3LoadXYZArray_V( VmathPoint3 *pnt0, VmathPoint3 *pnt1, VmathPoint3 *pnt2, VmathPoint3 *pnt3, const vec_float4 *threeQuads );
889
890 /*
891  * Store four 3-D points in three quadwords
892  */
893 static inline void vmathP3StoreXYZArray_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, vec_float4 *threeQuads );
894
895 /*
896  * Store eight 3-D points as half-floats
897  */
898 static inline void vmathP3StoreHalfFloats_V( VmathPoint3 pnt0, VmathPoint3 pnt1, VmathPoint3 pnt2, VmathPoint3 pnt3, VmathPoint3 pnt4, VmathPoint3 pnt5, VmathPoint3 pnt6, VmathPoint3 pnt7, vec_ushort8 *threeQuads );
899
900 #ifdef _VECTORMATH_DEBUG
901
902 /*
903  * Print a 3-D point
904  * NOTE: 
905  * Function is only defined when _VECTORMATH_DEBUG is defined.
906  */
907 static inline void vmathP3Print_V( VmathPoint3 pnt );
908
909 /*
910  * Print a 3-D point and an associated string identifier
911  * NOTE: 
912  * Function is only defined when _VECTORMATH_DEBUG is defined.
913  */
914 static inline void vmathP3Prints_V( VmathPoint3 pnt, const char *name );
915
916 #endif
917
918 /*
919  * Construct a quaternion from x, y, z, and w elements
920  */
921 static inline VmathQuat vmathQMakeFromElems_V( float x, float y, float z, float w );
922
923 /*
924  * Construct a quaternion from a 3-D vector and a scalar
925  */
926 static inline VmathQuat vmathQMakeFromV3Scalar_V( VmathVector3 xyz, float w );
927
928 /*
929  * Copy elements from a 4-D vector into a quaternion
930  */
931 static inline VmathQuat vmathQMakeFromV4_V( VmathVector4 vec );
932
933 /*
934  * Convert a rotation matrix to a unit-length quaternion
935  */
936 static inline VmathQuat vmathQMakeFromM3_V( VmathMatrix3 rotMat );
937
938 /*
939  * Set all elements of a quaternion to the same scalar value
940  */
941 static inline VmathQuat vmathQMakeFromScalar_V( float scalar );
942
943 /*
944  * Set vector float data in a quaternion
945  */
946 static inline VmathQuat vmathQMakeFrom128_V( vec_float4 vf4 );
947
948 /*
949  * Get vector float data from a quaternion
950  */
951 static inline vec_float4 vmathQGet128_V( VmathQuat quat );
952
953 /*
954  * Set the x, y, and z elements of a quaternion
955  * NOTE: 
956  * This function does not change the w element.
957  */
958 static inline void vmathQSetXYZ_V( VmathQuat *result, VmathVector3 vec );
959
960 /*
961  * Get the x, y, and z elements of a quaternion
962  */
963 static inline VmathVector3 vmathQGetXYZ_V( VmathQuat quat );
964
965 /*
966  * Set the x element of a quaternion
967  */
968 static inline void vmathQSetX_V( VmathQuat *result, float x );
969
970 /*
971  * Set the y element of a quaternion
972  */
973 static inline void vmathQSetY_V( VmathQuat *result, float y );
974
975 /*
976  * Set the z element of a quaternion
977  */
978 static inline void vmathQSetZ_V( VmathQuat *result, float z );
979
980 /*
981  * Set the w element of a quaternion
982  */
983 static inline void vmathQSetW_V( VmathQuat *result, float w );
984
985 /*
986  * Get the x element of a quaternion
987  */
988 static inline float vmathQGetX_V( VmathQuat quat );
989
990 /*
991  * Get the y element of a quaternion
992  */
993 static inline float vmathQGetY_V( VmathQuat quat );
994
995 /*
996  * Get the z element of a quaternion
997  */
998 static inline float vmathQGetZ_V( VmathQuat quat );
999
1000 /*
1001  * Get the w element of a quaternion
1002  */
1003 static inline float vmathQGetW_V( VmathQuat quat );
1004
1005 /*
1006  * Set an x, y, z, or w element of a quaternion by index
1007  */
1008 static inline void vmathQSetElem_V( VmathQuat *result, int idx, float value );
1009
1010 /*
1011  * Get an x, y, z, or w element of a quaternion by index
1012  */
1013 static inline float vmathQGetElem_V( VmathQuat quat, int idx );
1014
1015 /*
1016  * Add two quaternions
1017  */
1018 static inline VmathQuat vmathQAdd_V( VmathQuat quat0, VmathQuat quat1 );
1019
1020 /*
1021  * Subtract a quaternion from another quaternion
1022  */
1023 static inline VmathQuat vmathQSub_V( VmathQuat quat0, VmathQuat quat1 );
1024
1025 /*
1026  * Multiply two quaternions
1027  */
1028 static inline VmathQuat vmathQMul_V( VmathQuat quat0, VmathQuat quat1 );
1029
1030 /*
1031  * Multiply a quaternion by a scalar
1032  */
1033 static inline VmathQuat vmathQScalarMul_V( VmathQuat quat, float scalar );
1034
1035 /*
1036  * Divide a quaternion by a scalar
1037  */
1038 static inline VmathQuat vmathQScalarDiv_V( VmathQuat quat, float scalar );
1039
1040 /*
1041  * Negate all elements of a quaternion
1042  */
1043 static inline VmathQuat vmathQNeg_V( VmathQuat quat );
1044
1045 /*
1046  * Construct an identity quaternion
1047  */
1048 static inline VmathQuat vmathQMakeIdentity_V( );
1049
1050 /*
1051  * Construct a quaternion to rotate between two unit-length 3-D vectors
1052  * NOTE: 
1053  * The result is unpredictable if unitVec0 and unitVec1 point in opposite directions.
1054  */
1055 static inline VmathQuat vmathQMakeRotationArc_V( VmathVector3 unitVec0, VmathVector3 unitVec1 );
1056
1057 /*
1058  * Construct a quaternion to rotate around a unit-length 3-D vector
1059  */
1060 static inline VmathQuat vmathQMakeRotationAxis_V( float radians, VmathVector3 unitVec );
1061
1062 /*
1063  * Construct a quaternion to rotate around the x axis
1064  */
1065 static inline VmathQuat vmathQMakeRotationX_V( float radians );
1066
1067 /*
1068  * Construct a quaternion to rotate around the y axis
1069  */
1070 static inline VmathQuat vmathQMakeRotationY_V( float radians );
1071
1072 /*
1073  * Construct a quaternion to rotate around the z axis
1074  */
1075 static inline VmathQuat vmathQMakeRotationZ_V( float radians );
1076
1077 /*
1078  * Compute the conjugate of a quaternion
1079  */
1080 static inline VmathQuat vmathQConj_V( VmathQuat quat );
1081
1082 /*
1083  * Use a unit-length quaternion to rotate a 3-D vector
1084  */
1085 static inline VmathVector3 vmathQRotate_V( VmathQuat unitQuat, VmathVector3 vec );
1086
1087 /*
1088  * Compute the dot product of two quaternions
1089  */
1090 static inline float vmathQDot_V( VmathQuat quat0, VmathQuat quat1 );
1091
1092 /*
1093  * Compute the norm of a quaternion
1094  */
1095 static inline float vmathQNorm_V( VmathQuat quat );
1096
1097 /*
1098  * Compute the length of a quaternion
1099  */
1100 static inline float vmathQLength_V( VmathQuat quat );
1101
1102 /*
1103  * Normalize a quaternion
1104  * NOTE: 
1105  * The result is unpredictable when all elements of quat are at or near zero.
1106  */
1107 static inline VmathQuat vmathQNormalize_V( VmathQuat quat );
1108
1109 /*
1110  * Linear interpolation between two quaternions
1111  * NOTE: 
1112  * Does not clamp t between 0 and 1.
1113  */
1114 static inline VmathQuat vmathQLerp_V( float t, VmathQuat quat0, VmathQuat quat1 );
1115
1116 /*
1117  * Spherical linear interpolation between two quaternions
1118  * NOTE: 
1119  * Interpolates along the shortest path between orientations.
1120  * Does not clamp t between 0 and 1.
1121  */
1122 static inline VmathQuat vmathQSlerp_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1 );
1123
1124 /*
1125  * Spherical quadrangle interpolation
1126  */
1127 static inline VmathQuat vmathQSquad_V( float t, VmathQuat unitQuat0, VmathQuat unitQuat1, VmathQuat unitQuat2, VmathQuat unitQuat3 );
1128
1129 /*
1130  * Conditionally select between two quaternions
1131  * NOTE: 
1132  * This function uses a conditional select instruction to avoid a branch.
1133  */
1134 static inline VmathQuat vmathQSelect_V( VmathQuat quat0, VmathQuat quat1, unsigned int select1 );
1135
1136 #ifdef _VECTORMATH_DEBUG
1137
1138 /*
1139  * Print a quaternion
1140  * NOTE: 
1141  * Function is only defined when _VECTORMATH_DEBUG is defined.
1142  */
1143 static inline void vmathQPrint_V( VmathQuat quat );
1144
1145 /*
1146  * Print a quaternion and an associated string identifier
1147  * NOTE: 
1148  * Function is only defined when _VECTORMATH_DEBUG is defined.
1149  */
1150 static inline void vmathQPrints_V( VmathQuat quat, const char *name );
1151
1152 #endif
1153
1154 /*
1155  * Construct a 3x3 matrix containing the specified columns
1156  */
1157 static inline VmathMatrix3 vmathM3MakeFromCols_V( VmathVector3 col0, VmathVector3 col1, VmathVector3 col2 );
1158
1159 /*
1160  * Construct a 3x3 rotation matrix from a unit-length quaternion
1161  */
1162 static inline VmathMatrix3 vmathM3MakeFromQ_V( VmathQuat unitQuat );
1163
1164 /*
1165  * Set all elements of a 3x3 matrix to the same scalar value
1166  */
1167 static inline VmathMatrix3 vmathM3MakeFromScalar_V( float scalar );
1168
1169 /*
1170  * Set column 0 of a 3x3 matrix
1171  */
1172 static inline void vmathM3SetCol0_V( VmathMatrix3 *result, VmathVector3 col0 );
1173
1174 /*
1175  * Set column 1 of a 3x3 matrix
1176  */
1177 static inline void vmathM3SetCol1_V( VmathMatrix3 *result, VmathVector3 col1 );
1178
1179 /*
1180  * Set column 2 of a 3x3 matrix
1181  */
1182 static inline void vmathM3SetCol2_V( VmathMatrix3 *result, VmathVector3 col2 );
1183
1184 /*
1185  * Get column 0 of a 3x3 matrix
1186  */
1187 static inline VmathVector3 vmathM3GetCol0_V( VmathMatrix3 mat );
1188
1189 /*
1190  * Get column 1 of a 3x3 matrix
1191  */
1192 static inline VmathVector3 vmathM3GetCol1_V( VmathMatrix3 mat );
1193
1194 /*
1195  * Get column 2 of a 3x3 matrix
1196  */
1197 static inline VmathVector3 vmathM3GetCol2_V( VmathMatrix3 mat );
1198
1199 /*
1200  * Set the column of a 3x3 matrix referred to by the specified index
1201  */
1202 static inline void vmathM3SetCol_V( VmathMatrix3 *result, int col, VmathVector3 vec );
1203
1204 /*
1205  * Set the row of a 3x3 matrix referred to by the specified index
1206  */
1207 static inline void vmathM3SetRow_V( VmathMatrix3 *result, int row, VmathVector3 vec );
1208
1209 /*
1210  * Get the column of a 3x3 matrix referred to by the specified index
1211  */
1212 static inline VmathVector3 vmathM3GetCol_V( VmathMatrix3 mat, int col );
1213
1214 /*
1215  * Get the row of a 3x3 matrix referred to by the specified index
1216  */
1217 static inline VmathVector3 vmathM3GetRow_V( VmathMatrix3 mat, int row );
1218
1219 /*
1220  * Set the element of a 3x3 matrix referred to by column and row indices
1221  */
1222 static inline void vmathM3SetElem_V( VmathMatrix3 *result, int col, int row, float val );
1223
1224 /*
1225  * Get the element of a 3x3 matrix referred to by column and row indices
1226  */
1227 static inline float vmathM3GetElem_V( VmathMatrix3 mat, int col, int row );
1228
1229 /*
1230  * Add two 3x3 matrices
1231  */
1232 static inline VmathMatrix3 vmathM3Add_V( VmathMatrix3 mat0, VmathMatrix3 mat1 );
1233
1234 /*
1235  * Subtract a 3x3 matrix from another 3x3 matrix
1236  */
1237 static inline VmathMatrix3 vmathM3Sub_V( VmathMatrix3 mat0, VmathMatrix3 mat1 );
1238
1239 /*
1240  * Negate all elements of a 3x3 matrix
1241  */
1242 static inline VmathMatrix3 vmathM3Neg_V( VmathMatrix3 mat );
1243
1244 /*
1245  * Multiply a 3x3 matrix by a scalar
1246  */
1247 static inline VmathMatrix3 vmathM3ScalarMul_V( VmathMatrix3 mat, float scalar );
1248
1249 /*
1250  * Multiply a 3x3 matrix by a 3-D vector
1251  */
1252 static inline VmathVector3 vmathM3MulV3_V( VmathMatrix3 mat, VmathVector3 vec );
1253
1254 /*
1255  * Multiply two 3x3 matrices
1256  */
1257 static inline VmathMatrix3 vmathM3Mul_V( VmathMatrix3 mat0, VmathMatrix3 mat1 );
1258
1259 /*
1260  * Construct an identity 3x3 matrix
1261  */
1262 static inline VmathMatrix3 vmathM3MakeIdentity_V( );
1263
1264 /*
1265  * Construct a 3x3 matrix to rotate around the x axis
1266  */
1267 static inline VmathMatrix3 vmathM3MakeRotationX_V( float radians );
1268
1269 /*
1270  * Construct a 3x3 matrix to rotate around the y axis
1271  */
1272 static inline VmathMatrix3 vmathM3MakeRotationY_V( float radians );
1273
1274 /*
1275  * Construct a 3x3 matrix to rotate around the z axis
1276  */
1277 static inline VmathMatrix3 vmathM3MakeRotationZ_V( float radians );
1278
1279 /*
1280  * Construct a 3x3 matrix to rotate around the x, y, and z axes
1281  */
1282 static inline VmathMatrix3 vmathM3MakeRotationZYX_V( VmathVector3 radiansXYZ );
1283
1284 /*
1285  * Construct a 3x3 matrix to rotate around a unit-length 3-D vector
1286  */
1287 static inline VmathMatrix3 vmathM3MakeRotationAxis_V( float radians, VmathVector3 unitVec );
1288
1289 /*
1290  * Construct a rotation matrix from a unit-length quaternion
1291  */
1292 static inline VmathMatrix3 vmathM3MakeRotationQ_V( VmathQuat unitQuat );
1293
1294 /*
1295  * Construct a 3x3 matrix to perform scaling
1296  */
1297 static inline VmathMatrix3 vmathM3MakeScale_V( VmathVector3 scaleVec );
1298
1299 /*
1300  * Append (post-multiply) a scale transformation to a 3x3 matrix
1301  * NOTE: 
1302  * Faster than creating and multiplying a scale transformation matrix.
1303  */
1304 static inline VmathMatrix3 vmathM3AppendScale_V( VmathMatrix3 mat, VmathVector3 scaleVec );
1305
1306 /*
1307  * Prepend (pre-multiply) a scale transformation to a 3x3 matrix
1308  * NOTE: 
1309  * Faster than creating and multiplying a scale transformation matrix.
1310  */
1311 static inline VmathMatrix3 vmathM3PrependScale_V( VmathVector3 scaleVec, VmathMatrix3 mat );
1312
1313 /*
1314  * Multiply two 3x3 matrices per element
1315  */
1316 static inline VmathMatrix3 vmathM3MulPerElem_V( VmathMatrix3 mat0, VmathMatrix3 mat1 );
1317
1318 /*
1319  * Compute the absolute value of a 3x3 matrix per element
1320  */
1321 static inline VmathMatrix3 vmathM3AbsPerElem_V( VmathMatrix3 mat );
1322
1323 /*
1324  * Transpose of a 3x3 matrix
1325  */
1326 static inline VmathMatrix3 vmathM3Transpose_V( VmathMatrix3 mat );
1327
1328 /*
1329  * Compute the inverse of a 3x3 matrix
1330  * NOTE: 
1331  * Result is unpredictable when the determinant of mat is equal to or near 0.
1332  */
1333 static inline VmathMatrix3 vmathM3Inverse_V( VmathMatrix3 mat );
1334
1335 /*
1336  * Determinant of a 3x3 matrix
1337  */
1338 static inline float vmathM3Determinant_V( VmathMatrix3 mat );
1339
1340 /*
1341  * Conditionally select between two 3x3 matrices
1342  * NOTE: 
1343  * This function uses a conditional select instruction to avoid a branch.
1344  */
1345 static inline VmathMatrix3 vmathM3Select_V( VmathMatrix3 mat0, VmathMatrix3 mat1, unsigned int select1 );
1346
1347 #ifdef _VECTORMATH_DEBUG
1348
1349 /*
1350  * Print a 3x3 matrix
1351  * NOTE: 
1352  * Function is only defined when _VECTORMATH_DEBUG is defined.
1353  */
1354 static inline void vmathM3Print_V( VmathMatrix3 mat );
1355
1356 /*
1357  * Print a 3x3 matrix and an associated string identifier
1358  * NOTE: 
1359  * Function is only defined when _VECTORMATH_DEBUG is defined.
1360  */
1361 static inline void vmathM3Prints_V( VmathMatrix3 mat, const char *name );
1362
1363 #endif
1364
1365 /*
1366  * Construct a 4x4 matrix containing the specified columns
1367  */
1368 static inline VmathMatrix4 vmathM4MakeFromCols_V( VmathVector4 col0, VmathVector4 col1, VmathVector4 col2, VmathVector4 col3 );
1369
1370 /*
1371  * Construct a 4x4 matrix from a 3x4 transformation matrix
1372  */
1373 static inline VmathMatrix4 vmathM4MakeFromT3_V( VmathTransform3 mat );
1374
1375 /*
1376  * Construct a 4x4 matrix from a 3x3 matrix and a 3-D vector
1377  */
1378 static inline VmathMatrix4 vmathM4MakeFromM3V3_V( VmathMatrix3 mat, VmathVector3 translateVec );
1379
1380 /*
1381  * Construct a 4x4 matrix from a unit-length quaternion and a 3-D vector
1382  */
1383 static inline VmathMatrix4 vmathM4MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec );
1384
1385 /*
1386  * Set all elements of a 4x4 matrix to the same scalar value
1387  */
1388 static inline VmathMatrix4 vmathM4MakeFromScalar_V( float scalar );
1389
1390 /*
1391  * Set the upper-left 3x3 submatrix
1392  * NOTE: 
1393  * This function does not change the bottom row elements.
1394  */
1395 static inline void vmathM4SetUpper3x3_V( VmathMatrix4 *result, VmathMatrix3 mat3 );
1396
1397 /*
1398  * Get the upper-left 3x3 submatrix of a 4x4 matrix
1399  */
1400 static inline VmathMatrix3 vmathM4GetUpper3x3_V( VmathMatrix4 mat );
1401
1402 /*
1403  * Set translation component
1404  * NOTE: 
1405  * This function does not change the bottom row elements.
1406  */
1407 static inline void vmathM4SetTranslation_V( VmathMatrix4 *result, VmathVector3 translateVec );
1408
1409 /*
1410  * Get the translation component of a 4x4 matrix
1411  */
1412 static inline VmathVector3 vmathM4GetTranslation_V( VmathMatrix4 mat );
1413
1414 /*
1415  * Set column 0 of a 4x4 matrix
1416  */
1417 static inline void vmathM4SetCol0_V( VmathMatrix4 *result, VmathVector4 col0 );
1418
1419 /*
1420  * Set column 1 of a 4x4 matrix
1421  */
1422 static inline void vmathM4SetCol1_V( VmathMatrix4 *result, VmathVector4 col1 );
1423
1424 /*
1425  * Set column 2 of a 4x4 matrix
1426  */
1427 static inline void vmathM4SetCol2_V( VmathMatrix4 *result, VmathVector4 col2 );
1428
1429 /*
1430  * Set column 3 of a 4x4 matrix
1431  */
1432 static inline void vmathM4SetCol3_V( VmathMatrix4 *result, VmathVector4 col3 );
1433
1434 /*
1435  * Get column 0 of a 4x4 matrix
1436  */
1437 static inline VmathVector4 vmathM4GetCol0_V( VmathMatrix4 mat );
1438
1439 /*
1440  * Get column 1 of a 4x4 matrix
1441  */
1442 static inline VmathVector4 vmathM4GetCol1_V( VmathMatrix4 mat );
1443
1444 /*
1445  * Get column 2 of a 4x4 matrix
1446  */
1447 static inline VmathVector4 vmathM4GetCol2_V( VmathMatrix4 mat );
1448
1449 /*
1450  * Get column 3 of a 4x4 matrix
1451  */
1452 static inline VmathVector4 vmathM4GetCol3_V( VmathMatrix4 mat );
1453
1454 /*
1455  * Set the column of a 4x4 matrix referred to by the specified index
1456  */
1457 static inline void vmathM4SetCol_V( VmathMatrix4 *result, int col, VmathVector4 vec );
1458
1459 /*
1460  * Set the row of a 4x4 matrix referred to by the specified index
1461  */
1462 static inline void vmathM4SetRow_V( VmathMatrix4 *result, int row, VmathVector4 vec );
1463
1464 /*
1465  * Get the column of a 4x4 matrix referred to by the specified index
1466  */
1467 static inline VmathVector4 vmathM4GetCol_V( VmathMatrix4 mat, int col );
1468
1469 /*
1470  * Get the row of a 4x4 matrix referred to by the specified index
1471  */
1472 static inline VmathVector4 vmathM4GetRow_V( VmathMatrix4 mat, int row );
1473
1474 /*
1475  * Set the element of a 4x4 matrix referred to by column and row indices
1476  */
1477 static inline void vmathM4SetElem_V( VmathMatrix4 *result, int col, int row, float val );
1478
1479 /*
1480  * Get the element of a 4x4 matrix referred to by column and row indices
1481  */
1482 static inline float vmathM4GetElem_V( VmathMatrix4 mat, int col, int row );
1483
1484 /*
1485  * Add two 4x4 matrices
1486  */
1487 static inline VmathMatrix4 vmathM4Add_V( VmathMatrix4 mat0, VmathMatrix4 mat1 );
1488
1489 /*
1490  * Subtract a 4x4 matrix from another 4x4 matrix
1491  */
1492 static inline VmathMatrix4 vmathM4Sub_V( VmathMatrix4 mat0, VmathMatrix4 mat1 );
1493
1494 /*
1495  * Negate all elements of a 4x4 matrix
1496  */
1497 static inline VmathMatrix4 vmathM4Neg_V( VmathMatrix4 mat );
1498
1499 /*
1500  * Multiply a 4x4 matrix by a scalar
1501  */
1502 static inline VmathMatrix4 vmathM4ScalarMul_V( VmathMatrix4 mat, float scalar );
1503
1504 /*
1505  * Multiply a 4x4 matrix by a 4-D vector
1506  */
1507 static inline VmathVector4 vmathM4MulV4_V( VmathMatrix4 mat, VmathVector4 vec );
1508
1509 /*
1510  * Multiply a 4x4 matrix by a 3-D vector
1511  */
1512 static inline VmathVector4 vmathM4MulV3_V( VmathMatrix4 mat, VmathVector3 vec );
1513
1514 /*
1515  * Multiply a 4x4 matrix by a 3-D point
1516  */
1517 static inline VmathVector4 vmathM4MulP3_V( VmathMatrix4 mat, VmathPoint3 pnt );
1518
1519 /*
1520  * Multiply two 4x4 matrices
1521  */
1522 static inline VmathMatrix4 vmathM4Mul_V( VmathMatrix4 mat0, VmathMatrix4 mat1 );
1523
1524 /*
1525  * Multiply a 4x4 matrix by a 3x4 transformation matrix
1526  */
1527 static inline VmathMatrix4 vmathM4MulT3_V( VmathMatrix4 mat, VmathTransform3 tfrm );
1528
1529 /*
1530  * Construct an identity 4x4 matrix
1531  */
1532 static inline VmathMatrix4 vmathM4MakeIdentity_V( );
1533
1534 /*
1535  * Construct a 4x4 matrix to rotate around the x axis
1536  */
1537 static inline VmathMatrix4 vmathM4MakeRotationX_V( float radians );
1538
1539 /*
1540  * Construct a 4x4 matrix to rotate around the y axis
1541  */
1542 static inline VmathMatrix4 vmathM4MakeRotationY_V( float radians );
1543
1544 /*
1545  * Construct a 4x4 matrix to rotate around the z axis
1546  */
1547 static inline VmathMatrix4 vmathM4MakeRotationZ_V( float radians );
1548
1549 /*
1550  * Construct a 4x4 matrix to rotate around the x, y, and z axes
1551  */
1552 static inline VmathMatrix4 vmathM4MakeRotationZYX_V( VmathVector3 radiansXYZ );
1553
1554 /*
1555  * Construct a 4x4 matrix to rotate around a unit-length 3-D vector
1556  */
1557 static inline VmathMatrix4 vmathM4MakeRotationAxis_V( float radians, VmathVector3 unitVec );
1558
1559 /*
1560  * Construct a rotation matrix from a unit-length quaternion
1561  */
1562 static inline VmathMatrix4 vmathM4MakeRotationQ_V( VmathQuat unitQuat );
1563
1564 /*
1565  * Construct a 4x4 matrix to perform scaling
1566  */
1567 static inline VmathMatrix4 vmathM4MakeScale_V( VmathVector3 scaleVec );
1568
1569 /*
1570  * Construct a 4x4 matrix to perform translation
1571  */
1572 static inline VmathMatrix4 vmathM4MakeTranslation_V( VmathVector3 translateVec );
1573
1574 /*
1575  * Construct viewing matrix based on eye position, position looked at, and up direction
1576  */
1577 static inline VmathMatrix4 vmathM4MakeLookAt_V( VmathPoint3 eyePos, VmathPoint3 lookAtPos, VmathVector3 upVec );
1578
1579 /*
1580  * Construct a perspective projection matrix
1581  */
1582 static inline VmathMatrix4 vmathM4MakePerspective_V( float fovyRadians, float aspect, float zNear, float zFar );
1583
1584 /*
1585  * Construct a perspective projection matrix based on frustum
1586  */
1587 static inline VmathMatrix4 vmathM4MakeFrustum_V( float left, float right, float bottom, float top, float zNear, float zFar );
1588
1589 /*
1590  * Construct an orthographic projection matrix
1591  */
1592 static inline VmathMatrix4 vmathM4MakeOrthographic_V( float left, float right, float bottom, float top, float zNear, float zFar );
1593
1594 /*
1595  * Append (post-multiply) a scale transformation to a 4x4 matrix
1596  * NOTE: 
1597  * Faster than creating and multiplying a scale transformation matrix.
1598  */
1599 static inline VmathMatrix4 vmathM4AppendScale_V( VmathMatrix4 mat, VmathVector3 scaleVec );
1600
1601 /*
1602  * Prepend (pre-multiply) a scale transformation to a 4x4 matrix
1603  * NOTE: 
1604  * Faster than creating and multiplying a scale transformation matrix.
1605  */
1606 static inline VmathMatrix4 vmathM4PrependScale_V( VmathVector3 scaleVec, VmathMatrix4 mat );
1607
1608 /*
1609  * Multiply two 4x4 matrices per element
1610  */
1611 static inline VmathMatrix4 vmathM4MulPerElem_V( VmathMatrix4 mat0, VmathMatrix4 mat1 );
1612
1613 /*
1614  * Compute the absolute value of a 4x4 matrix per element
1615  */
1616 static inline VmathMatrix4 vmathM4AbsPerElem_V( VmathMatrix4 mat );
1617
1618 /*
1619  * Transpose of a 4x4 matrix
1620  */
1621 static inline VmathMatrix4 vmathM4Transpose_V( VmathMatrix4 mat );
1622
1623 /*
1624  * Compute the inverse of a 4x4 matrix
1625  * NOTE: 
1626  * Result is unpredictable when the determinant of mat is equal to or near 0.
1627  */
1628 static inline VmathMatrix4 vmathM4Inverse_V( VmathMatrix4 mat );
1629
1630 /*
1631  * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix
1632  * NOTE: 
1633  * 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.
1634  */
1635 static inline VmathMatrix4 vmathM4AffineInverse_V( VmathMatrix4 mat );
1636
1637 /*
1638  * Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix
1639  * NOTE: 
1640  * This can be used to achieve better performance than a general inverse when the specified 4x4 matrix meets the given restrictions.
1641  */
1642 static inline VmathMatrix4 vmathM4OrthoInverse_V( VmathMatrix4 mat );
1643
1644 /*
1645  * Determinant of a 4x4 matrix
1646  */
1647 static inline float vmathM4Determinant_V( VmathMatrix4 mat );
1648
1649 /*
1650  * Conditionally select between two 4x4 matrices
1651  * NOTE: 
1652  * This function uses a conditional select instruction to avoid a branch.
1653  */
1654 static inline VmathMatrix4 vmathM4Select_V( VmathMatrix4 mat0, VmathMatrix4 mat1, unsigned int select1 );
1655
1656 #ifdef _VECTORMATH_DEBUG
1657
1658 /*
1659  * Print a 4x4 matrix
1660  * NOTE: 
1661  * Function is only defined when _VECTORMATH_DEBUG is defined.
1662  */
1663 static inline void vmathM4Print_V( VmathMatrix4 mat );
1664
1665 /*
1666  * Print a 4x4 matrix and an associated string identifier
1667  * NOTE: 
1668  * Function is only defined when _VECTORMATH_DEBUG is defined.
1669  */
1670 static inline void vmathM4Prints_V( VmathMatrix4 mat, const char *name );
1671
1672 #endif
1673
1674 /*
1675  * Construct a 3x4 transformation matrix containing the specified columns
1676  */
1677 static inline VmathTransform3 vmathT3MakeFromCols_V( VmathVector3 col0, VmathVector3 col1, VmathVector3 col2, VmathVector3 col3 );
1678
1679 /*
1680  * Construct a 3x4 transformation matrix from a 3x3 matrix and a 3-D vector
1681  */
1682 static inline VmathTransform3 vmathT3MakeFromM3V3_V( VmathMatrix3 tfrm, VmathVector3 translateVec );
1683
1684 /*
1685  * Construct a 3x4 transformation matrix from a unit-length quaternion and a 3-D vector
1686  */
1687 static inline VmathTransform3 vmathT3MakeFromQV3_V( VmathQuat unitQuat, VmathVector3 translateVec );
1688
1689 /*
1690  * Set all elements of a 3x4 transformation matrix to the same scalar value
1691  */
1692 static inline VmathTransform3 vmathT3MakeFromScalar_V( float scalar );
1693
1694 /*
1695  * Set the upper-left 3x3 submatrix
1696  */
1697 static inline void vmathT3SetUpper3x3_V( VmathTransform3 *result, VmathMatrix3 mat3 );
1698
1699 /*
1700  * Get the upper-left 3x3 submatrix of a 3x4 transformation matrix
1701  */
1702 static inline VmathMatrix3 vmathT3GetUpper3x3_V( VmathTransform3 tfrm );
1703
1704 /*
1705  * Set translation component
1706  */
1707 static inline void vmathT3SetTranslation_V( VmathTransform3 *result, VmathVector3 translateVec );
1708
1709 /*
1710  * Get the translation component of a 3x4 transformation matrix
1711  */
1712 static inline VmathVector3 vmathT3GetTranslation_V( VmathTransform3 tfrm );
1713
1714 /*
1715  * Set column 0 of a 3x4 transformation matrix
1716  */
1717 static inline void vmathT3SetCol0_V( VmathTransform3 *result, VmathVector3 col0 );
1718
1719 /*
1720  * Set column 1 of a 3x4 transformation matrix
1721  */
1722 static inline void vmathT3SetCol1_V( VmathTransform3 *result, VmathVector3 col1 );
1723
1724 /*
1725  * Set column 2 of a 3x4 transformation matrix
1726  */
1727 static inline void vmathT3SetCol2_V( VmathTransform3 *result, VmathVector3 col2 );
1728
1729 /*
1730  * Set column 3 of a 3x4 transformation matrix
1731  */
1732 static inline void vmathT3SetCol3_V( VmathTransform3 *result, VmathVector3 col3 );
1733
1734 /*
1735  * Get column 0 of a 3x4 transformation matrix
1736  */
1737 static inline VmathVector3 vmathT3GetCol0_V( VmathTransform3 tfrm );
1738
1739 /*
1740  * Get column 1 of a 3x4 transformation matrix
1741  */
1742 static inline VmathVector3 vmathT3GetCol1_V( VmathTransform3 tfrm );
1743
1744 /*
1745  * Get column 2 of a 3x4 transformation matrix
1746  */
1747 static inline VmathVector3 vmathT3GetCol2_V( VmathTransform3 tfrm );
1748
1749 /*
1750  * Get column 3 of a 3x4 transformation matrix
1751  */
1752 static inline VmathVector3 vmathT3GetCol3_V( VmathTransform3 tfrm );
1753
1754 /*
1755  * Set the column of a 3x4 transformation matrix referred to by the specified index
1756  */
1757 static inline void vmathT3SetCol_V( VmathTransform3 *result, int col, VmathVector3 vec );
1758
1759 /*
1760  * Set the row of a 3x4 transformation matrix referred to by the specified index
1761  */
1762 static inline void vmathT3SetRow_V( VmathTransform3 *result, int row, VmathVector4 vec );
1763
1764 /*
1765  * Get the column of a 3x4 transformation matrix referred to by the specified index
1766  */
1767 static inline VmathVector3 vmathT3GetCol_V( VmathTransform3 tfrm, int col );
1768
1769 /*
1770  * Get the row of a 3x4 transformation matrix referred to by the specified index
1771  */
1772 static inline VmathVector4 vmathT3GetRow_V( VmathTransform3 tfrm, int row );
1773
1774 /*
1775  * Set the element of a 3x4 transformation matrix referred to by column and row indices
1776  */
1777 static inline void vmathT3SetElem_V( VmathTransform3 *result, int col, int row, float val );
1778
1779 /*
1780  * Get the element of a 3x4 transformation matrix referred to by column and row indices
1781  */
1782 static inline float vmathT3GetElem_V( VmathTransform3 tfrm, int col, int row );
1783
1784 /*
1785  * Multiply a 3x4 transformation matrix by a 3-D vector
1786  */
1787 static inline VmathVector3 vmathT3MulV3_V( VmathTransform3 tfrm, VmathVector3 vec );
1788
1789 /*
1790  * Multiply a 3x4 transformation matrix by a 3-D point
1791  */
1792 static inline VmathPoint3 vmathT3MulP3_V( VmathTransform3 tfrm, VmathPoint3 pnt );
1793
1794 /*
1795  * Multiply two 3x4 transformation matrices
1796  */
1797 static inline VmathTransform3 vmathT3Mul_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 );
1798
1799 /*
1800  * Construct an identity 3x4 transformation matrix
1801  */
1802 static inline VmathTransform3 vmathT3MakeIdentity_V( );
1803
1804 /*
1805  * Construct a 3x4 transformation matrix to rotate around the x axis
1806  */
1807 static inline VmathTransform3 vmathT3MakeRotationX_V( float radians );
1808
1809 /*
1810  * Construct a 3x4 transformation matrix to rotate around the y axis
1811  */
1812 static inline VmathTransform3 vmathT3MakeRotationY_V( float radians );
1813
1814 /*
1815  * Construct a 3x4 transformation matrix to rotate around the z axis
1816  */
1817 static inline VmathTransform3 vmathT3MakeRotationZ_V( float radians );
1818
1819 /*
1820  * Construct a 3x4 transformation matrix to rotate around the x, y, and z axes
1821  */
1822 static inline VmathTransform3 vmathT3MakeRotationZYX_V( VmathVector3 radiansXYZ );
1823
1824 /*
1825  * Construct a 3x4 transformation matrix to rotate around a unit-length 3-D vector
1826  */
1827 static inline VmathTransform3 vmathT3MakeRotationAxis_V( float radians, VmathVector3 unitVec );
1828
1829 /*
1830  * Construct a rotation matrix from a unit-length quaternion
1831  */
1832 static inline VmathTransform3 vmathT3MakeRotationQ_V( VmathQuat unitQuat );
1833
1834 /*
1835  * Construct a 3x4 transformation matrix to perform scaling
1836  */
1837 static inline VmathTransform3 vmathT3MakeScale_V( VmathVector3 scaleVec );
1838
1839 /*
1840  * Construct a 3x4 transformation matrix to perform translation
1841  */
1842 static inline VmathTransform3 vmathT3MakeTranslation_V( VmathVector3 translateVec );
1843
1844 /*
1845  * Append (post-multiply) a scale transformation to a 3x4 transformation matrix
1846  * NOTE: 
1847  * Faster than creating and multiplying a scale transformation matrix.
1848  */
1849 static inline VmathTransform3 vmathT3AppendScale_V( VmathTransform3 tfrm, VmathVector3 scaleVec );
1850
1851 /*
1852  * Prepend (pre-multiply) a scale transformation to a 3x4 transformation matrix
1853  * NOTE: 
1854  * Faster than creating and multiplying a scale transformation matrix.
1855  */
1856 static inline VmathTransform3 vmathT3PrependScale_V( VmathVector3 scaleVec, VmathTransform3 tfrm );
1857
1858 /*
1859  * Multiply two 3x4 transformation matrices per element
1860  */
1861 static inline VmathTransform3 vmathT3MulPerElem_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1 );
1862
1863 /*
1864  * Compute the absolute value of a 3x4 transformation matrix per element
1865  */
1866 static inline VmathTransform3 vmathT3AbsPerElem_V( VmathTransform3 tfrm );
1867
1868 /*
1869  * Inverse of a 3x4 transformation matrix
1870  * NOTE: 
1871  * Result is unpredictable when the determinant of the left 3x3 submatrix is equal to or near 0.
1872  */
1873 static inline VmathTransform3 vmathT3Inverse_V( VmathTransform3 tfrm );
1874
1875 /*
1876  * Compute the inverse of a 3x4 transformation matrix, expected to have an orthogonal upper-left 3x3 submatrix
1877  * NOTE: 
1878  * This can be used to achieve better performance than a general inverse when the specified 3x4 transformation matrix meets the given restrictions.
1879  */
1880 static inline VmathTransform3 vmathT3OrthoInverse_V( VmathTransform3 tfrm );
1881
1882 /*
1883  * Conditionally select between two 3x4 transformation matrices
1884  * NOTE: 
1885  * This function uses a conditional select instruction to avoid a branch.
1886  */
1887 static inline VmathTransform3 vmathT3Select_V( VmathTransform3 tfrm0, VmathTransform3 tfrm1, unsigned int select1 );
1888
1889 #ifdef _VECTORMATH_DEBUG
1890
1891 /*
1892  * Print a 3x4 transformation matrix
1893  * NOTE: 
1894  * Function is only defined when _VECTORMATH_DEBUG is defined.
1895  */
1896 static inline void vmathT3Print_V( VmathTransform3 tfrm );
1897
1898 /*
1899  * Print a 3x4 transformation matrix and an associated string identifier
1900  * NOTE: 
1901  * Function is only defined when _VECTORMATH_DEBUG is defined.
1902  */
1903 static inline void vmathT3Prints_V( VmathTransform3 tfrm, const char *name );
1904
1905 #endif
1906
1907 #ifdef __cplusplus
1908 }
1909 #endif /* __cplusplus */
1910
1911 #include "vectormath_aos.h"
1912 #include "vec_aos_v.h"
1913 #include "quat_aos_v.h"
1914 #include "mat_aos_v.h"
1915
1916 #endif