fbsdk/fbmath.h Source File
 
 
 
fbsdk/fbmath.h
Go to the documentation of this file.
00001 #ifndef __FBMATH_H__
00002 #define __FBMATH_H__
00003 /**************************************************************************
00004  Copyright (c) 1994 - 2009 Autodesk, Inc. and/or its licensors.
00005  All Rights Reserved.
00006  
00007  The coded instructions, statements, computer programs, and/or related 
00008  material (collectively the "Data") in these files contain unpublished 
00009  information proprietary to Autodesk, Inc. and/or its licensors, which is 
00010  protected by Canada and United States of America federal copyright law 
00011  and by international treaties.
00012  
00013  The Data may not be disclosed or distributed to third parties, in whole 
00014  or in part, without the prior written consent of Autodesk, Inc. 
00015  ("Autodesk").
00016  
00017  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00018  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO 
00019  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR 
00020  ARISING BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES 
00021  OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR 
00022  PURPOSE OR USE. WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT 
00023  WARRANT THAT THE OPERATION OF THE DATA WILL BE UNINTERRUPTED OR ERROR 
00024  FREE.
00025  
00026  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS 
00027  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR 
00028  EXPENSES OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE 
00029  DAMAGES OR OTHER SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS 
00030  OF PROFITS, REVENUE OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR 
00031  DAMAGES OF ANY KIND), HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF 
00032  LIABILITY, WHETHER DERIVED FROM CONTRACT, TORT (INCLUDING, BUT NOT 
00033  LIMITED TO, NEGLIGENCE), OR OTHERWISE, ARISING OUT OF OR RELATING TO THE 
00034  DATA OR ITS USE OR ANY OTHER PERFORMANCE, WHETHER OR NOT AUTODESK HAS 
00035  BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
00036  
00037 **************************************************************************/
00038 
00043 #include <kaydaradef.h>
00044 #ifndef FBSDK_DLL
00045 
00048         #define FBSDK_DLL K_DLLIMPORT
00049 #endif
00050 
00051 #include <fbsdk/fbtypes.h>
00052 
00053 #ifdef FBSDKUseNamespace
00054         namespace FBSDKNamespace {
00055 #endif
00056 
00058 enum FBRotationOrder { 
00059         kFBXYZ,         
00060     kFBXZY,     
00061     kFBYXZ,     
00062         kFBYZX,         
00063         kFBZXY,         
00064     kFBZYX,     
00065 };
00066 
00067 FB_DEFINE_ENUM( FBSDK_DLL, RotationOrder ); 
00068 
00070 // Matrix
00072 
00076 FBSDK_DLL void FBMatrixInverse (FBMatrix  &pMatrix, const FBMatrix  &pSrc);
00077 
00082 FBSDK_DLL void FBMatrixTranspose (FBMatrix  &pMatrix, const FBMatrix  &pSrc);
00083 
00089 FBSDK_DLL void FBMatrixMult     (FBMatrix  &pMatrix, const FBMatrix  &pA, const FBMatrix  &pB);
00090 
00096 FBSDK_DLL void FBVertexMatrixMult( FBVertex &pOutVertex, const FBMatrix &pMatrix,       const FBVertex &pVertex );
00097 
00103 FBSDK_DLL void FBVectorMatrixMult( FBVector4d &pOutVector, const FBMatrix &pMatrix, const FBVector4d &pVector );
00104 
00106 // T,R,S to Matrix
00108 // N.B. Rotation is in EulerXYZ
00113 FBSDK_DLL void FBTranslationToMatrix    (FBMatrix  &pMatrix,            const FBTVector& pVector);
00114 
00120 FBSDK_DLL void FBRotationToMatrix               (FBMatrix  &pMatrix,            const FBRVector& pVector, FBRotationOrder pRotationOrder = kFBXYZ);
00121 
00126 FBSDK_DLL void FBScalingToMatrix                (FBMatrix  &pMatrix,            const FBSVector& pVector);
00127 
00135 FBSDK_DLL void FBTRSToMatrix                    (FBMatrix  &pMatrix,            const FBTVector& pTVector, const FBRVector& pRVector, const FBSVector& pSVector);
00136 
00138 // Matrix to T,R,S
00140 // Rotation is in EulerXYZ
00145 FBSDK_DLL void FBMatrixToTranslation    (FBTVector &pVector,            const FBMatrix& pMatrix);
00146 
00153 FBSDK_DLL void FBMatrixToRotation               (FBRVector &pVector,            const FBMatrix& pMatrix, FBRotationOrder pRotationOrder = kFBXYZ);
00154 
00159 FBSDK_DLL void FBMatrixToScaling                (FBSVector &pVector,            const FBMatrix& pMatrix);
00160 
00168 FBSDK_DLL void FBMatrixToTRS                    (FBTVector &pTVector, FBRVector &pRVector, FBSVector &pSVector, const FBMatrix& pMatrix);
00169 
00171 // Quaternion
00173 
00178 FBSDK_DLL void FBRotationToQuaternion   (FBQuaternion &pQuaternion,     const FBRVector& pVector, FBRotationOrder pRotationOrder = kFBXYZ);
00179 
00186 FBSDK_DLL void FBQuaternionToRotation   (FBRVector &pVector,            const FBQuaternion& pQuaternion, FBRotationOrder pRotationOrder = kFBXYZ);
00187 
00193 FBSDK_DLL void FBMatrixToQuaternion(FBQuaternion &pQuaternion,  const FBMatrix& pMatrix);
00194 
00199 FBSDK_DLL void FBQuaternionToMatrix(FBMatrix &pMatrix,          const FBQuaternion& pQuaternion);
00200 
00201 
00203 // Local/Global conversions
00205 
00212 FBSDK_DLL void FBGetLocalMatrix                 (FBMatrix &pMatrix, const FBMatrix& pMatrixParent, const FBMatrix& pMatrixChild);
00213 
00221 FBSDK_DLL void FBGetGlobalMatrix                (FBMatrix &pMatrix, const FBMatrix& pMatrixParent, const FBMatrix& pLocalMatrix);
00222 
00223 
00228 FBSDK_DLL void FBMatrixOrthogonalize    (FBMatrix &pMatrix);
00229 
00231 // Vector operations
00233 
00238 FBSDK_DLL void          FBAdd                           (FBTVector &pResult, const FBTVector &pV1, const FBTVector &pV2);
00239 
00245 FBSDK_DLL void          FBSub                           (FBTVector &pResult, const FBTVector &pV1, const FBTVector &pV2);
00246 
00252 FBSDK_DLL void          FBMult                          (FBTVector &pResult, const FBTVector &pV1, double pV2);
00253 
00259 FBSDK_DLL void          FBMult                          (FBTVector &pResult, const FBTVector &pV1, const FBTVector &pV2);
00260 
00266 FBSDK_DLL void          FBMult                          (FBMatrix &pResult, const FBMatrix &pM, const FBSVector &pV);
00267 
00273 FBSDK_DLL double        FBDot                           (const FBTVector &pV1, const FBTVector &pV2);
00274 
00279 FBSDK_DLL double        FBLength                        (const FBTVector &pV);
00280 
00282 // Quaternion operations
00284 
00289 FBSDK_DLL void          FBQAdd                          (FBQuaternion &pResult, const FBQuaternion &pQ1, const FBQuaternion &pQ2);
00290 
00296 FBSDK_DLL void          FBQSub                          (FBQuaternion &pResult, const FBQuaternion &pQ1, const FBQuaternion &pQ2);
00297 
00303 FBSDK_DLL void          FBQMult                         (FBQuaternion &pResult, const FBQuaternion &pQ1, double pQ2);
00304 
00310 FBSDK_DLL void          FBQMult                         (FBQuaternion &pResult, const FBQuaternion &pQ1, const FBQuaternion &pQ2);
00311 
00317 FBSDK_DLL double        FBQDot                          (const FBQuaternion &pQ1, const FBQuaternion &pQ2);
00318 
00323 FBSDK_DLL double        FBQLength                       (const FBQuaternion &pQ);
00324 
00326 // Vertex operations
00328 
00332 FBSDK_DLL double        FBLength                        (const FBVertex &pV);
00333 
00335 // Rotation utilities
00337 
00343 FBSDK_DLL void  FBInterpolateRotation( FBRVector &pROut, const FBRVector &pR0, const FBRVector &pR1, double pU );
00344 
00351 FBSDK_DLL void  FBInterpolateRotation( FBQuaternion &pQOut, const FBQuaternion &pQ0, const FBQuaternion &pQ1, double pU );
00352 
00359 FBSDK_DLL void          FBGetContinuousRotation ( FBRVector &pROut, const FBRVector &pR0, const FBRVector &pR1 );
00360 
00362 // Miscellaneous utilities 
00364 
00370 FBSDK_DLL double        FBClamp         (double pV, double pL, double pH);
00371 
00375 FBSDK_DLL void  FBBigEndianToNative             (unsigned short &pV);
00376 
00380 FBSDK_DLL void  FBLittleEndianToNative  (unsigned short &pV);
00381 
00382 
00383 #ifdef FBSDKUseNamespace
00384         }
00385 #endif
00386 #endif