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

a linear 3D transformation More...

#include <transformation_3d.h>

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

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

Static Public Member Functions

static const TSelf identity ()
 make a 3D identity transformation
 
static const TSelf translation (const TVector &offset)
 make a 3D transformation representing a translation
 
static const TSelf scaler (TParam scale)
 make a 3D transformation representing a uniform scaling
 
static const TSelf scaler (const TVector &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 TVector &axis, TParam radians)
 make a 3D transformation representing a rotation around an arbitrary axis
 

Related Symbols

(Note that these are not member symbols.)

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.
 

Detailed Description

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

a linear 3D transformation

Author
Bram de Greve [BdG]

Definition at line 108 of file transformation_3d.h.

Constructor & Destructor Documentation

◆ Transformation3D() [1/3]

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

construct an identity transformation.

An identity transformation transforms every point to itself.

Definition at line 62 of file transformation_3d.inl.

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

◆ Transformation3D() [2/3]

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

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));
Aabb2D< T, MMP > transform(const Aabb2D< T, MMP > &subject, const Transformation2D< T > &transformation)
apply transformation to axis aligned bounding box
Transformation3D()
construct an identity transformation.

Definition at line 82 of file transformation_3d.inl.

◆ Transformation3D() [3/3]

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

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 102 of file transformation_3d.inl.

Member Function Documentation

◆ inverse()

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

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

◆ matrix()

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 149 of file transformation_3d.inl.

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

◆ inverseMatrix()

template<typename T>
const Transformation3D< T >::TValue * lass::prim::Transformation3D< T >::inverseMatrix ( ) const
inline

Return pointer to row major matrix representation of inverse transformation.

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

Definition at line 162 of file transformation_3d.inl.

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

Friends And Related Symbol Documentation

◆ transform()

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.

◆ concatenate()

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);
Transformation3D< T > concatenate(const Transformation3D< T > &first, const Transformation3D< T > &second)
concatenate two transformations first and second in one.

Definition at line 555 of file transformation_3d.inl.

◆ normalTransform() [1/2]

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 615 of file transformation_3d.inl.

◆ normalTransform() [2/2]

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

Definition at line 640 of file transformation_3d.inl.


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