library of assembled shared sources

http://lass.cocamware.com

lass::prim::Transformation2D< T > Class Template Reference

a linear 2D transformation More...

#include <transformation_2d.h>

Collaboration diagram for lass::prim::Transformation2D< T >:

Collaboration graph
[legend]

Data Structures

struct  Rebind

Public Types

enum  { dimension = 3 }
typedef Transformation2D< T > TSelf
typedef util::CallTraits< T >
::TValue 
TValue
typedef util::CallTraits< T >
::TParam 
TParam
typedef util::CallTraits< T >
::TReference 
TReference
typedef util::CallTraits< T >
::TConstReference 
TConstReference
typedef num::NumTraits< T > TNumTraits
typedef size_t TSize

Public Member Functions

 Transformation2D ()
 construct an identity transformation.
template<typename InputIterator >
 Transformation2D (InputIterator first, InputIterator last)
 construct a transformation from a 3x3 tranformation matrix.
const Transformation2D< T > inverse () const
 return the inverse transformation.
const TValuematrix () const
 Return pointer to row major matrix representation of transformation.
void swap (TSelf &other)

Static Public Member Functions

static const TSelf identity ()
 make a 2D identity transformation
static const TSelf translation (const Vector2D< T > &offset)
 make a 2D transformation representing a translation
static const TSelf scaler (const T &scale)
 make a 3D transformation representing a uniform scaling
static const TSelf scaler (const Vector2D< T > &scale)
 make a 3D transformation representing a scaling with different factors per axis
static const TSelf rotation (TParam radians)
 make a 3D transformation representing a counterclockwise rotation

Private Types

enum  { matrixSize_ = 9 }
typedef util::SharedPtr
< TValue,
impl::Transformation2DStorage
TMatrix

Private Member Functions

 Transformation2D (const TMatrix &matrix, const TMatrix &inverseMatrix, bool dummy)

Static Private Member Functions

static const TMatrixgetIdentityMatrix ()

Private Attributes

TMatrix matrix_
TMatrix inverseMatrix_

Static Private Attributes

static TMatrix identityMatrix_
static util::Semaphore sync_

Related Functions

(Note that these are not member functions.)

template<typename T >
Transformation2D< T > concatenate (const Transformation2D< T > &first, const Transformation2D< T > &second)
 concatenate two transformations first and second in one.
template<typename T >
Vector2D< T > transform (const Vector2D< T > &subject, const Transformation2D< T > &transformation)
 apply transformation to a vector
template<typename T >
Point2D< T > transform (const Point2D< T > &subject, const Transformation2D< T > &transformation)
 apply transformation to a point
template<typename T >
Vector2D< T > normalTransform (const Vector2D< T > &subject, const Transformation2D< T > &transformation)
 apply transformation to a normal vector.
template<typename T >
std::pair< Vector2D< T >, T > normalTransform (const std::pair< Vector2D< T >, T > &subject, const Transformation2D< T > &transformation)
 apply transformation to a 3D normal vector.
template<typename T , typename Char , typename Traits >
std::basic_ostream< Char,
Traits > & 
operator<< (std::basic_ostream< Char, Traits > &stream, const Transformation2D< T > &transformation)
template<typename T >
io::XmlOStreamoperator<< (io::XmlOStream &stream, const Transformation2D< T > &transformation)

Detailed Description

template<typename T>
class lass::prim::Transformation2D< T >

a linear 2D transformation

Author:
Bram de Greve [BdG]

Definition at line 83 of file transformation_2d.h.


Member Typedef Documentation

template<typename T >
typedef Transformation2D<T> lass::prim::Transformation2D< T >::TSelf

Definition at line 87 of file transformation_2d.h.

template<typename T >
typedef util::CallTraits<T>::TValue lass::prim::Transformation2D< T >::TValue

Definition at line 89 of file transformation_2d.h.

template<typename T >
typedef util::CallTraits<T>::TParam lass::prim::Transformation2D< T >::TParam

Definition at line 90 of file transformation_2d.h.

template<typename T >
typedef util::CallTraits<T>::TReference lass::prim::Transformation2D< T >::TReference

Definition at line 91 of file transformation_2d.h.

Definition at line 92 of file transformation_2d.h.

template<typename T >
typedef num::NumTraits<T> lass::prim::Transformation2D< T >::TNumTraits

Definition at line 93 of file transformation_2d.h.

template<typename T >
typedef size_t lass::prim::Transformation2D< T >::TSize

Definition at line 94 of file transformation_2d.h.

Definition at line 121 of file transformation_2d.h.


Member Enumeration Documentation

template<typename T >
anonymous enum

Enumerator:
dimension 

Definition at line 96 of file transformation_2d.h.

template<typename T >
anonymous enum [private]

Enumerator:
matrixSize_ 

Definition at line 119 of file transformation_2d.h.


Constructor & Destructor Documentation

template<typename T >
lass::prim::Transformation2D< T >::Transformation2D (  )  [inline]

construct an identity transformation.

An identity transformation transforms every point to itself.

Definition at line 60 of file transformation_2d.inl.

References lass::prim::Transformation2D< T >::matrix_, lass::num::NumTraits< C >::one, and lass::num::NumTraits< C >::zero.

template<typename T >
template<typename InputIterator >
lass::prim::Transformation2D< T >::Transformation2D ( InputIterator  first,
InputIterator  last 
) [inline]

construct a transformation from a 3x3 tranformation matrix.

The elements of the 3x3 matrix will represented in a row major way by an iterator range [first, last) of 9 elements.

Definition at line 83 of file transformation_2d.inl.

References lass::prim::distance(), lass::util::SharedPtr< T, StoragePolicy, CounterPolicy >::get(), LASS_ENFORCE, lass::prim::Transformation2D< T >::matrix_, and lass::prim::Transformation2D< T >::matrixSize_.

template<typename T >
lass::prim::Transformation2D< T >::Transformation2D ( const TMatrix matrix,
const TMatrix inverseMatrix,
bool  dummy 
) [inline, private]

Definition at line 240 of file transformation_2d.inl.


Member Function Documentation

template<typename T >
const Transformation2D< T > lass::prim::Transformation2D< T >::inverse (  )  const [inline]

template<typename T >
const Transformation2D< T >::TValue * lass::prim::Transformation2D< T >::matrix (  )  const [inline]

Return pointer to row major matrix representation of transformation.

This is for immediate use only, like std::basic_string::data().

Definition at line 149 of file transformation_2d.inl.

References lass::util::SharedPtr< T, StoragePolicy, CounterPolicy >::get(), and lass::prim::Transformation2D< T >::matrix_.

Referenced by lass::prim::Transformation2D< T >::concatenate(), and lass::prim::Transformation2D< T >::transform().

template<typename T >
void lass::prim::Transformation2D< T >::swap ( TSelf other  )  [inline]

template<typename T >
const Transformation2D< T > lass::prim::Transformation2D< T >::identity (  )  [inline, static]

make a 2D identity transformation

Definition at line 168 of file transformation_2d.inl.

template<typename T >
const Transformation2D< T > lass::prim::Transformation2D< T >::translation ( const Vector2D< T > &  offset  )  [inline, static]

make a 2D transformation representing a translation

Definition at line 178 of file transformation_2d.inl.

References lass::prim::Transformation2D< T >::matrix_, lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.

template<typename T >
const Transformation2D< T > lass::prim::Transformation2D< T >::scaler ( const T &  scale  )  [inline, static]

make a 3D transformation representing a uniform scaling

Definition at line 192 of file transformation_2d.inl.

References lass::prim::Transformation2D< T >::matrix_.

template<typename T >
const Transformation2D< T > lass::prim::Transformation2D< T >::scaler ( const Vector2D< T > &  scale  )  [inline, static]

make a 3D transformation representing a scaling with different factors per axis

Definition at line 205 of file transformation_2d.inl.

References lass::prim::Transformation2D< T >::matrix_, lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.

template<typename T >
const Transformation2D< T > lass::prim::Transformation2D< T >::rotation ( TParam  radians  )  [inline, static]

make a 3D transformation representing a counterclockwise rotation

Definition at line 218 of file transformation_2d.inl.

References lass::prim::cos(), lass::prim::Transformation2D< T >::matrix_, lass::num::sin(), and lass::stde::T.

template<typename T >
static const TMatrix& lass::prim::Transformation2D< T >::getIdentityMatrix (  )  [static, private]


Friends And Related Function Documentation

template<typename T >
Transformation2D< T > concatenate ( const Transformation2D< T > &  first,
const Transformation2D< T > &  second 
) [related]

concatenate two transformations first and second in one.

The result is one transformation that performs the same actions as first performing first and then second. Hence, the following lines of code are equivalent (ignoring numerical imprecions):

    y = transform(x, concatenate(first, second));
  y = transform(transform(x, first), second);

Definition at line 262 of file transformation_2d.inl.

References lass::prim::Transformation2D< T >::matrix(), and lass::stde::T.

template<typename T >
Vector2D< T > transform ( const Vector2D< T > &  subject,
const Transformation2D< T > &  transformation 
) [related]

template<typename T >
Point2D< T > transform ( const Point2D< T > &  subject,
const Transformation2D< T > &  transformation 
) [related]

template<typename T >
Vector2D< T > normalTransform ( const Vector2D< T > &  subject,
const Transformation2D< T > &  transformation 
) [related]

apply transformation to a normal vector.

Vectors that represent a normal vector should transform differentely than ordinary vectors. Use this transformation function for normals.

Definition at line 319 of file transformation_2d.inl.

References lass::prim::Transformation2D< T >::inverse(), lass::stde::T, lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.

template<typename T >
std::pair< Vector2D< T >, T > normalTransform ( const std::pair< Vector2D< T >, T > &  subject,
const Transformation2D< T > &  transformation 
) [related]

apply transformation to a 3D normal vector.

Vectors that represent a normal vector should transform differentely than ordinary vectors. Use this transformation function for normals.

Cartesian lines have a 3D normal vector that must be transformed in 2D. Use this function to do it:

  // ax + by + c == 0
    normalTransform(std::make_pair(Vector2D<float>(a, b), c), transformation);

Definition at line 343 of file transformation_2d.inl.

References lass::prim::Transformation2D< T >::inverse(), lass::stde::T, lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.

template<typename T , typename Char , typename Traits >
std::basic_ostream< Char, Traits > & operator<< ( std::basic_ostream< Char, Traits > &  stream,
const Transformation2D< T > &  transformation 
) [related]

Definition at line 361 of file transformation_2d.inl.

References LASS_ENFORCE_STREAM, and lass::stde::T.

template<typename T >
io::XmlOStream & operator<< ( io::XmlOStream stream,
const Transformation2D< T > &  transformation 
) [related]

Definition at line 377 of file transformation_2d.inl.

References LASS_ENFORCE_STREAM, and lass::stde::T.


Field Documentation

template<typename T >
TMatrix lass::prim::Transformation2D< T >::matrix_ [private]

template<typename T >
TMatrix lass::prim::Transformation2D< T >::inverseMatrix_ [mutable, private]

template<typename T >
TMatrix lass::prim::Transformation2D< T >::identityMatrix_ [static, private]

Definition at line 130 of file transformation_2d.h.

template<typename T >
util::Semaphore lass::prim::Transformation2D< T >::sync_ [inline, static, private]

Definition at line 132 of file transformation_2d.h.

Referenced by lass::prim::Transformation2D< T >::inverse().


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

Generated on Mon Nov 10 14:22:14 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo