tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
/*!****************************************************************************
 
 @file         PVRTMatrix.h
 @copyright    Copyright (c) Imagination Technologies Limited.
 @brief        Vector and Matrix functions for floating and fixed point math. 
 @details      The general matrix format used is directly compatible with, for
               example, both DirectX and OpenGL.
 
******************************************************************************/
#ifndef _PVRTMATRIX_H_
#define _PVRTMATRIX_H_
 
#include "PVRTGlobal.h"
/****************************************************************************
** Defines
****************************************************************************/
#define MAT00 0
#define MAT01 1
#define MAT02 2
#define MAT03 3
#define MAT10 4
#define MAT11 5
#define MAT12 6
#define MAT13 7
#define MAT20 8
#define MAT21 9
#define MAT22 10
#define MAT23 11
#define MAT30 12
#define MAT31 13
#define MAT32 14
#define MAT33 15
 
/****************************************************************************
** Typedefs
****************************************************************************/
/*!***************************************************************************
 @brief     2D floating point vector
*****************************************************************************/
typedef struct
{
   float x;    /*!< x coordinate */
   float y;    /*!< y coordinate */
} PVRTVECTOR2f;
 
/*!***************************************************************************
 @brief     2D fixed point vector
*****************************************************************************/
typedef struct
{
   int x;    /*!< x coordinate */
   int y;    /*!< y coordinate */
} PVRTVECTOR2x;
 
/*!***************************************************************************
 @brief     3D floating point vector
*****************************************************************************/
typedef struct
{
   float x;    /*!< x coordinate */
   float y;    /*!< y coordinate */
   float z;    /*!< z coordinate */
} PVRTVECTOR3f;
 
/*!***************************************************************************
 @brief     3D fixed point vector
*****************************************************************************/
typedef struct
{
   int x;    /*!< x coordinate */
   int y;    /*!< y coordinate */
   int z;    /*!< z coordinate */
} PVRTVECTOR3x;
 
/*!***************************************************************************
 @brief     4D floating point vector
*****************************************************************************/
typedef struct
{
   float x;    /*!< x coordinate */
   float y;    /*!< y coordinate */
   float z;    /*!< z coordinate */
   float w;    /*!< w coordinate */
} PVRTVECTOR4f;
 
/*!***************************************************************************
 @brief     4D fixed point vector
*****************************************************************************/
typedef struct
{
   int x;    /*!< x coordinate */
   int y;    /*!< y coordinate */
   int z;    /*!< z coordinate */
   int w;    /*!< w coordinate */
} PVRTVECTOR4x;
 
/*!***************************************************************************
 @class     PVRTMATRIXf
 @brief     4x4 floating point matrix
*****************************************************************************/
class PVRTMATRIXf
{
public:
    float* operator [] ( const int Row )
   {
       return &f[Row<<2];
   }
   float f[16];    /*!< Array of float */
};
 
/*!***************************************************************************
 @class     PVRTMATRIXx
 @brief     4x4 fixed point matrix
*****************************************************************************/
class PVRTMATRIXx
{
public:
    int* operator [] ( const int Row )
   {
       return &f[Row<<2];
   }
   int f[16];
};
 
/*!***************************************************************************
 @class     PVRTMATRIX3f
 @brief     3x3 floating point matrix
*****************************************************************************/
 
class PVRTMATRIX3f
{
public:
    float* operator [] ( const int Row )
   {
       return &f[Row*3];
   }
   float f[9];    /*!< Array of float */
};
 
/*!***************************************************************************
 @class     PVRTMATRIX3x
 @brief     3x3 fixed point matrix
*****************************************************************************/
class PVRTMATRIX3x
{
public:
    int* operator [] ( const int Row )
   {
       return &f[Row*3];
   }
   int f[9];
};
 
 
/****************************************************************************
** Float or fixed
****************************************************************************/
#ifdef PVRT_FIXED_POINT_ENABLE
   typedef PVRTVECTOR2x        PVRTVECTOR2;
   typedef PVRTVECTOR3x        PVRTVECTOR3;
   typedef PVRTVECTOR4x        PVRTVECTOR4;
   typedef PVRTMATRIX3x        PVRTMATRIX3;
   typedef PVRTMATRIXx            PVRTMATRIX;
   #define PVRTMatrixIdentity                    PVRTMatrixIdentityX
   #define PVRTMatrixMultiply                    PVRTMatrixMultiplyX
   #define PVRTMatrixTranslation                PVRTMatrixTranslationX
   #define PVRTMatrixScaling                    PVRTMatrixScalingX
   #define PVRTMatrixRotationX                    PVRTMatrixRotationXX
   #define PVRTMatrixRotationY                    PVRTMatrixRotationYX
   #define PVRTMatrixRotationZ                    PVRTMatrixRotationZX
   #define PVRTMatrixTranspose                    PVRTMatrixTransposeX
   #define PVRTMatrixInverse                    PVRTMatrixInverseX
   #define PVRTMatrixInverseEx                    PVRTMatrixInverseExX
   #define PVRTMatrixLookAtLH                    PVRTMatrixLookAtLHX
   #define PVRTMatrixLookAtRH                    PVRTMatrixLookAtRHX
   #define PVRTMatrixPerspectiveFovLH            PVRTMatrixPerspectiveFovLHX
   #define PVRTMatrixPerspectiveFovRH            PVRTMatrixPerspectiveFovRHX
   #define PVRTMatrixOrthoLH                    PVRTMatrixOrthoLHX
   #define PVRTMatrixOrthoRH                    PVRTMatrixOrthoRHX
   #define PVRTMatrixVec3Lerp                    PVRTMatrixVec3LerpX
   #define PVRTMatrixVec3DotProduct            PVRTMatrixVec3DotProductX
   #define PVRTMatrixVec3CrossProduct            PVRTMatrixVec3CrossProductX
   #define PVRTMatrixVec3Normalize                PVRTMatrixVec3NormalizeX
   #define PVRTMatrixVec3Length                PVRTMatrixVec3LengthX
   #define PVRTMatrixLinearEqSolve                PVRTMatrixLinearEqSolveX
#else
   typedef PVRTVECTOR2f        PVRTVECTOR2;
   typedef PVRTVECTOR3f        PVRTVECTOR3;
   typedef PVRTVECTOR4f        PVRTVECTOR4;
   typedef PVRTMATRIX3f        PVRTMATRIX3;
   typedef PVRTMATRIXf            PVRTMATRIX;
   #define PVRTMatrixIdentity                    PVRTMatrixIdentityF
   #define PVRTMatrixMultiply                    PVRTMatrixMultiplyF
   #define PVRTMatrixTranslation                PVRTMatrixTranslationF
   #define PVRTMatrixScaling                    PVRTMatrixScalingF
   #define PVRTMatrixRotationX                    PVRTMatrixRotationXF
   #define PVRTMatrixRotationY                    PVRTMatrixRotationYF
   #define PVRTMatrixRotationZ                    PVRTMatrixRotationZF
   #define PVRTMatrixTranspose                    PVRTMatrixTransposeF
   #define PVRTMatrixInverse                    PVRTMatrixInverseF
   #define PVRTMatrixInverseEx                    PVRTMatrixInverseExF
   #define PVRTMatrixLookAtLH                    PVRTMatrixLookAtLHF
   #define PVRTMatrixLookAtRH                    PVRTMatrixLookAtRHF
   #define PVRTMatrixPerspectiveFovLH            PVRTMatrixPerspectiveFovLHF
   #define PVRTMatrixPerspectiveFovRH            PVRTMatrixPerspectiveFovRHF
   #define PVRTMatrixOrthoLH                    PVRTMatrixOrthoLHF
   #define PVRTMatrixOrthoRH                    PVRTMatrixOrthoRHF
   #define PVRTMatrixVec3Lerp                    PVRTMatrixVec3LerpF
   #define PVRTMatrixVec3DotProduct            PVRTMatrixVec3DotProductF
   #define PVRTMatrixVec3CrossProduct            PVRTMatrixVec3CrossProductF
   #define PVRTMatrixVec3Normalize                PVRTMatrixVec3NormalizeF
   #define PVRTMatrixVec3Length                PVRTMatrixVec3LengthF
   #define PVRTMatrixLinearEqSolve                PVRTMatrixLinearEqSolveF
#endif
 
/****************************************************************************
** Functions
****************************************************************************/
 
/*!***************************************************************************
 @fn                  PVRTMatrixIdentityF
 @param[out]            mOut    Set to identity
 @brief              Reset matrix to identity matrix.
*****************************************************************************/
void PVRTMatrixIdentityF(PVRTMATRIXf &mOut);
 
/*!***************************************************************************
 @fn                  PVRTMatrixIdentityX
 @param[out]            mOut    Set to identity
 @brief              Reset matrix to identity matrix.
*****************************************************************************/
void PVRTMatrixIdentityX(PVRTMATRIXx &mOut);
 
/*!***************************************************************************
 @fn                  PVRTMatrixMultiplyF
 @param[out]            mOut    Result of mA x mB
 @param[in]                mA        First operand
 @param[in]                mB        Second operand
 @brief              Multiply mA by mB and assign the result to mOut
                   (mOut = p1 * p2). A copy of the result matrix is done in
                   the function because mOut can be a parameter mA or mB.
*****************************************************************************/
void PVRTMatrixMultiplyF(
   PVRTMATRIXf            &mOut,
   const PVRTMATRIXf    &mA,
   const PVRTMATRIXf    &mB);
/*!***************************************************************************
 @fn                  PVRTMatrixMultiplyX
 @param[out]            mOut    Result of mA x mB
 @param[in]                mA        First operand
 @param[in]                mB        Second operand
 @brief              Multiply mA by mB and assign the result to mOut
                   (mOut = p1 * p2). A copy of the result matrix is done in
                   the function because mOut can be a parameter mA or mB.
                   The fixed-point shift could be performed after adding
                   all four intermediate results together however this might
                   cause some overflow issues.
*****************************************************************************/
void PVRTMatrixMultiplyX(
   PVRTMATRIXx            &mOut,
   const PVRTMATRIXx    &mA,
   const PVRTMATRIXx    &mB);
 
/*!***************************************************************************
 @fn                   PVRTMatrixTranslationF
 @param[out]            mOut    Translation matrix
 @param[in]                fX        X component of the translation
 @param[in]                fY        Y component of the translation
 @param[in]                fZ        Z component of the translation
 @brief              Build a transaltion matrix mOut using fX, fY and fZ.
*****************************************************************************/
void PVRTMatrixTranslationF(
   PVRTMATRIXf    &mOut,
   const float    fX,
   const float    fY,
   const float    fZ);
/*!***************************************************************************
 @fn                PVRTMatrixTranslationX
 @param[out]            mOut    Translation matrix
 @param[in]                fX        X component of the translation
 @param[in]                fY        Y component of the translation
 @param[in]                fZ        Z component of the translation
 @brief              Build a transaltion matrix mOut using fX, fY and fZ.
*****************************************************************************/
void PVRTMatrixTranslationX(
   PVRTMATRIXx    &mOut,
   const int    fX,
   const int    fY,
   const int    fZ);
 
/*!***************************************************************************
 @fn                   PVRTMatrixScalingF
 @param[out]            mOut    Scale matrix
 @param[in]                fX        X component of the scaling
 @param[in]                fY        Y component of the scaling
 @param[in]                fZ        Z component of the scaling
 @brief              Build a scale matrix mOut using fX, fY and fZ.
*****************************************************************************/
void PVRTMatrixScalingF(
   PVRTMATRIXf    &mOut,
   const float fX,
   const float fY,
   const float fZ);
 
/*!***************************************************************************
 @fn                   PVRTMatrixScalingX
 @param[out]            mOut    Scale matrix
 @param[in]                fX        X component of the scaling
 @param[in]                fY        Y component of the scaling
 @param[in]                fZ        Z component of the scaling
 @brief              Build a scale matrix mOut using fX, fY and fZ.
*****************************************************************************/
void PVRTMatrixScalingX(
   PVRTMATRIXx    &mOut,
   const int    fX,
   const int    fY,
   const int    fZ);
 
/*!***************************************************************************
 @fn                   PVRTMatrixRotationXF
 @param[out]            mOut    Rotation matrix
 @param[in]                fAngle    Angle of the rotation
 @brief              Create an X rotation matrix mOut.
*****************************************************************************/
void PVRTMatrixRotationXF(
   PVRTMATRIXf    &mOut,
   const float fAngle);
 
/*!***************************************************************************
 @fn                   PVRTMatrixRotationXX
 @param[out]            mOut    Rotation matrix
 @param[in]                fAngle    Angle of the rotation
 @brief              Create an X rotation matrix mOut.
*****************************************************************************/
void PVRTMatrixRotationXX(
   PVRTMATRIXx    &mOut,
   const int    fAngle);
 
/*!***************************************************************************
 @fn                   PVRTMatrixRotationYF
 @param[out]            mOut    Rotation matrix
 @param[in]                fAngle    Angle of the rotation
 @brief              Create an Y rotation matrix mOut.
*****************************************************************************/
void PVRTMatrixRotationYF(
   PVRTMATRIXf    &mOut,
   const float fAngle);
 
/*!***************************************************************************
 @fn                   PVRTMatrixRotationYX
 @param[out]            mOut    Rotation matrix
 @param[in]                fAngle    Angle of the rotation
 @brief              Create an Y rotation matrix mOut.
*****************************************************************************/
void PVRTMatrixRotationYX(
   PVRTMATRIXx    &mOut,
   const int    fAngle);
 
/*!***************************************************************************
 @fn                   PVRTMatrixRotationZF
 @param[out]            mOut    Rotation matrix
 @param[in]                fAngle    Angle of the rotation
 @brief              Create an Z rotation matrix mOut.
*****************************************************************************/
void PVRTMatrixRotationZF(
   PVRTMATRIXf    &mOut,
   const float fAngle);
/*!***************************************************************************
 @fn                   PVRTMatrixRotationZX
 @param[out]            mOut    Rotation matrix
 @param[in]                fAngle    Angle of the rotation
 @brief              Create an Z rotation matrix mOut.
*****************************************************************************/
void PVRTMatrixRotationZX(
   PVRTMATRIXx    &mOut,
   const int    fAngle);
 
/*!***************************************************************************
 @fn                   PVRTMatrixTransposeF
 @param[out]            mOut    Transposed matrix
 @param[in]                mIn        Original matrix
 @brief              Compute the transpose matrix of mIn.
*****************************************************************************/
void PVRTMatrixTransposeF(
   PVRTMATRIXf            &mOut,
   const PVRTMATRIXf    &mIn);
/*!***************************************************************************
 @fn                   PVRTMatrixTransposeX
 @param[out]            mOut    Transposed matrix
 @param[in]                mIn        Original matrix
 @brief              Compute the transpose matrix of mIn.
*****************************************************************************/
void PVRTMatrixTransposeX(
   PVRTMATRIXx            &mOut,
   const PVRTMATRIXx    &mIn);
 
/*!***************************************************************************
 @fn                  PVRTMatrixInverseF
 @param[out]            mOut    Inversed matrix
 @param[in]                mIn        Original matrix
 @brief              Compute the inverse matrix of mIn.
                   The matrix must be of the form :
                   A 0
                   C 1
                   Where A is a 3x3 matrix and C is a 1x3 matrix.
*****************************************************************************/
void PVRTMatrixInverseF(
   PVRTMATRIXf            &mOut,
   const PVRTMATRIXf    &mIn);
/*!***************************************************************************
 @fn                  PVRTMatrixInverseX
 @param[out]            mOut    Inversed matrix
 @param[in]                mIn        Original matrix
 @brief              Compute the inverse matrix of mIn.
                   The matrix must be of the form :
                   A 0
                   C 1
                   Where A is a 3x3 matrix and C is a 1x3 matrix.
*****************************************************************************/
void PVRTMatrixInverseX(
   PVRTMATRIXx            &mOut,
   const PVRTMATRIXx    &mIn);
 
/*!***************************************************************************
 @fn                  PVRTMatrixInverseExF
 @param[out]            mOut    Inversed matrix
 @param[in]                mIn        Original matrix
 @brief              Compute the inverse matrix of mIn.
                   Uses a linear equation solver and the knowledge that M.M^-1=I.
                   Use this fn to calculate the inverse of matrices that
                   PVRTMatrixInverse() cannot.
*****************************************************************************/
void PVRTMatrixInverseExF(
   PVRTMATRIXf            &mOut,
   const PVRTMATRIXf    &mIn);
/*!***************************************************************************
 @fn                  PVRTMatrixInverseExX
 @param[out]            mOut    Inversed matrix
 @param[in]                mIn        Original matrix
 @brief              Compute the inverse matrix of mIn.
                   Uses a linear equation solver and the knowledge that M.M^-1=I.
                   Use this fn to calculate the inverse of matrices that
                   PVRTMatrixInverse() cannot.
*****************************************************************************/
void PVRTMatrixInverseExX(
   PVRTMATRIXx            &mOut,
   const PVRTMATRIXx    &mIn);
 
/*!***************************************************************************
 @fn                  PVRTMatrixLookAtLHF
 @param[out]            mOut    Look-at view matrix
 @param[in]                vEye    Position of the camera
 @param[in]                vAt        Point the camera is looking at
 @param[in]                vUp        Up direction for the camera
 @brief              Create a look-at view matrix.
*****************************************************************************/
void PVRTMatrixLookAtLHF(
   PVRTMATRIXf            &mOut,
   const PVRTVECTOR3f    &vEye,
   const PVRTVECTOR3f    &vAt,
   const PVRTVECTOR3f    &vUp);
/*!***************************************************************************
 @fn                  PVRTMatrixLookAtLHX
 @param[out]            mOut    Look-at view matrix
 @param[in]                vEye    Position of the camera
 @param[in]                vAt        Point the camera is looking at
 @param[in]                vUp        Up direction for the camera
 @brief              Create a look-at view matrix.
*****************************************************************************/
void PVRTMatrixLookAtLHX(
   PVRTMATRIXx            &mOut,
   const PVRTVECTOR3x    &vEye,
   const PVRTVECTOR3x    &vAt,
   const PVRTVECTOR3x    &vUp);
 
/*!***************************************************************************
 @fn                  PVRTMatrixLookAtRHF
 @param[out]            mOut    Look-at view matrix
 @param[in]                vEye    Position of the camera
 @param[in]                vAt        Point the camera is looking at
 @param[in]                vUp        Up direction for the camera
 @brief              Create a look-at view matrix.
*****************************************************************************/
void PVRTMatrixLookAtRHF(
   PVRTMATRIXf            &mOut,
   const PVRTVECTOR3f    &vEye,
   const PVRTVECTOR3f    &vAt,
   const PVRTVECTOR3f    &vUp);
/*!***************************************************************************
 @fn                  PVRTMatrixLookAtRHX
 @param[out]            mOut    Look-at view matrix
 @param[in]                vEye    Position of the camera
 @param[in]                vAt        Point the camera is looking at
 @param[in]                vUp        Up direction for the camera
 @brief              Create a look-at view matrix.
*****************************************************************************/
void PVRTMatrixLookAtRHX(
   PVRTMATRIXx            &mOut,
   const PVRTVECTOR3x    &vEye,
   const PVRTVECTOR3x    &vAt,
   const PVRTVECTOR3x    &vUp);
 
/*!***************************************************************************
 @fn              PVRTMatrixPerspectiveFovLHF
 @param[out]        mOut        Perspective matrix
 @param[in]            fFOVy        Field of view
 @param[in]            fAspect        Aspect ratio
 @param[in]            fNear        Near clipping distance
 @param[in]            fFar        Far clipping distance
 @param[in]            bRotate        Should we rotate it ? (for upright screens)
 @brief          Create a perspective matrix.
*****************************************************************************/
void PVRTMatrixPerspectiveFovLHF(
   PVRTMATRIXf    &mOut,
   const float    fFOVy,
   const float    fAspect,
   const float    fNear,
   const float    fFar,
   const bool  bRotate = false);
/*!***************************************************************************
 @fn              PVRTMatrixPerspectiveFovLHX
 @param[out]        mOut        Perspective matrix
 @param[in]            fFOVy        Field of view
 @param[in]            fAspect        Aspect ratio
 @param[in]            fNear        Near clipping distance
 @param[in]            fFar        Far clipping distance
 @param[in]            bRotate        Should we rotate it ? (for upright screens)
 @brief          Create a perspective matrix.
*****************************************************************************/
void PVRTMatrixPerspectiveFovLHX(
   PVRTMATRIXx    &mOut,
   const int    fFOVy,
   const int    fAspect,
   const int    fNear,
   const int    fFar,
   const bool  bRotate = false);
 
/*!***************************************************************************
 @fn              PVRTMatrixPerspectiveFovRHF
 @param[out]        mOut        Perspective matrix
 @param[in]            fFOVy        Field of view
 @param[in]            fAspect        Aspect ratio
 @param[in]            fNear        Near clipping distance
 @param[in]            fFar        Far clipping distance
 @param[in]            bRotate        Should we rotate it ? (for upright screens)
 @brief          Create a perspective matrix.
*****************************************************************************/
void PVRTMatrixPerspectiveFovRHF(
   PVRTMATRIXf    &mOut,
   const float    fFOVy,
   const float    fAspect,
   const float    fNear,
   const float    fFar,
   const bool  bRotate = false);
/*!***************************************************************************
 @fn              PVRTMatrixPerspectiveFovRHX
 @param[out]        mOut        Perspective matrix
 @param[in]            fFOVy        Field of view
 @param[in]            fAspect        Aspect ratio
 @param[in]            fNear        Near clipping distance
 @param[in]            fFar        Far clipping distance
 @param[in]            bRotate        Should we rotate it ? (for upright screens)
 @brief          Create a perspective matrix.
*****************************************************************************/
void PVRTMatrixPerspectiveFovRHX(
   PVRTMATRIXx    &mOut,
   const int    fFOVy,
   const int    fAspect,
   const int    fNear,
   const int    fFar,
   const bool  bRotate = false);
 
/*!***************************************************************************
 @fn              PVRTMatrixOrthoLHF
 @param[out]        mOut        Orthographic matrix
 @param[in]            w            Width of the screen
 @param[in]            h            Height of the screen
 @param[in]            zn            Near clipping distance
 @param[in]            zf            Far clipping distance
 @param[in]            bRotate        Should we rotate it ? (for upright screens)
 @brief          Create an orthographic matrix.
*****************************************************************************/
void PVRTMatrixOrthoLHF(
   PVRTMATRIXf    &mOut,
   const float w,
   const float h,
   const float zn,
   const float zf,
   const bool  bRotate = false);
/*!***************************************************************************
 @fn              PVRTMatrixOrthoLHX
 @param[out]        mOut        Orthographic matrix
 @param[in]            w            Width of the screen
 @param[in]            h            Height of the screen
 @param[in]            zn            Near clipping distance
 @param[in]            zf            Far clipping distance
 @param[in]            bRotate        Should we rotate it ? (for upright screens)
 @brief          Create an orthographic matrix.
*****************************************************************************/
void PVRTMatrixOrthoLHX(
   PVRTMATRIXx    &mOut,
   const int    w,
   const int    h,
   const int    zn,
   const int    zf,
   const bool  bRotate = false);
 
/*!***************************************************************************
 @fn              PVRTMatrixOrthoRHF
 @param[out]        mOut        Orthographic matrix
 @param[in]            w            Width of the screen
 @param[in]            h            Height of the screen
 @param[in]            zn            Near clipping distance
 @param[in]            zf            Far clipping distance
 @param[in]            bRotate        Should we rotate it ? (for upright screens)
 @brief          Create an orthographic matrix.
*****************************************************************************/
void PVRTMatrixOrthoRHF(
   PVRTMATRIXf    &mOut,
   const float w,
   const float h,
   const float zn,
   const float zf,
   const bool  bRotate = false);
/*!***************************************************************************
 @fn              PVRTMatrixOrthoRHX
 @param[out]        mOut        Orthographic matrix
 @param[in]            w            Width of the screen
 @param[in]            h            Height of the screen
 @param[in]            zn            Near clipping distance
 @param[in]            zf            Far clipping distance
 @param[in]            bRotate        Should we rotate it ? (for upright screens)
 @brief          Create an orthographic matrix.
*****************************************************************************/
void PVRTMatrixOrthoRHX(
   PVRTMATRIXx    &mOut,
   const int    w,
   const int    h,
   const int    zn,
   const int    zf,
   const bool  bRotate = false);
 
/*!***************************************************************************
 @fn                  PVRTMatrixVec3LerpF
 @param[out]            vOut    Result of the interpolation
 @param[in]                v1        First vector to interpolate from
 @param[in]                v2        Second vector to interpolate form
 @param[in]                s        Coefficient of interpolation
 @brief              This function performs the linear interpolation based on
                   the following formula: V1 + s(V2-V1).
*****************************************************************************/
void PVRTMatrixVec3LerpF(
   PVRTVECTOR3f        &vOut,
   const PVRTVECTOR3f    &v1,
   const PVRTVECTOR3f    &v2,
   const float            s);
/*!***************************************************************************
 @fn                  PVRTMatrixVec3LerpX
 @param[out]            vOut    Result of the interpolation
 @param[in]                v1        First vector to interpolate from
 @param[in]                v2        Second vector to interpolate form
 @param[in]                s        Coefficient of interpolation
 @brief              This function performs the linear interpolation based on
                   the following formula: V1 + s(V2-V1).
*****************************************************************************/
void PVRTMatrixVec3LerpX(
   PVRTVECTOR3x        &vOut,
   const PVRTVECTOR3x    &v1,
   const PVRTVECTOR3x    &v2,
   const int            s);
 
/*!***************************************************************************
 @fn                  PVRTMatrixVec3DotProductF
 @param[in]                v1        First vector
 @param[in]                v2        Second vector
 @return            Dot product of the two vectors.
 @brief              This function performs the dot product of the two
                   supplied vectors.
*****************************************************************************/
float PVRTMatrixVec3DotProductF(
   const PVRTVECTOR3f    &v1,
   const PVRTVECTOR3f    &v2);
/*!***************************************************************************
 @fn                  PVRTMatrixVec3DotProductX
 @param[in]                v1        First vector
 @param[in]                v2        Second vector
 @return            Dot product of the two vectors.
 @brief              This function performs the dot product of the two
                   supplied vectors.
                   A single >> 16 shift could be applied to the final accumulated
                   result however this runs the risk of overflow between the
                   results of the intermediate additions.
*****************************************************************************/
int PVRTMatrixVec3DotProductX(
   const PVRTVECTOR3x    &v1,
   const PVRTVECTOR3x    &v2);
 
/*!***************************************************************************
 @fn                  PVRTMatrixVec3CrossProductF
 @param[out]            vOut    Cross product of the two vectors
 @param[in]                v1        First vector
 @param[in]                v2        Second vector
 @brief              This function performs the cross product of the two
                   supplied vectors.
*****************************************************************************/
void PVRTMatrixVec3CrossProductF(
   PVRTVECTOR3f        &vOut,
   const PVRTVECTOR3f    &v1,
   const PVRTVECTOR3f    &v2);
/*!***************************************************************************
 @fn                  PVRTMatrixVec3CrossProductX
 @param[out]            vOut    Cross product of the two vectors
 @param[in]                v1        First vector
 @param[in]                v2        Second vector
 @brief              This function performs the cross product of the two
                   supplied vectors.
*****************************************************************************/
void PVRTMatrixVec3CrossProductX(
   PVRTVECTOR3x        &vOut,
   const PVRTVECTOR3x    &v1,
   const PVRTVECTOR3x    &v2);
 
/*!***************************************************************************
 @fn                  PVRTMatrixVec3NormalizeF
 @param[out]            vOut    Normalized vector
 @param[in]                vIn        Vector to normalize
 @brief              Normalizes the supplied vector.
*****************************************************************************/
void PVRTMatrixVec3NormalizeF(
   PVRTVECTOR3f        &vOut,
   const PVRTVECTOR3f    &vIn);
/*!***************************************************************************
 @fn                  PVRTMatrixVec3NormalizeX
 @param[out]            vOut    Normalized vector
 @param[in]                vIn        Vector to normalize
 @brief              Normalizes the supplied vector.
                   The square root function is currently still performed
                   in floating-point.
                   Original vector is scaled down prior to be normalized in
                   order to avoid overflow issues.
*****************************************************************************/
void PVRTMatrixVec3NormalizeX(
   PVRTVECTOR3x        &vOut,
   const PVRTVECTOR3x    &vIn);
/*!***************************************************************************
 @fn                  PVRTMatrixVec3LengthF
 @param[in]                vIn        Vector to get the length of
 @return            The length of the vector
  @brief              Gets the length of the supplied vector.
*****************************************************************************/
float PVRTMatrixVec3LengthF(
   const PVRTVECTOR3f    &vIn);
/*!***************************************************************************
 @fn                  PVRTMatrixVec3LengthX
 @param[in]                vIn        Vector to get the length of
 @return            The length of the vector
 @brief              Gets the length of the supplied vector
*****************************************************************************/
int PVRTMatrixVec3LengthX(
   const PVRTVECTOR3x    &vIn);
/*!***************************************************************************
 @fn                  PVRTMatrixLinearEqSolveF
 @param[in]                pSrc    2D array of floats. 4 Eq linear problem is 5x4
                           matrix, constants in first column
 @param[in]                nCnt    Number of equations to solve
 @param[out]            pRes    Result
 @brief              Solves 'nCnt' simultaneous equations of 'nCnt' variables.
                   pRes should be an array large enough to contain the
                   results: the values of the 'nCnt' variables.
                   This fn recursively uses Gaussian Elimination.
*****************************************************************************/
 
void PVRTMatrixLinearEqSolveF(
   float        * const pRes,
   float        ** const pSrc,
   const int    nCnt);
/*!***************************************************************************
 @fn                  PVRTMatrixLinearEqSolveX
 @param[in]                pSrc    2D array of floats. 4 Eq linear problem is 5x4
                           matrix, constants in first column
 @param[in]                nCnt    Number of equations to solve
 @param[out]            pRes    Result
 @brief              Solves 'nCnt' simultaneous equations of 'nCnt' variables.
                   pRes should be an array large enough to contain the
                   results: the values of the 'nCnt' variables.
                   This fn recursively uses Gaussian Elimination.
*****************************************************************************/
void PVRTMatrixLinearEqSolveX(
   int            * const pRes,
   int            ** const pSrc,
   const int    nCnt);
 
#endif
 
/*****************************************************************************
 End of file (PVRTMatrix.h)
*****************************************************************************/