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