mTransform.h
Engine/source/math/mTransform.h
Classes:
class
A transform expressed as a combination of a position vector and an angular orientation.
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _MTRANSFORM_H_ 25#define _MTRANSFORM_H_ 26 27#ifndef _MPOINT3_H_ 28 #include "math/mPoint3.h" 29#endif 30#ifndef _MANGAXIS_H_ 31 #include "math/mAngAxis.h" 32#endif 33#ifndef _MMATRIX_H_ 34 #include "math/mMatrix.h" 35#endif 36 37/// A transform expressed as a combination of a position vector and an angular 38/// orientation. 39class TransformF 40{ 41 public: 42 43 Point3F mPosition; 44 AngAxisF mOrientation; 45 bool mHasRotation; 46 47 static const TransformF Identity; 48 49 TransformF() 50 : mPosition( Point3F::Zero ), 51 mOrientation( Point3F( 0, 0, 1 ), 0 ), 52 mHasRotation(true) 53 { 54 } 55 56 TransformF( const Point3F& position, const AngAxisF& orientation ) 57 { 58 set( position, orientation ); 59 mHasRotation = true; 60 } 61 62 TransformF( const MatrixF& mat ) 63 { 64 set( mat ); 65 mHasRotation = true; 66 } 67 68 bool hasRotation() const { return mHasRotation; } 69 70 void set( const Point3F& position, const AngAxisF& orientation ) 71 { 72 mPosition = position; 73 mOrientation = orientation; 74 } 75 76 void set( const MatrixF& mat ) 77 { 78 mPosition = mat.getPosition(); 79 mOrientation.set( mat ); 80 } 81 82 /// Return the position vector of the transform. 83 const Point3F& getPosition() const { return mPosition; } 84 85 /// REturn the orientation of the transform. 86 const AngAxisF& getOrientation() const { return mOrientation; } 87 88 MatrixF getMatrix() const 89 { 90 MatrixF mat; 91 mOrientation.setMatrix( &mat ); 92 mat.setPosition( mPosition ); 93 94 return mat; 95 } 96}; 97 98#endif // !_MTRANSFORM_H_ 99