Honeycomb  0.1
Component-Model Framework
Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Friends | List of all members
honey::Transform_< Real > Class Template Reference

A 3D linear transform from TRS components (translation, rotation, and scale/skew) More...

#include <Matrix4.h>

Collaboration diagram for honey::Transform_< Real >:
Collaboration graph
[legend]

Public Member Functions

 Transform_ ()
 Init to identity. More...
 
 Transform_ (const Vec3 &trans, const Quat &rot=Quat::identity, const Vec3 &scale=Vec3::one, const Quat &skew=Quat::identity)
 Construct from TRS components. More...
 
 Transform_ (const Matrix4 &mat)
 Construct from matrix. Matrix will be decomposed, an expensive operation. More...
 
 ~Transform_ ()
 
Transform_fromIdentity ()
 Init to identity. More...
 
Transform_fromTrs (const Vec3 &trans, const Quat &rot=Quat::identity, const Vec3 &scale=Vec3::one, const Quat &skew=Quat::identity)
 Init from TRS components. More...
 
Transform_fromMatrix (const Matrix4 &mat)
 Init from matrix. Matrix will be decomposed, an expensive operation. More...
 
Transform_operator= (const Transform_ &rhs)
 
Transform_ operator* (const Transform_ &tm) const
 
Vec3 operator* (const Vec3 &v) const
 
Vec4 operator* (const Vec4 &v) const
 
Vec2 operator* (const Vec2 &v) const
 
Transform_operator*= (const Transform_ &tm)
 
Vec3 mulRotScale (const Vec3 &v) const
 Transform by just rotation and scale/skew components (no translation) More...
 
bool operator== (const Transform_ &rhs) const
 
bool operator!= (const Transform_ &rhs) const
 
Transform_ inverse () const
 
void resetTrans ()
 
void resetRot ()
 
void resetScale ()
 
void setTrans (const Vec3 &trans)
 
const Vec3getTrans () const
 
void setRot (const Quat &rot)
 
const QuatgetRot () const
 
void setScale (const Vec3 &scale, const Quat &skew=Quat::identity)
 
void setScale (Real f)
 
const Vec3getScale () const
 
const QuatgetSkew () const
 
void getTrs (optional< Vec3 & > trans=optnull, optional< Quat & > rot=optnull, optional< Vec3 & > scale=optnull, optional< Quat & > skew=optnull) const
 
Transform_translate (const Vec3 &v)
 Make a tm that performs this transform first, then does a translation. ie. T * this. More...
 
Transform_preTranslate (const Vec3 &v)
 Make a tm that does a translation first, then performs this transform. ie. this * T. More...
 
Transform_rotate (const Quat &q)
 Make a tm that performs this transform first, then does a rotation. ie. R * this. More...
 
Transform_preRotate (const Quat &q)
 Make a tm that does a rotation first, then performs this transform. ie. this * R. More...
 
Transform_scale (const Vec3 &v, const Quat &skew=Quat::identity)
 Make a tm that performs this transform first, then does a scale. ie. S * this. More...
 
Transform_scale (Real f)
 Uniform scale. More...
 
Transform_preScale (const Vec3 &v, const Quat &skew=Quat::identity)
 Make a tm that does a scale first, then performs this transform. ie. this * S. More...
 
Transform_preScale (Real f)
 Uniform prescale. More...
 
bool isIdentity () const
 
bool hasTrans () const
 
bool hasRot () const
 
bool hasScale () const
 
bool hasUniformScale () const
 
bool hasSkew () const
 

Static Public Attributes

static const Transform_ identity
 

Protected Types

typedef Vec< 2, RealVec2
 
typedef Vec< 3, RealVec3
 
typedef Vec< 4, RealVec4
 
typedef Matrix< 4, 4, RealMatrix4
 
typedef Quat_< RealQuat
 

Protected Member Functions

virtual void onTmChange ()
 

Friends

ostream & operator<< (ostream &os, const Transform_ &tm)
 

Detailed Description

template<class Real>
class honey::Transform_< Real >

A 3D linear transform from TRS components (translation, rotation, and scale/skew)

The TRS model is equivalent to a 4x4 affine homogeneous matrix where translation occupies the last column, and rotation combines with scale/skew to form a 3x3 sub-matrix in the upper-left:

| RS   RS   RS   Tx |   T: Translation
| RS   RS   RS   Ty |   R: Rotation
| RS   RS   RS   Tz |   S: Scale/Skew
| 0    0    0    1  |

$ tm = T R S $ -> A transform first scales (S), then rotates (R), then translates (T).
$ S = U K U^{-1} $ -> Scaling is done by first rotating into scale-space using the inverse of skew ( $U^{-1}$) then scaling (K), then rotating back out of scale-space (U).

Advantages of TRS model over affine matrix model:

Disadvantages:

Be wary of the following operations:

Member Typedef Documentation

template<class Real >
typedef Matrix<4,4,Real> honey::Transform_< Real >::Matrix4
protected
template<class Real >
typedef Quat_<Real> honey::Transform_< Real >::Quat
protected
template<class Real >
typedef Vec<2,Real> honey::Transform_< Real >::Vec2
protected
template<class Real >
typedef Vec<3,Real> honey::Transform_< Real >::Vec3
protected
template<class Real >
typedef Vec<4,Real> honey::Transform_< Real >::Vec4
protected

Constructor & Destructor Documentation

template<class Real >
honey::Transform_< Real >::Transform_ ( )
inline

Init to identity.

template<class Real >
honey::Transform_< Real >::Transform_ ( const Vec3 trans,
const Quat rot = Quat::identity,
const Vec3 scale = Vec3::one,
const Quat skew = Quat::identity 
)
inline

Construct from TRS components.

template<class Real >
honey::Transform_< Real >::Transform_ ( const Matrix4 mat)
inlineexplicit

Construct from matrix. Matrix will be decomposed, an expensive operation.

template<class Real >
honey::Transform_< Real >::~Transform_ ( )
inline

Member Function Documentation

template<class Real >
Transform_& honey::Transform_< Real >::fromIdentity ( )
inline

Init to identity.

template<class Real >
Transform_& honey::Transform_< Real >::fromMatrix ( const Matrix4 mat)
inline

Init from matrix. Matrix will be decomposed, an expensive operation.

template<class Real >
Transform_& honey::Transform_< Real >::fromTrs ( const Vec3 trans,
const Quat rot = Quat::identity,
const Vec3 scale = Vec3::one,
const Quat skew = Quat::identity 
)
inline

Init from TRS components.

template<class Real >
const Quat& honey::Transform_< Real >::getRot ( ) const
inline
template<class Real >
const Vec3& honey::Transform_< Real >::getScale ( ) const
inline
template<class Real >
const Quat& honey::Transform_< Real >::getSkew ( ) const
inline
template<class Real >
const Vec3& honey::Transform_< Real >::getTrans ( ) const
inline
template<class Real >
void honey::Transform_< Real >::getTrs ( optional< Vec3 & >  trans = optnull,
optional< Quat & >  rot = optnull,
optional< Vec3 & >  scale = optnull,
optional< Quat & >  skew = optnull 
) const
inline
template<class Real >
bool honey::Transform_< Real >::hasRot ( ) const
inline
template<class Real >
bool honey::Transform_< Real >::hasScale ( ) const
inline
template<class Real >
bool honey::Transform_< Real >::hasSkew ( ) const
inline
template<class Real >
bool honey::Transform_< Real >::hasTrans ( ) const
inline
template<class Real >
bool honey::Transform_< Real >::hasUniformScale ( ) const
inline
template<class Real >
Transform_< Real > honey::Transform_< Real >::inverse ( ) const
template<class Real >
bool honey::Transform_< Real >::isIdentity ( ) const
inline
template<class Real >
Vec3 honey::Transform_< Real >::mulRotScale ( const Vec3 v) const
inline

Transform by just rotation and scale/skew components (no translation)

template<class Real >
virtual void honey::Transform_< Real >::onTmChange ( )
inlineprotectedvirtual
template<class Real >
bool honey::Transform_< Real >::operator!= ( const Transform_< Real > &  rhs) const
inline
template<class Real >
Transform_< Real > honey::Transform_< Real >::operator* ( const Transform_< Real > &  tm) const

_bUniformScale && !tm._bUniformScale

template<class Real >
Vec3 honey::Transform_< Real >::operator* ( const Vec3 v) const
inline
template<class Real >
Vec4 honey::Transform_< Real >::operator* ( const Vec4 v) const
inline
template<class Real >
Vec2 honey::Transform_< Real >::operator* ( const Vec2 v) const
inline
template<class Real >
Transform_& honey::Transform_< Real >::operator*= ( const Transform_< Real > &  tm)
inline
template<class Real >
Transform_& honey::Transform_< Real >::operator= ( const Transform_< Real > &  rhs)
inline
template<class Real >
bool honey::Transform_< Real >::operator== ( const Transform_< Real > &  rhs) const
inline
template<class Real >
Transform_& honey::Transform_< Real >::preRotate ( const Quat q)
inline

Make a tm that does a rotation first, then performs this transform. ie. this * R.

template<class Real >
Transform_& honey::Transform_< Real >::preScale ( const Vec3 v,
const Quat skew = Quat::identity 
)
inline

Make a tm that does a scale first, then performs this transform. ie. this * S.

template<class Real >
Transform_& honey::Transform_< Real >::preScale ( Real  f)
inline

Uniform prescale.

template<class Real >
Transform_& honey::Transform_< Real >::preTranslate ( const Vec3 v)
inline

Make a tm that does a translation first, then performs this transform. ie. this * T.

template<class Real >
void honey::Transform_< Real >::resetRot ( )
inline
template<class Real >
void honey::Transform_< Real >::resetScale ( )
inline
template<class Real >
void honey::Transform_< Real >::resetTrans ( )
inline
template<class Real >
Transform_& honey::Transform_< Real >::rotate ( const Quat q)
inline

Make a tm that performs this transform first, then does a rotation. ie. R * this.

template<class Real >
Transform_& honey::Transform_< Real >::scale ( const Vec3 v,
const Quat skew = Quat::identity 
)
inline

Make a tm that performs this transform first, then does a scale. ie. S * this.

template<class Real >
Transform_& honey::Transform_< Real >::scale ( Real  f)
inline

Uniform scale.

template<class Real >
void honey::Transform_< Real >::setRot ( const Quat rot)
inline
template<class Real >
void honey::Transform_< Real >::setScale ( const Vec3 scale,
const Quat skew = Quat::identity 
)
inline
template<class Real >
void honey::Transform_< Real >::setScale ( Real  f)
inline
template<class Real >
void honey::Transform_< Real >::setTrans ( const Vec3 trans)
inline
template<class Real >
Transform_& honey::Transform_< Real >::translate ( const Vec3 v)
inline

Make a tm that performs this transform first, then does a translation. ie. T * this.

Friends And Related Function Documentation

template<class Real >
ostream& operator<< ( ostream &  os,
const Transform_< Real > &  tm 
)
friend

Member Data Documentation

template<class Real >
const Transform_< Real > honey::Transform_< Real >::identity
static

The documentation for this class was generated from the following files: