PowerVR Software Development Kit |
00001 /*!*************************************************************************** 00002 @File PVRTMatrix.h 00003 00004 @Brief Vector, Matrix and quaternion functions for floating and fixed point math. 00005 00006 @Author PowerVR 00007 00008 @Date August 1999 00009 00010 @Copyright Copyright 2003-2004 by Imagination Technologies Limited. 00011 All rights reserved. No part of this software, either 00012 material or conceptual may be copied or distributed, 00013 transmitted, transcribed, stored in a retrieval system 00014 or translated into any human or computer language in any 00015 form by any means, electronic, mechanical, manual or 00016 other-wise, or disclosed to third parties without the 00017 express written permission of Imagination Technologies 00018 Limited, Unit 8, HomePark Industrial Estate, 00019 King's Langley, Hertfordshire, WD4 8LZ, U.K. 00020 00021 @Platform ANSI compatible 00022 00023 @Description Vector, Matrix and quaternion functions for floating and fixed point math. 00024 The general matrix format used is directly compatible with, for example, 00025 both DirectX and OpenGL. For the reasons why, read this: 00026 http://research.microsoft.com/~hollasch/cgindex/math/matrix/column-vec.html 00027 00028 $Revision: 1.8 $ 00029 *****************************************************************************/ 00030 #ifndef _PVRTMATRIX_H_ 00031 #define _PVRTMATRIX_H_ 00032 00033 00034 /**************************************************************************** 00035 ** Typedefs 00036 ****************************************************************************/ 00037 00038 /*!*************************************************************************** 00039 3D floating point vector 00040 *****************************************************************************/ 00041 typedef struct 00042 { 00043 float x; 00044 float y; 00045 float z; 00046 } PVRTVECTOR3f; 00047 00048 /*!*************************************************************************** 00049 3D fixed point vector 00050 *****************************************************************************/ 00051 typedef struct 00052 { 00053 int x; 00054 int y; 00055 int z; 00056 } PVRTVECTOR3x; 00057 00058 /*!*************************************************************************** 00059 4D floating point vector 00060 *****************************************************************************/ 00061 typedef struct 00062 { 00063 float x; 00064 float y; 00065 float z; 00066 float w; 00067 } PVRTVECTOR4f; 00068 00069 /*!*************************************************************************** 00070 4D fixed point vector 00071 *****************************************************************************/ 00072 typedef struct 00073 { 00074 int x; 00075 int y; 00076 int z; 00077 int w; 00078 } PVRTVECTOR4x; 00079 00080 /*!*************************************************************************** 00081 Floating point Quaternion 00082 *****************************************************************************/ 00083 typedef struct 00084 { 00085 float x; 00086 float y; 00087 float z; 00088 float w; 00089 } PVRTQUATERNIONf; 00090 /*!*************************************************************************** 00091 Fixed point Quaternion 00092 *****************************************************************************/ 00093 typedef struct 00094 { 00095 int x; 00096 int y; 00097 int z; 00098 int w; 00099 } PVRTQUATERNIONx; 00100 00101 /*!*************************************************************************** 00102 4x4 floating point matrix 00103 *****************************************************************************/ 00104 typedef struct 00105 { 00106 float f[16]; 00107 } PVRTMATRIXf; 00108 00109 /*!*************************************************************************** 00110 4x4 fixed point matrix 00111 *****************************************************************************/ 00112 typedef struct 00113 { 00114 int f[16]; 00115 } PVRTMATRIXx; 00116 00117 /**************************************************************************** 00118 ** Float or fixed 00119 ****************************************************************************/ 00120 #ifdef PVRTFIXEDPOINTENABLE 00121 typedef PVRTVECTOR3x PVRTVECTOR3; 00122 typedef PVRTVECTOR4x PVRTVECTOR4; 00123 typedef PVRTQUATERNIONx PVRTQUATERNION; 00124 typedef PVRTMATRIXx PVRTMATRIX; 00125 #define PVRTMatrixIdentity PVRTMatrixIdentityX 00126 #define PVRTMatrixMultiply PVRTMatrixMultiplyX 00127 #define PVRTMatrixTranslation PVRTMatrixTranslationX 00128 #define PVRTMatrixScaling PVRTMatrixScalingX 00129 #define PVRTMatrixRotationX PVRTMatrixRotationXX 00130 #define PVRTMatrixRotationY PVRTMatrixRotationYX 00131 #define PVRTMatrixRotationZ PVRTMatrixRotationZX 00132 #define PVRTMatrixTranspose PVRTMatrixTransposeX 00133 #define PVRTMatrixInverse PVRTMatrixInverseX 00134 #define PVRTMatrixInverseEx PVRTMatrixInverseExX 00135 #define PVRTMatrixLookAtLH PVRTMatrixLookAtLHX 00136 #define PVRTMatrixLookAtRH PVRTMatrixLookAtRHX 00137 #define PVRTMatrixPerspectiveFovLH PVRTMatrixPerspectiveFovLHX 00138 #define PVRTMatrixPerspectiveFovRH PVRTMatrixPerspectiveFovRHX 00139 #define PVRTMatrixOrthoLH PVRTMatrixOrthoLHX 00140 #define PVRTMatrixOrthoRH PVRTMatrixOrthoRHX 00141 #define PVRTMatrixVec3Lerp PVRTMatrixVec3LerpX 00142 #define PVRTMatrixVec3DotProduct PVRTMatrixVec3DotProductX 00143 #define PVRTMatrixVec3CrossProduct PVRTMatrixVec3CrossProductX 00144 #define PVRTMatrixVec3Normalize PVRTMatrixVec3NormalizeX 00145 #define PVRTMatrixQuaternionIdentity PVRTMatrixQuaternionIdentityX 00146 #define PVRTMatrixQuaternionRotationAxis PVRTMatrixQuaternionRotationAxisX 00147 #define PVRTMatrixQuaternionToAxisAngle PVRTMatrixQuaternionToAxisAngleX 00148 #define PVRTMatrixQuaternionSlerp PVRTMatrixQuaternionSlerpX 00149 #define PVRTMatrixQuaternionNormalize PVRTMatrixQuaternionNormalizeX 00150 #define PVRTMatrixRotationQuaternion PVRTMatrixRotationQuaternionX 00151 #define PVRTMatrixQuaternionMultiply PVRTMatrixQuaternionMultiplyX 00152 #define PVRTMatrixLinearEqSolve PVRTMatrixLinearEqSolveX 00153 #else 00154 typedef PVRTVECTOR3f PVRTVECTOR3; 00155 typedef PVRTVECTOR4f PVRTVECTOR4; 00156 typedef PVRTQUATERNIONf PVRTQUATERNION; 00157 typedef PVRTMATRIXf PVRTMATRIX; 00158 #define PVRTMatrixIdentity PVRTMatrixIdentityF 00159 #define PVRTMatrixMultiply PVRTMatrixMultiplyF 00160 #define PVRTMatrixTranslation PVRTMatrixTranslationF 00161 #define PVRTMatrixScaling PVRTMatrixScalingF 00162 #define PVRTMatrixRotationX PVRTMatrixRotationXF 00163 #define PVRTMatrixRotationY PVRTMatrixRotationYF 00164 #define PVRTMatrixRotationZ PVRTMatrixRotationZF 00165 #define PVRTMatrixTranspose PVRTMatrixTransposeF 00166 #define PVRTMatrixInverse PVRTMatrixInverseF 00167 #define PVRTMatrixInverseEx PVRTMatrixInverseExF 00168 #define PVRTMatrixLookAtLH PVRTMatrixLookAtLHF 00169 #define PVRTMatrixLookAtRH PVRTMatrixLookAtRHF 00170 #define PVRTMatrixPerspectiveFovLH PVRTMatrixPerspectiveFovLHF 00171 #define PVRTMatrixPerspectiveFovRH PVRTMatrixPerspectiveFovRHF 00172 #define PVRTMatrixOrthoLH PVRTMatrixOrthoLHF 00173 #define PVRTMatrixOrthoRH PVRTMatrixOrthoRHF 00174 #define PVRTMatrixVec3Lerp PVRTMatrixVec3LerpF 00175 #define PVRTMatrixVec3DotProduct PVRTMatrixVec3DotProductF 00176 #define PVRTMatrixVec3CrossProduct PVRTMatrixVec3CrossProductF 00177 #define PVRTMatrixVec3Normalize PVRTMatrixVec3NormalizeF 00178 #define PVRTMatrixQuaternionIdentity PVRTMatrixQuaternionIdentityF 00179 #define PVRTMatrixQuaternionRotationAxis PVRTMatrixQuaternionRotationAxisF 00180 #define PVRTMatrixQuaternionToAxisAngle PVRTMatrixQuaternionToAxisAngleF 00181 #define PVRTMatrixQuaternionSlerp PVRTMatrixQuaternionSlerpF 00182 #define PVRTMatrixQuaternionNormalize PVRTMatrixQuaternionNormalizeF 00183 #define PVRTMatrixRotationQuaternion PVRTMatrixRotationQuaternionF 00184 #define PVRTMatrixQuaternionMultiply PVRTMatrixQuaternionMultiplyF 00185 #define PVRTMatrixLinearEqSolve PVRTMatrixLinearEqSolveF 00186 #endif 00187 00188 /**************************************************************************** 00189 ** Functions 00190 ****************************************************************************/ 00191 00192 /*!*************************************************************************** 00193 @Function PVRTMatrixIdentityF 00194 @Output mOut Set to identity 00195 @Description Reset matrix to identity matrix. 00196 *****************************************************************************/ 00197 void PVRTMatrixIdentityF(PVRTMATRIXf &mOut); 00198 00199 /*!*************************************************************************** 00200 @Function PVRTMatrixIdentityX 00201 @Output mOut Set to identity 00202 @Description Reset matrix to identity matrix. 00203 *****************************************************************************/ 00204 void PVRTMatrixIdentityX(PVRTMATRIXx &mOut); 00205 00206 /*!*************************************************************************** 00207 @Function PVRTMatrixMultiplyF 00208 @Output mOut Result of mA x mB 00209 @Input mA First operand 00210 @Input mB Second operand 00211 @Description Multiply mA by mB and assign the result to mOut 00212 (mOut = p1 * p2). A copy of the result matrix is done in 00213 the function because mOut can be a parameter mA or mB. 00214 *****************************************************************************/ 00215 void PVRTMatrixMultiplyF( 00216 PVRTMATRIXf &mOut, 00217 const PVRTMATRIXf &mA, 00218 const PVRTMATRIXf &mB); 00219 /*!*************************************************************************** 00220 @Function PVRTMatrixMultiplyX 00221 @Output mOut Result of mA x mB 00222 @Input mA First operand 00223 @Input mB Second operand 00224 @Description Multiply mA by mB and assign the result to mOut 00225 (mOut = p1 * p2). A copy of the result matrix is done in 00226 the function because mOut can be a parameter mA or mB. 00227 The fixed-point shift could be performed after adding 00228 all four intermediate results together however this might 00229 cause some overflow issues. 00230 *****************************************************************************/ 00231 void PVRTMatrixMultiplyX( 00232 PVRTMATRIXx &mOut, 00233 const PVRTMATRIXx &mA, 00234 const PVRTMATRIXx &mB); 00235 00236 /*!*************************************************************************** 00237 @Function Name PVRTMatrixTranslationF 00238 @Output mOut Translation matrix 00239 @Input fX X component of the translation 00240 @Input fY Y component of the translation 00241 @Input fZ Z component of the translation 00242 @Description Build a transaltion matrix mOut using fX, fY and fZ. 00243 *****************************************************************************/ 00244 void PVRTMatrixTranslationF( 00245 PVRTMATRIXf &mOut, 00246 const float fX, 00247 const float fY, 00248 const float fZ); 00249 /*!*************************************************************************** 00250 @Function Name PVRTMatrixTranslationX 00251 @Output mOut Translation matrix 00252 @Input fX X component of the translation 00253 @Input fY Y component of the translation 00254 @Input fZ Z component of the translation 00255 @Description Build a transaltion matrix mOut using fX, fY and fZ. 00256 *****************************************************************************/ 00257 void PVRTMatrixTranslationX( 00258 PVRTMATRIXx &mOut, 00259 const int fX, 00260 const int fY, 00261 const int fZ); 00262 00263 /*!*************************************************************************** 00264 @Function Name PVRTMatrixScalingF 00265 @Output mOut Scale matrix 00266 @Input fX X component of the scaling 00267 @Input fY Y component of the scaling 00268 @Input fZ Z component of the scaling 00269 @Description Build a scale matrix mOut using fX, fY and fZ. 00270 *****************************************************************************/ 00271 void PVRTMatrixScalingF( 00272 PVRTMATRIXf &mOut, 00273 const float fX, 00274 const float fY, 00275 const float fZ); 00276 /*!*************************************************************************** 00277 @Function Name PVRTMatrixScalingX 00278 @Output mOut Scale matrix 00279 @Input fX X component of the scaling 00280 @Input fY Y component of the scaling 00281 @Input fZ Z component of the scaling 00282 @Description Build a scale matrix mOut using fX, fY and fZ. 00283 *****************************************************************************/ 00284 void PVRTMatrixScalingX( 00285 PVRTMATRIXx &mOut, 00286 const int fX, 00287 const int fY, 00288 const int fZ); 00289 00290 /*!*************************************************************************** 00291 @Function Name PVRTMatrixRotationXF 00292 @Output mOut Rotation matrix 00293 @Input fAngle Angle of the rotation 00294 @Description Create an X rotation matrix mOut. 00295 *****************************************************************************/ 00296 void PVRTMatrixRotationXF( 00297 PVRTMATRIXf &mOut, 00298 const float fAngle); 00299 /*!*************************************************************************** 00300 @Function Name PVRTMatrixRotationXX 00301 @Output mOut Rotation matrix 00302 @Input fAngle Angle of the rotation 00303 @Description Create an X rotation matrix mOut. 00304 *****************************************************************************/ 00305 void PVRTMatrixRotationXX( 00306 PVRTMATRIXx &mOut, 00307 const int fAngle); 00308 00309 /*!*************************************************************************** 00310 @Function Name PVRTMatrixRotationYF 00311 @Output mOut Rotation matrix 00312 @Input fAngle Angle of the rotation 00313 @Description Create an Y rotation matrix mOut. 00314 *****************************************************************************/ 00315 void PVRTMatrixRotationYF( 00316 PVRTMATRIXf &mOut, 00317 const float fAngle); 00318 /*!*************************************************************************** 00319 @Function Name PVRTMatrixRotationYX 00320 @Output mOut Rotation matrix 00321 @Input fAngle Angle of the rotation 00322 @Description Create an Y rotation matrix mOut. 00323 *****************************************************************************/ 00324 void PVRTMatrixRotationYX( 00325 PVRTMATRIXx &mOut, 00326 const int fAngle); 00327 00328 /*!*************************************************************************** 00329 @Function Name PVRTMatrixRotationZF 00330 @Output mOut Rotation matrix 00331 @Input fAngle Angle of the rotation 00332 @Description Create an Z rotation matrix mOut. 00333 *****************************************************************************/ 00334 void PVRTMatrixRotationZF( 00335 PVRTMATRIXf &mOut, 00336 const float fAngle); 00337 /*!*************************************************************************** 00338 @Function Name PVRTMatrixRotationZX 00339 @Output mOut Rotation matrix 00340 @Input fAngle Angle of the rotation 00341 @Description Create an Z rotation matrix mOut. 00342 *****************************************************************************/ 00343 void PVRTMatrixRotationZX( 00344 PVRTMATRIXx &mOut, 00345 const int fAngle); 00346 00347 /*!*************************************************************************** 00348 @Function Name PVRTMatrixTransposeF 00349 @Output mOut Transposed matrix 00350 @Input mIn Original matrix 00351 @Description Compute the transpose matrix of mIn. 00352 *****************************************************************************/ 00353 void PVRTMatrixTransposeF( 00354 PVRTMATRIXf &mOut, 00355 const PVRTMATRIXf &mIn); 00356 /*!*************************************************************************** 00357 @Function Name PVRTMatrixTransposeX 00358 @Output mOut Transposed matrix 00359 @Input mIn Original matrix 00360 @Description Compute the transpose matrix of mIn. 00361 *****************************************************************************/ 00362 void PVRTMatrixTransposeX( 00363 PVRTMATRIXx &mOut, 00364 const PVRTMATRIXx &mIn); 00365 00366 /*!*************************************************************************** 00367 @Function PVRTMatrixInverseF 00368 @Output mOut Inversed matrix 00369 @Input mIn Original matrix 00370 @Description Compute the inverse matrix of mIn. 00371 The matrix must be of the form : 00372 A 0 00373 C 1 00374 Where A is a 3x3 matrix and C is a 1x3 matrix. 00375 *****************************************************************************/ 00376 void PVRTMatrixInverseF( 00377 PVRTMATRIXf &mOut, 00378 const PVRTMATRIXf &mIn); 00379 /*!*************************************************************************** 00380 @Function PVRTMatrixInverseX 00381 @Output mOut Inversed matrix 00382 @Input mIn Original matrix 00383 @Description Compute the inverse matrix of mIn. 00384 The matrix must be of the form : 00385 A 0 00386 C 1 00387 Where A is a 3x3 matrix and C is a 1x3 matrix. 00388 *****************************************************************************/ 00389 void PVRTMatrixInverseX( 00390 PVRTMATRIXx &mOut, 00391 const PVRTMATRIXx &mIn); 00392 00393 /*!*************************************************************************** 00394 @Function PVRTMatrixInverseExF 00395 @Output mOut Inversed matrix 00396 @Input mIn Original matrix 00397 @Description Compute the inverse matrix of mIn. 00398 Uses a linear equation solver and the knowledge that M.M^-1=I. 00399 Use this fn to calculate the inverse of matrices that 00400 PVRTMatrixInverse() cannot. 00401 *****************************************************************************/ 00402 void PVRTMatrixInverseExF( 00403 PVRTMATRIXf &mOut, 00404 const PVRTMATRIXf &mIn); 00405 /*!*************************************************************************** 00406 @Function PVRTMatrixInverseExX 00407 @Output mOut Inversed matrix 00408 @Input mIn Original matrix 00409 @Description Compute the inverse matrix of mIn. 00410 Uses a linear equation solver and the knowledge that M.M^-1=I. 00411 Use this fn to calculate the inverse of matrices that 00412 PVRTMatrixInverse() cannot. 00413 *****************************************************************************/ 00414 void PVRTMatrixInverseExX( 00415 PVRTMATRIXx &mOut, 00416 const PVRTMATRIXx &mIn); 00417 00418 /*!*************************************************************************** 00419 @Function PVRTMatrixLookAtLHF 00420 @Output mOut Look-at view matrix 00421 @Input vEye Position of the camera 00422 @Input vAt Point the camera is looking at 00423 @Input vUp Up direction for the camera 00424 @Description Create a look-at view matrix. 00425 *****************************************************************************/ 00426 void PVRTMatrixLookAtLHF( 00427 PVRTMATRIXf &mOut, 00428 const PVRTVECTOR3f &vEye, 00429 const PVRTVECTOR3f &vAt, 00430 const PVRTVECTOR3f &vUp); 00431 /*!*************************************************************************** 00432 @Function PVRTMatrixLookAtLHX 00433 @Output mOut Look-at view matrix 00434 @Input vEye Position of the camera 00435 @Input vAt Point the camera is looking at 00436 @Input vUp Up direction for the camera 00437 @Description Create a look-at view matrix. 00438 *****************************************************************************/ 00439 void PVRTMatrixLookAtLHX( 00440 PVRTMATRIXx &mOut, 00441 const PVRTVECTOR3x &vEye, 00442 const PVRTVECTOR3x &vAt, 00443 const PVRTVECTOR3x &vUp); 00444 00445 /*!*************************************************************************** 00446 @Function PVRTMatrixLookAtRHF 00447 @Output mOut Look-at view matrix 00448 @Input vEye Position of the camera 00449 @Input vAt Point the camera is looking at 00450 @Input vUp Up direction for the camera 00451 @Description Create a look-at view matrix. 00452 *****************************************************************************/ 00453 void PVRTMatrixLookAtRHF( 00454 PVRTMATRIXf &mOut, 00455 const PVRTVECTOR3f &vEye, 00456 const PVRTVECTOR3f &vAt, 00457 const PVRTVECTOR3f &vUp); 00458 /*!*************************************************************************** 00459 @Function PVRTMatrixLookAtRHX 00460 @Output mOut Look-at view matrix 00461 @Input vEye Position of the camera 00462 @Input vAt Point the camera is looking at 00463 @Input vUp Up direction for the camera 00464 @Description Create a look-at view matrix. 00465 *****************************************************************************/ 00466 void PVRTMatrixLookAtRHX( 00467 PVRTMATRIXx &mOut, 00468 const PVRTVECTOR3x &vEye, 00469 const PVRTVECTOR3x &vAt, 00470 const PVRTVECTOR3x &vUp); 00471 00472 /*!*************************************************************************** 00473 @Function PVRTMatrixPerspectiveFovLHF 00474 @Output mOut Perspective matrix 00475 @Input fFOVy Field of view 00476 @Input fAspect Aspect ratio 00477 @Input fNear Near clipping distance 00478 @Input fFar Far clipping distance 00479 @Input bRotate Should we rotate it ? (for upright screens) 00480 @Description Create a perspective matrix. 00481 *****************************************************************************/ 00482 void PVRTMatrixPerspectiveFovLHF( 00483 PVRTMATRIXf &mOut, 00484 const float fFOVy, 00485 const float fAspect, 00486 const float fNear, 00487 const float fFar, 00488 const bool bRotate = false); 00489 /*!*************************************************************************** 00490 @Function PVRTMatrixPerspectiveFovLHX 00491 @Output mOut Perspective matrix 00492 @Input fFOVy Field of view 00493 @Input fAspect Aspect ratio 00494 @Input fNear Near clipping distance 00495 @Input fFar Far clipping distance 00496 @Input bRotate Should we rotate it ? (for upright screens) 00497 @Description Create a perspective matrix. 00498 *****************************************************************************/ 00499 void PVRTMatrixPerspectiveFovLHX( 00500 PVRTMATRIXx &mOut, 00501 const int fFOVy, 00502 const int fAspect, 00503 const int fNear, 00504 const int fFar, 00505 const bool bRotate = false); 00506 00507 /*!*************************************************************************** 00508 @Function PVRTMatrixPerspectiveFovRHF 00509 @Output mOut Perspective matrix 00510 @Input fFOVy Field of view 00511 @Input fAspect Aspect ratio 00512 @Input fNear Near clipping distance 00513 @Input fFar Far clipping distance 00514 @Input bRotate Should we rotate it ? (for upright screens) 00515 @Description Create a perspective matrix. 00516 *****************************************************************************/ 00517 void PVRTMatrixPerspectiveFovRHF( 00518 PVRTMATRIXf &mOut, 00519 const float fFOVy, 00520 const float fAspect, 00521 const float fNear, 00522 const float fFar, 00523 const bool bRotate = false); 00524 /*!*************************************************************************** 00525 @Function PVRTMatrixPerspectiveFovRHX 00526 @Output mOut Perspective matrix 00527 @Input fFOVy Field of view 00528 @Input fAspect Aspect ratio 00529 @Input fNear Near clipping distance 00530 @Input fFar Far clipping distance 00531 @Input bRotate Should we rotate it ? (for upright screens) 00532 @Description Create a perspective matrix. 00533 *****************************************************************************/ 00534 void PVRTMatrixPerspectiveFovRHX( 00535 PVRTMATRIXx &mOut, 00536 const int fFOVy, 00537 const int fAspect, 00538 const int fNear, 00539 const int fFar, 00540 const bool bRotate = false); 00541 00542 /*!*************************************************************************** 00543 @Function PVRTMatrixOrthoLHF 00544 @Output mOut Orthographic matrix 00545 @Input w Width of the screen 00546 @Input h Height of the screen 00547 @Input zn Near clipping distance 00548 @Input zf Far clipping distance 00549 @Input bRotate Should we rotate it ? (for upright screens) 00550 @Description Create an orthographic matrix. 00551 *****************************************************************************/ 00552 void PVRTMatrixOrthoLHF( 00553 PVRTMATRIXf &mOut, 00554 const float w, 00555 const float h, 00556 const float zn, 00557 const float zf, 00558 const bool bRotate = false); 00559 /*!*************************************************************************** 00560 @Function PVRTMatrixOrthoLHX 00561 @Output mOut Orthographic matrix 00562 @Input w Width of the screen 00563 @Input h Height of the screen 00564 @Input zn Near clipping distance 00565 @Input zf Far clipping distance 00566 @Input bRotate Should we rotate it ? (for upright screens) 00567 @Description Create an orthographic matrix. 00568 *****************************************************************************/ 00569 void PVRTMatrixOrthoLHX( 00570 PVRTMATRIXx &mOut, 00571 const int w, 00572 const int h, 00573 const int zn, 00574 const int zf, 00575 const bool bRotate = false); 00576 00577 /*!*************************************************************************** 00578 @Function PVRTMatrixOrthoRHF 00579 @Output mOut Orthographic matrix 00580 @Input w Width of the screen 00581 @Input h Height of the screen 00582 @Input zn Near clipping distance 00583 @Input zf Far clipping distance 00584 @Input bRotate Should we rotate it ? (for upright screens) 00585 @Description Create an orthographic matrix. 00586 *****************************************************************************/ 00587 void PVRTMatrixOrthoRHF( 00588 PVRTMATRIXf &mOut, 00589 const float w, 00590 const float h, 00591 const float zn, 00592 const float zf, 00593 const bool bRotate = false); 00594 /*!*************************************************************************** 00595 @Function PVRTMatrixOrthoRHX 00596 @Output mOut Orthographic matrix 00597 @Input w Width of the screen 00598 @Input h Height of the screen 00599 @Input zn Near clipping distance 00600 @Input zf Far clipping distance 00601 @Input bRotate Should we rotate it ? (for upright screens) 00602 @Description Create an orthographic matrix. 00603 *****************************************************************************/ 00604 void PVRTMatrixOrthoRHX( 00605 PVRTMATRIXx &mOut, 00606 const int w, 00607 const int h, 00608 const int zn, 00609 const int zf, 00610 const bool bRotate = false); 00611 00612 /*!*************************************************************************** 00613 @Function PVRTMatrixVec3LerpF 00614 @Output vOut Result of the interpolation 00615 @Input v1 First vector to interpolate from 00616 @Input v2 Second vector to interpolate form 00617 @Input s Coefficient of interpolation 00618 @Description This function performs the linear interpolation based on 00619 the following formula: V1 + s(V2-V1). 00620 *****************************************************************************/ 00621 void PVRTMatrixVec3LerpF( 00622 PVRTVECTOR3f &vOut, 00623 const PVRTVECTOR3f &v1, 00624 const PVRTVECTOR3f &v2, 00625 const float s); 00626 /*!*************************************************************************** 00627 @Function PVRTMatrixVec3LerpX 00628 @Output vOut Result of the interpolation 00629 @Input v1 First vector to interpolate from 00630 @Input v2 Second vector to interpolate form 00631 @Input s Coefficient of interpolation 00632 @Description This function performs the linear interpolation based on 00633 the following formula: V1 + s(V2-V1). 00634 *****************************************************************************/ 00635 void PVRTMatrixVec3LerpX( 00636 PVRTVECTOR3x &vOut, 00637 const PVRTVECTOR3x &v1, 00638 const PVRTVECTOR3x &v2, 00639 const int s); 00640 00641 /*!*************************************************************************** 00642 @Function PVRTMatrixVec3DotProductF 00643 @Input v1 First vector 00644 @Input v2 Second vector 00645 @Return Dot product of the two vectors. 00646 @Description This function performs the dot product of the two 00647 supplied vectors. 00648 *****************************************************************************/ 00649 float PVRTMatrixVec3DotProductF( 00650 const PVRTVECTOR3f &v1, 00651 const PVRTVECTOR3f &v2); 00652 /*!*************************************************************************** 00653 @Function PVRTMatrixVec3DotProductX 00654 @Input v1 First vector 00655 @Input v2 Second vector 00656 @Return Dot product of the two vectors. 00657 @Description This function performs the dot product of the two 00658 supplied vectors. 00659 A single >> 16 shift could be applied to the final accumulated 00660 result however this runs the risk of overflow between the 00661 results of the intermediate additions. 00662 *****************************************************************************/ 00663 int PVRTMatrixVec3DotProductX( 00664 const PVRTVECTOR3x &v1, 00665 const PVRTVECTOR3x &v2); 00666 00667 /*!*************************************************************************** 00668 @Function PVRTMatrixVec3CrossProductF 00669 @Output vOut Cross product of the two vectors 00670 @Input v1 First vector 00671 @Input v2 Second vector 00672 @Description This function performs the cross product of the two 00673 supplied vectors. 00674 *****************************************************************************/ 00675 void PVRTMatrixVec3CrossProductF( 00676 PVRTVECTOR3f &vOut, 00677 const PVRTVECTOR3f &v1, 00678 const PVRTVECTOR3f &v2); 00679 /*!*************************************************************************** 00680 @Function PVRTMatrixVec3CrossProductX 00681 @Output vOut Cross product of the two vectors 00682 @Input v1 First vector 00683 @Input v2 Second vector 00684 @Description This function performs the cross product of the two 00685 supplied vectors. 00686 *****************************************************************************/ 00687 void PVRTMatrixVec3CrossProductX( 00688 PVRTVECTOR3x &vOut, 00689 const PVRTVECTOR3x &v1, 00690 const PVRTVECTOR3x &v2); 00691 00692 /*!*************************************************************************** 00693 @Function PVRTMatrixVec3NormalizeF 00694 @Output vOut Normalized vector 00695 @Input vIn Vector to normalize 00696 @Description Normalizes the supplied vector. 00697 *****************************************************************************/ 00698 void PVRTMatrixVec3NormalizeF( 00699 PVRTVECTOR3f &vOut, 00700 const PVRTVECTOR3f &vIn); 00701 /*!*************************************************************************** 00702 @Function PVRTMatrixVec3NormalizeX 00703 @Output vOut Normalized vector 00704 @Input vIn Vector to normalize 00705 @Description Normalizes the supplied vector. 00706 The square root function is currently still performed 00707 in floating-point. 00708 Original vector is scaled down prior to be normalized in 00709 order to avoid overflow issues. 00710 *****************************************************************************/ 00711 void PVRTMatrixVec3NormalizeX( 00712 PVRTVECTOR3x &vOut, 00713 const PVRTVECTOR3x &vIn); 00714 00715 /*!*************************************************************************** 00716 @Function PVRTMatrixQuaternionIdentityF 00717 @Output qOut Identity quaternion 00718 @Description Sets the quaternion to (0, 0, 0, 1), the identity quaternion. 00719 *****************************************************************************/ 00720 void PVRTMatrixQuaternionIdentityF( 00721 PVRTQUATERNIONf &qOut); 00722 /*!*************************************************************************** 00723 @Function PVRTMatrixQuaternionIdentityX 00724 @Output qOut Identity quaternion 00725 @Description Sets the quaternion to (0, 0, 0, 1), the identity quaternion. 00726 *****************************************************************************/ 00727 void PVRTMatrixQuaternionIdentityX( 00728 PVRTQUATERNIONx &qOut); 00729 00730 /*!*************************************************************************** 00731 @Function PVRTMatrixQuaternionRotationAxisF 00732 @Output qOut Rotation quaternion 00733 @Input vAxis Axis to rotate around 00734 @Input fAngle Angle to rotate 00735 @Description Create quaternion corresponding to a rotation of fAngle 00736 radians around submitted vector. 00737 *****************************************************************************/ 00738 void PVRTMatrixQuaternionRotationAxisF( 00739 PVRTQUATERNIONf &qOut, 00740 const PVRTVECTOR3f &vAxis, 00741 const float fAngle); 00742 /*!*************************************************************************** 00743 @Function PVRTMatrixQuaternionRotationAxisX 00744 @Output qOut Rotation quaternion 00745 @Input vAxis Axis to rotate around 00746 @Input fAngle Angle to rotate 00747 @Description Create quaternion corresponding to a rotation of fAngle 00748 radians around submitted vector. 00749 *****************************************************************************/ 00750 void PVRTMatrixQuaternionRotationAxisX( 00751 PVRTQUATERNIONx &qOut, 00752 const PVRTVECTOR3x &vAxis, 00753 const int fAngle); 00754 00755 00756 /*!*************************************************************************** 00757 @Function PVRTMatrixQuaternionToAxisAngleF 00758 @Input qIn Quaternion to transform 00759 @Output vAxis Axis of rotation 00760 @Output fAngle Angle of rotation 00761 @Description Convert a quaternion to an axis and angle. Expects a unit 00762 quaternion. 00763 *****************************************************************************/ 00764 void PVRTMatrixQuaternionToAxisAngleF( 00765 const PVRTQUATERNIONf &qIn, 00766 PVRTVECTOR3f &vAxis, 00767 float &fAngle); 00768 /*!*************************************************************************** 00769 @Function PVRTMatrixQuaternionToAxisAngleX 00770 @Input qIn Quaternion to transform 00771 @Output vAxis Axis of rotation 00772 @Output fAngle Angle of rotation 00773 @Description Convert a quaternion to an axis and angle. Expects a unit 00774 quaternion. 00775 *****************************************************************************/ 00776 void PVRTMatrixQuaternionToAxisAngleX( 00777 const PVRTQUATERNIONx &qIn, 00778 PVRTVECTOR3x &vAxis, 00779 int &fAngle); 00780 00781 /*!*************************************************************************** 00782 @Function PVRTMatrixQuaternionSlerpF 00783 @Output qOut Result of the interpolation 00784 @Input qA First quaternion to interpolate from 00785 @Input qB Second quaternion to interpolate from 00786 @Input t Coefficient of interpolation 00787 @Description Perform a Spherical Linear intERPolation between quaternion A 00788 and quaternion B at time t. t must be between 0.0f and 1.0f 00789 *****************************************************************************/ 00790 void PVRTMatrixQuaternionSlerpF( 00791 PVRTQUATERNIONf &qOut, 00792 const PVRTQUATERNIONf &qA, 00793 const PVRTQUATERNIONf &qB, 00794 const float t); 00795 /*!*************************************************************************** 00796 @Function PVRTMatrixQuaternionSlerpX 00797 @Output qOut Result of the interpolation 00798 @Input qA First quaternion to interpolate from 00799 @Input qB Second quaternion to interpolate from 00800 @Input t Coefficient of interpolation 00801 @Description Perform a Spherical Linear intERPolation between quaternion A 00802 and quaternion B at time t. t must be between 0.0f and 1.0f 00803 Requires input quaternions to be normalized 00804 *****************************************************************************/ 00805 void PVRTMatrixQuaternionSlerpX( 00806 PVRTQUATERNIONx &qOut, 00807 const PVRTQUATERNIONx &qA, 00808 const PVRTQUATERNIONx &qB, 00809 const int t); 00810 00811 /*!*************************************************************************** 00812 @Function PVRTMatrixQuaternionNormalizeF 00813 @Modified quat Vector to normalize 00814 @Description Normalize quaternion. 00815 *****************************************************************************/ 00816 void PVRTMatrixQuaternionNormalizeF(PVRTQUATERNIONf &quat); 00817 /*!*************************************************************************** 00818 @Function PVRTMatrixQuaternionNormalizeX 00819 @Modified quat Vector to normalize 00820 @Description Normalize quaternion. 00821 Original quaternion is scaled down prior to be normalized in 00822 order to avoid overflow issues. 00823 *****************************************************************************/ 00824 void PVRTMatrixQuaternionNormalizeX(PVRTQUATERNIONx &quat); 00825 00826 /*!*************************************************************************** 00827 @Function PVRTMatrixRotationQuaternionF 00828 @Output mOut Resulting rotation matrix 00829 @Input quat Quaternion to transform 00830 @Description Create rotation matrix from submitted quaternion. 00831 Assuming the quaternion is of the form [X Y Z W]: 00832 00833 | 2 2 | 00834 | 1 - 2Y - 2Z 2XY - 2ZW 2XZ + 2YW 0 | 00835 | | 00836 | 2 2 | 00837 M = | 2XY + 2ZW 1 - 2X - 2Z 2YZ - 2XW 0 | 00838 | | 00839 | 2 2 | 00840 | 2XZ - 2YW 2YZ + 2XW 1 - 2X - 2Y 0 | 00841 | | 00842 | 0 0 0 1 | 00843 *****************************************************************************/ 00844 void PVRTMatrixRotationQuaternionF( 00845 PVRTMATRIXf &mOut, 00846 const PVRTQUATERNIONf &quat); 00847 /*!*************************************************************************** 00848 @Function PVRTMatrixRotationQuaternionX 00849 @Output mOut Resulting rotation matrix 00850 @Input quat Quaternion to transform 00851 @Description Create rotation matrix from submitted quaternion. 00852 Assuming the quaternion is of the form [X Y Z W]: 00853 00854 | 2 2 | 00855 | 1 - 2Y - 2Z 2XY - 2ZW 2XZ + 2YW 0 | 00856 | | 00857 | 2 2 | 00858 M = | 2XY + 2ZW 1 - 2X - 2Z 2YZ - 2XW 0 | 00859 | | 00860 | 2 2 | 00861 | 2XZ - 2YW 2YZ + 2XW 1 - 2X - 2Y 0 | 00862 | | 00863 | 0 0 0 1 | 00864 *****************************************************************************/ 00865 void PVRTMatrixRotationQuaternionX( 00866 PVRTMATRIXx &mOut, 00867 const PVRTQUATERNIONx &quat); 00868 00869 /*!*************************************************************************** 00870 @Function PVRTMatrixQuaternionMultiplyF 00871 @Output qOut Resulting quaternion 00872 @Input qA First quaternion to multiply 00873 @Input qB Second quaternion to multiply 00874 @Description Multiply quaternion A with quaternion B and return the 00875 result in qOut. 00876 *****************************************************************************/ 00877 void PVRTMatrixQuaternionMultiplyF( 00878 PVRTQUATERNIONf &qOut, 00879 const PVRTQUATERNIONf &qA, 00880 const PVRTQUATERNIONf &qB); 00881 /*!*************************************************************************** 00882 @Function PVRTMatrixQuaternionMultiplyX 00883 @Output qOut Resulting quaternion 00884 @Input qA First quaternion to multiply 00885 @Input qB Second quaternion to multiply 00886 @Description Multiply quaternion A with quaternion B and return the 00887 result in qOut. 00888 Input quaternions must be normalized. 00889 *****************************************************************************/ 00890 void PVRTMatrixQuaternionMultiplyX( 00891 PVRTQUATERNIONx &qOut, 00892 const PVRTQUATERNIONx &qA, 00893 const PVRTQUATERNIONx &qB); 00894 00895 /*!*************************************************************************** 00896 @Function PVRTMatrixLinearEqSolveF 00897 @Input pSrc 2D array of floats. 4 Eq linear problem is 5x4 00898 matrix, constants in first column 00899 @Input nCnt Number of equations to solve 00900 @Output pRes Result 00901 @Description Solves 'nCnt' simultaneous equations of 'nCnt' variables. 00902 pRes should be an array large enough to contain the 00903 results: the values of the 'nCnt' variables. 00904 This fn recursively uses Gaussian Elimination. 00905 *****************************************************************************/ 00906 void PVRTMatrixLinearEqSolveF( 00907 float * const pRes, 00908 float ** const pSrc, 00909 const int nCnt); 00910 /*!*************************************************************************** 00911 @Function PVRTMatrixLinearEqSolveX 00912 @Input pSrc 2D array of floats. 4 Eq linear problem is 5x4 00913 matrix, constants in first column 00914 @Input nCnt Number of equations to solve 00915 @Output pRes Result 00916 @Description Solves 'nCnt' simultaneous equations of 'nCnt' variables. 00917 pRes should be an array large enough to contain the 00918 results: the values of the 'nCnt' variables. 00919 This fn recursively uses Gaussian Elimination. 00920 *****************************************************************************/ 00921 void PVRTMatrixLinearEqSolveX( 00922 int * const pRes, 00923 int ** const pSrc, 00924 const int nCnt); 00925 00926 00927 #endif 00928 00929 /***************************************************************************** 00930 End of file (PVRTMatrix.h) 00931 *****************************************************************************/
Copyright © 1999-2006, PowerVR Technologies and partners. PowerVR Technologies is a division of Imagination Technologies Ltd.