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,FBMatrix  &pSrc);
00077 
00082 FBSDK_DLL void FBMatrixTranspose (FBMatrix  &pMatrix,FBMatrix  &pSrc);
00083 
00089 FBSDK_DLL void FBMatrixMult (FBMatrix  &pMatrix,FBMatrix  &pA,FBMatrix  &pB);
00090 
00096 FBSDK_DLL void FBVertexMatrixMult( FBVertex &pOutVertex, FBMatrix &pMatrix, FBVertex &pVertex );
00097 
00103 FBSDK_DLL void FBVectorMatrixMult( FBVector4d &pOutVector, FBMatrix &pMatrix, FBVector4d &pVector );
00104 
00106 // T,R,S to Matrix
00108 // N.B. Rotation is in EulerXYZ
00113 FBSDK_DLL void FBTranslationToMatrix    (FBMatrix  &pMatrix,        FBTVector pVector);
00114 
00120 FBSDK_DLL void FBRotationToMatrix       (FBMatrix  &pMatrix,        FBRVector pVector, FBRotationOrder pRotationOrder = kFBXYZ);
00121 
00126 FBSDK_DLL void FBScalingToMatrix        (FBMatrix  &pMatrix,        FBSVector pVector);
00127 
00135 FBSDK_DLL void FBTRSToMatrix            (FBMatrix  &pMatrix,        FBTVector pTVector, FBRVector pRVector, FBSVector pSVector);
00136 
00138 // Matrix to T,R,S
00140 // Rotation is in EulerXYZ
00145 FBSDK_DLL void FBMatrixToTranslation    (FBTVector &pVector,        FBMatrix pMatrix);
00146 
00153 FBSDK_DLL void FBMatrixToRotation       (FBRVector &pVector,        FBMatrix pMatrix, FBRotationOrder pRotationOrder = kFBXYZ);
00154 
00159 FBSDK_DLL void FBMatrixToScaling        (FBSVector &pVector,        FBMatrix pMatrix);
00160 
00168 FBSDK_DLL void FBMatrixToTRS            (FBTVector &pTVector, FBRVector &pRVector, FBSVector &pSVector,FBMatrix pMatrix);
00169 
00171 // Quaternion
00173 
00178 FBSDK_DLL void FBRotationToQuaternion   (FBQuaternion &pQuaternion, FBRVector pVector, FBRotationOrder pRotationOrder = kFBXYZ);
00179 
00186 FBSDK_DLL void FBQuaternionToRotation   (FBRVector &pVector,        FBQuaternion pQuaternion, FBRotationOrder pRotationOrder = kFBXYZ);
00187 
00188 
00190 // Local/Global conversions
00192 
00199 FBSDK_DLL void FBGetLocalMatrix         (FBMatrix &pMatrix, FBMatrix pMatrixParent, FBMatrix pMatrixChild);
00200 
00208 FBSDK_DLL void FBGetGlobalMatrix        (FBMatrix &pMatrix, FBMatrix pMatrixParent, FBMatrix pLocalMatrix);
00209 
00210 
00217 FBSDK_DLL void FBMatrixOrthogonalize    (FBMatrix &pMatrix);
00218 
00220 // Vector operations
00222 
00227 FBSDK_DLL void      FBAdd               (FBTVector &pResult, FBTVector &pV1, FBTVector &pV2);
00228 
00234 FBSDK_DLL void      FBSub               (FBTVector &pResult, FBTVector &pV1, FBTVector &pV2);
00235 
00241 FBSDK_DLL void      FBMult              (FBTVector &pResult, FBTVector &pV1, double pV2);
00242 
00248 FBSDK_DLL void      FBMult              (FBTVector &pResult, FBTVector &pV1, FBTVector &pV2);
00249 
00255 FBSDK_DLL void      FBMult              (FBMatrix &pResult, FBMatrix &pM, FBSVector &pV);
00256 
00262 FBSDK_DLL double    FBDot               (FBTVector &pV1, FBTVector &pV2);
00263 
00268 FBSDK_DLL double    FBLength            (FBTVector &pV);
00269 
00271 // Quaternion operations
00273 
00278 FBSDK_DLL void      FBQAdd              (FBQuaternion &pResult, const FBQuaternion &pQ1, const FBQuaternion &pQ2);
00279 
00285 FBSDK_DLL void      FBQSub              (FBQuaternion &pResult, const FBQuaternion &pQ1, const FBQuaternion &pQ2);
00286 
00292 FBSDK_DLL void      FBQMult             (FBQuaternion &pResult, const FBQuaternion &pQ1, double pQ2);
00293 
00299 FBSDK_DLL void      FBQMult             (FBQuaternion &pResult, const FBQuaternion &pQ1, const FBQuaternion &pQ2);
00300 
00306 FBSDK_DLL double    FBQDot              (const FBQuaternion &pQ1, const FBQuaternion &pQ2);
00307 
00312 FBSDK_DLL double    FBQLength           (const FBQuaternion &pQ);
00313 
00315 // Vertex operations
00317 
00321 FBSDK_DLL double    FBLength            (FBVertex &pV);
00322 
00324 // Rotation utilities
00326 
00332 FBSDK_DLL void  FBInterpolateRotation( FBRVector &pROut, const FBRVector &pR0, const FBRVector &pR1, double pU );
00333 
00340 FBSDK_DLL void  FBInterpolateRotation( FBQuaternion &pQOut, const FBQuaternion &pQ0, const FBQuaternion &pQ1, double pU );
00341 
00348 FBSDK_DLL void      FBGetContinuousRotation ( FBRVector &pROut, FBRVector &pR0, FBRVector &pR1 );
00349 
00351 // Miscellaneous utilities 
00353 
00359 FBSDK_DLL double    FBClamp     (double pV, double pL, double pH);
00360 
00364 FBSDK_DLL void  FBBigEndianToNative     (unsigned short &pV);
00365 
00369 FBSDK_DLL void  FBLittleEndianToNative  (unsigned short &pV);
00370 
00371 
00372 #ifdef FBSDKUseNamespace
00373     }
00374 #endif
00375 #endif