Library of Assembled Shared Sources
lass::prim::Transformation2D< T > Class Template Reference

a linear 2D transformation More...

#include <transformation_2d.h>

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

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 TValue * matrix () const
 Return pointer to row major matrix representation of transformation.
 

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
 

Related Symbols

(Note that these are not member symbols.)

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.
 

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.

Constructor & Destructor Documentation

◆ Transformation2D() [1/2]

template<typename T>
lass::prim::Transformation2D< T >::Transformation2D ( )

construct an identity transformation.

An identity transformation transforms every point to itself.

Definition at line 65 of file transformation_2d.inl.

Referenced by identity(), rotation(), scaler(), scaler(), and translation().

◆ Transformation2D() [2/2]

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

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 106 of file transformation_2d.inl.

Member Function Documentation

◆ inverse()

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

return the inverse transformation.

The inverse is calculated on the first call, and then cached for later use. For the transformation, we've use the C version of Cramer's rule as described in the Intel (R) article "Streaming SIMD Extensions -Inverse of 4x4 Matrix" which can be found here: http://www.intel.com/design/pentiumiii/sml/245043.htm

Definition at line 124 of file transformation_2d.inl.

References inv(), and lass::num::inv().

Referenced by lass::prim::Transformation2D< U >::normalTransform(), and lass::prim::Transformation2D< U >::normalTransform().

◆ matrix()

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 172 of file transformation_2d.inl.

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

Friends And Related Symbol Documentation

◆ concatenate()

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);
Transformation2D< T > concatenate(const Transformation2D< T > &first, const Transformation2D< T > &second)
concatenate two transformations first and second in one.
Vector2D< T > transform(const Vector2D< T > &subject, const Transformation2D< T > &transformation)
apply transformation to a vector

Definition at line 322 of file transformation_2d.inl.

◆ normalTransform() [1/2]

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 379 of file transformation_2d.inl.

◆ normalTransform() [2/2]

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);
Vector2D< T > normalTransform(const Vector2D< T > &subject, const Transformation2D< T > &transformation)
apply transformation to a normal vector.

Definition at line 403 of file transformation_2d.inl.


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