library of assembled shared sources |
http://lass.cocamware.com |
#include <transformation_2d.h>
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 TValue * | matrix () 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 TMatrix & | getIdentityMatrix () |
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::XmlOStream & | operator<< (io::XmlOStream &stream, const Transformation2D< T > &transformation) |
Definition at line 83 of file transformation_2d.h.
typedef Transformation2D<T> lass::prim::Transformation2D< T >::TSelf |
Definition at line 87 of file transformation_2d.h.
typedef util::CallTraits<T>::TValue lass::prim::Transformation2D< T >::TValue |
Definition at line 89 of file transformation_2d.h.
typedef util::CallTraits<T>::TParam lass::prim::Transformation2D< T >::TParam |
Definition at line 90 of file transformation_2d.h.
typedef util::CallTraits<T>::TReference lass::prim::Transformation2D< T >::TReference |
Definition at line 91 of file transformation_2d.h.
typedef util::CallTraits<T>::TConstReference lass::prim::Transformation2D< T >::TConstReference |
Definition at line 92 of file transformation_2d.h.
typedef num::NumTraits<T> lass::prim::Transformation2D< T >::TNumTraits |
Definition at line 93 of file transformation_2d.h.
typedef size_t lass::prim::Transformation2D< T >::TSize |
Definition at line 94 of file transformation_2d.h.
typedef util::SharedPtr<TValue, impl::Transformation2DStorage> lass::prim::Transformation2D< T >::TMatrix [private] |
Definition at line 121 of file transformation_2d.h.
anonymous enum |
anonymous enum [private] |
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.
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_.
lass::prim::Transformation2D< T >::Transformation2D | ( | const TMatrix & | matrix, | |
const TMatrix & | inverseMatrix, | |||
bool | dummy | |||
) | [inline, private] |
Definition at line 240 of file transformation_2d.inl.
const Transformation2D< T > lass::prim::Transformation2D< T >::inverse | ( | ) | const [inline] |
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 101 of file transformation_2d.inl.
References lass::util::SharedPtr< T, StoragePolicy, CounterPolicy >::get(), lass::num::inv(), lass::prim::Transformation2D< T >::inverseMatrix_, lass::util::SharedPtr< T, StoragePolicy, CounterPolicy >::isEmpty(), LASS_ASSERT, LASS_THROW_EX, lass::util::Semaphore::lock(), lass::prim::Transformation2D< T >::matrix_, lass::prim::Transformation2D< T >::matrixSize_, lass::util::SharedPtr< T, StoragePolicy, CounterPolicy >::reset(), lass::util::SharedPtr< T, StoragePolicy, CounterPolicy >::swap(), lass::prim::Transformation2D< T >::sync_, lass::util::Semaphore::unlock(), and lass::num::NumTraits< C >::zero.
Referenced by lass::prim::Transformation2D< T >::normalTransform().
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().
void lass::prim::Transformation2D< T >::swap | ( | TSelf & | other | ) | [inline] |
Definition at line 157 of file transformation_2d.inl.
References lass::prim::Transformation2D< T >::inverseMatrix_, lass::prim::Transformation2D< T >::matrix_, and lass::util::SharedPtr< T, StoragePolicy, CounterPolicy >::swap().
const Transformation2D< T > lass::prim::Transformation2D< T >::identity | ( | ) | [inline, static] |
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.
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_.
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.
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.
static const TMatrix& lass::prim::Transformation2D< T >::getIdentityMatrix | ( | ) | [static, private] |
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.
Vector2D< T > transform | ( | const Vector2D< T > & | subject, | |
const Transformation2D< T > & | transformation | |||
) | [related] |
apply transformation to a vector
Definition at line 287 of file transformation_2d.inl.
References lass::prim::Transformation2D< T >::matrix(), lass::stde::T, lass::prim::Vector2D< T >::x, and lass::prim::Vector2D< T >::y.
Point2D< T > transform | ( | const Point2D< T > & | subject, | |
const Transformation2D< T > & | transformation | |||
) | [related] |
apply transformation to a point
Definition at line 301 of file transformation_2d.inl.
References lass::num::inv(), lass::prim::Transformation2D< T >::matrix(), lass::stde::T, lass::prim::Point2D< T >::x, and lass::prim::Point2D< T >::y.
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.
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.
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.
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.
TMatrix lass::prim::Transformation2D< T >::matrix_ [private] |
Definition at line 127 of file transformation_2d.h.
Referenced by lass::prim::Transformation2D< T >::inverse(), lass::prim::Transformation2D< T >::matrix(), lass::prim::Transformation2D< T >::rotation(), lass::prim::Transformation2D< T >::scaler(), lass::prim::Transformation2D< T >::swap(), lass::prim::Transformation2D< T >::Transformation2D(), and lass::prim::Transformation2D< T >::translation().
TMatrix lass::prim::Transformation2D< T >::inverseMatrix_ [mutable, private] |
Definition at line 128 of file transformation_2d.h.
Referenced by lass::prim::Transformation2D< T >::inverse(), and lass::prim::Transformation2D< T >::swap().
TMatrix lass::prim::Transformation2D< T >::identityMatrix_ [static, private] |
Definition at line 130 of file transformation_2d.h.
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().
Generated on Mon Nov 10 14:22:14 2008 for Library of Assembled Shared Sources by 1.5.7.1 |