library of assembled shared sources

http://lass.cocamware.com

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

a linear 3D transformation More...

#include <transformation_3d.h>

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

Collaboration graph
[legend]

Data Structures

struct  Rebind

Public Types

enum  { dimension = TPoint::dimension }
typedef Transformation3D< T > TSelf
typedef Point3D< T > TPoint
typedef TPoint::TVector TVector
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

 Transformation3D ()
 construct an identity transformation.
 Transformation3D (const TPoint &origin, const TVector &baseX, const TVector &baseY, const TVector &baseZ)
 construct an matrix from an origin and three base vectors
template<typename InputIterator >
 Transformation3D (InputIterator first, InputIterator last)
 construct a transformation from a 4x4 tranformation matrix.
const TSelf 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 3D identity transformation
static const TSelf translation (const Vector3D< T > &offset)
 make a 3D transformation representing a translation
static const TSelf scaler (const T &scale)
 make a 3D transformation representing a uniform scaling
static const TSelf scaler (const Vector3D< T > &scale)
 make a 3D transformation representing a scaling with different factors per axis
static const TSelf rotation (XYZ axis, TParam radians)
 make a 3D transformation representing a rotation around a primary axis
static const TSelf rotation (const Vector3D< T > &axis, TParam radians)
 make a 3D transformation representing a rotation around an arbitrary axis

Private Types

enum  { matrixSize_ = 16 }
typedef util::SharedPtr
< TValue,
impl::Transformation3DStorage
TMatrix

Private Member Functions

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

Static Private Member Functions

static T * allocate ()

Private Attributes

TMatrix matrix_
TMatrix inverseMatrix_

Static Private Attributes

static util::Semaphore sync_

Related Functions

(Note that these are not member functions.)

template<typename T , class MMP >
Aabb2D< T, MMP > transform (const Aabb2D< T, MMP > &subject, const Transformation2D< T > &transformation)
 apply transformation to axis aligned bounding box
template<typename T , class MMP >
Aabb3D< T, MMP > transform (const Aabb3D< T, MMP > &subject, const Transformation3D< T > &transformation)
 apply transformation to axis aligned bounding box
template<typename T >
ColorRGBA transform (const ColorRGBA &subject, const Transformation3D< T > &transformation)
 apply transformation to axis aligned bounding box
template<typename T , class NP >
Plane3D< T, Cartesian, NP > transform (const Plane3D< T, Cartesian, NP > &plane, const Transformation3D< T > &transformation)
 apply transformation to cartesian plane
template<typename T , class NP >
Plane3D< T, Parametric, NP > transform (const Plane3D< T, Parametric, NP > &plane, const Transformation3D< T > &transformation)
 apply transformation to parametric plane
template<typename T , class NP >
Plane3D< T, Combined, NP > transform (const Plane3D< T, Combined, NP > &plane, const Transformation3D< T > &transformation)
 apply transformation to combined plane
template<typename T , class NP , class PP >
Ray3D< T, NP, PP > transform (const Ray3D< T, NP, PP > &subject, const Transformation3D< T > &transformation)
 apply transformation to ray
template<typename T , class NP , class PP >
Ray3D< T, NP, PP > transform (const Ray3D< T, NP, PP > &subject, const Transformation3D< T > &transformation, T &tRay)
 apply transformation to ray, and rescale a parameter to represent same point
template<typename T >
Transformation3D< T > concatenate (const Transformation3D< T > &first, const Transformation3D< T > &second)
 concatenate two transformations first and second in one.
template<typename T >
Vector3D< T > transform (const Vector3D< T > &subject, const Transformation3D< T > &transformation)
 apply transformation to a vector
template<typename T >
Point3D< T > transform (const Point3D< T > &subject, const Transformation3D< T > &transformation)
 apply transformation to a point
template<typename T >
Vector3D< T > normalTransform (const Vector3D< T > &subject, const Transformation3D< T > &transformation)
 apply transformation to a normal vector.
template<typename T >
std::pair< Vector3D< T >, T > normalTransform (const std::pair< Vector3D< T >, T > &subject, const Transformation3D< T > &transformation)
 apply transformation to a 4D normal vector.
template<typename T , typename Char , typename Traits >
std::basic_ostream< Char,
Traits > & 
operator<< (std::basic_ostream< Char, Traits > &stream, const Transformation3D< T > &transformation)
template<typename T >
io::XmlOStreamoperator<< (io::XmlOStream &stream, const Transformation3D< T > &transformation)

Detailed Description

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

a linear 3D transformation

Author:
Bram de Greve [BdG]

Definition at line 83 of file transformation_3d.h.


Member Typedef Documentation

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

Definition at line 87 of file transformation_3d.h.

template<typename T >
typedef Point3D<T> lass::prim::Transformation3D< T >::TPoint

Definition at line 89 of file transformation_3d.h.

template<typename T >
typedef TPoint::TVector lass::prim::Transformation3D< T >::TVector

Definition at line 90 of file transformation_3d.h.

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

Definition at line 91 of file transformation_3d.h.

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

Definition at line 92 of file transformation_3d.h.

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

Definition at line 93 of file transformation_3d.h.

Definition at line 94 of file transformation_3d.h.

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

Definition at line 95 of file transformation_3d.h.

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

Definition at line 96 of file transformation_3d.h.

Definition at line 126 of file transformation_3d.h.


Member Enumeration Documentation

template<typename T >
anonymous enum

Enumerator:
dimension 

Definition at line 98 of file transformation_3d.h.

template<typename T >
anonymous enum [private]

Enumerator:
matrixSize_ 

Definition at line 124 of file transformation_3d.h.


Constructor & Destructor Documentation

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

construct an identity transformation.

An identity transformation transforms every point to itself.

Definition at line 65 of file transformation_3d.inl.

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

template<typename T >
lass::prim::Transformation3D< T >::Transformation3D ( const TPoint origin,
const TVector baseX,
const TVector baseY,
const TVector baseZ 
) [inline]

construct an matrix from an origin and three base vectors

    TVector3D<T> i, j, k;
    TPoint3D<T> o, p;
    // ...

    Transformation3D<T> transformation(o, i, j, k);
    LASS_ASSERT(transform(p, transformation) == (o + i * p.x + j * p.y + k * p.z));

Definition at line 101 of file transformation_3d.inl.

References lass::prim::Transformation3D< T >::matrix_, lass::num::NumTraits< C >::one, lass::prim::Point3D< T >::x, lass::prim::Vector3D< T >::x, lass::prim::Point3D< T >::y, lass::prim::Vector3D< T >::y, lass::prim::Point3D< T >::z, lass::prim::Vector3D< T >::z, and lass::num::NumTraits< C >::zero.

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

construct a transformation from a 4x4 tranformation matrix.

The elements of the 4x4 matrix will represented in a row major way by an iterator range [first, last) of 16 elements.

Definition at line 132 of file transformation_3d.inl.

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

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

Definition at line 365 of file transformation_3d.inl.


Member Function Documentation

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

template<typename T >
const Transformation3D< T >::TValue * lass::prim::Transformation3D< 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 244 of file transformation_3d.inl.

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

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

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

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

make a 3D identity transformation

Definition at line 263 of file transformation_3d.inl.

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

make a 3D transformation representing a translation

Definition at line 273 of file transformation_3d.inl.

References lass::prim::Transformation3D< T >::matrix_, lass::prim::Vector3D< T >::x, lass::prim::Vector3D< T >::y, and lass::prim::Vector3D< T >::z.

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

make a 3D transformation representing a uniform scaling

Definition at line 287 of file transformation_3d.inl.

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

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

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

Definition at line 301 of file transformation_3d.inl.

References lass::prim::Transformation3D< T >::matrix_, lass::prim::Vector3D< T >::x, lass::prim::Vector3D< T >::y, and lass::prim::Vector3D< T >::z.

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

make a 3D transformation representing a rotation around a primary axis

Definition at line 315 of file transformation_3d.inl.

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

template<typename T >
const Transformation3D< T > lass::prim::Transformation3D< T >::rotation ( const Vector3D< T > &  axis,
TParam  radians 
) [inline, static]

template<typename T >
static T* lass::prim::Transformation3D< T >::allocate (  )  [static, private]


Friends And Related Function Documentation

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

template<typename T , class MMP >
Aabb3D< T, MMP > transform ( const Aabb3D< T, MMP > &  subject,
const Transformation3D< T > &  transformation 
) [related]

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

template<typename T , class NP >
Plane3D< T, Cartesian, NP > transform ( const Plane3D< T, Cartesian, NP > &  plane,
const Transformation3D< T > &  transformation 
) [related]

template<typename T , class NP >
Plane3D< T, Parametric, NP > transform ( const Plane3D< T, Parametric, NP > &  plane,
const Transformation3D< T > &  transformation 
) [related]

template<typename T , class NP >
Plane3D< T, Combined, NP > transform ( const Plane3D< T, Combined, NP > &  plane,
const Transformation3D< T > &  transformation 
) [related]

template<typename T , class NP , class PP >
Ray3D< T, NP, PP > transform ( const Ray3D< T, NP, PP > &  subject,
const Transformation3D< T > &  transformation 
) [related]

template<typename T , class NP , class PP >
Ray3D< T, NP, PP > transform ( const Ray3D< T, NP, PP > &  subject,
const Transformation3D< T > &  transformation,
T &  tRay 
) [related]

apply transformation to ray, and rescale a parameter to represent same point

Parameters:
tRay 
  • INPUT & OUTPUT
  • if direction gets renormalized, then a point on ray is no longer represented by same parameter. Adjust parameter tRay to fix this.
  • If you fill in 1 as tRay, you can use the result to rescale multiple parameters by multiplying it.
  • transform(ray, transf).point(t') == transform(ray.point(t), transf)

Definition at line 111 of file ray_3d_transformation_3d.h.

References lass::prim::Ray3D< T, NormalizingPolicy, ParameterPolicy >::direction(), lass::prim::Ray3D< T, NormalizingPolicy, ParameterPolicy >::support(), and lass::prim::transform().

template<typename T >
Transformation3D< T > concatenate ( const Transformation3D< T > &  first,
const Transformation3D< 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 387 of file transformation_3d.inl.

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

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

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

template<typename T >
Vector3D< T > normalTransform ( const Vector3D< T > &  subject,
const Transformation3D< 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 447 of file transformation_3d.inl.

References lass::prim::Transformation3D< T >::inverse(), lass::prim::Transformation3D< T >::matrix(), lass::stde::T, lass::prim::Vector3D< T >::x, lass::prim::Vector3D< T >::y, and lass::prim::Vector3D< T >::z.

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

apply transformation to a 4D normal vector.

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

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

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

Definition at line 472 of file transformation_3d.inl.

References lass::prim::Transformation3D< T >::inverse(), lass::prim::Transformation3D< T >::matrix(), lass::stde::T, lass::prim::Vector3D< T >::x, lass::prim::Vector3D< T >::y, and lass::prim::Vector3D< T >::z.

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

Definition at line 492 of file transformation_3d.inl.

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

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

Definition at line 509 of file transformation_3d.inl.

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


Field Documentation

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

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

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

Definition at line 135 of file transformation_3d.h.

Referenced by lass::prim::Transformation3D< 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