geomc 1.0
A c++ linear algebra template library
Public Member Functions | Public Attributes | Friends | Related Functions | List of all members
AffineTransform< T, N > Class Template Reference

Affine transformation class. More...

#include <geomc/linalg/AffineTransform.h>

Public Member Functions

 AffineTransform ()
 Construct a new identity transform.
 
AffineTransform< T, N > & operator*= (const AffineTransform< T, N > &xf)
 
AffineTransform< T, N > & operator/= (const AffineTransform< T, N > &xf)
 
template<typename U >
 operator AffineTransform< U, N > () const
 Cast elements to a different type.
 
const Vec< T, N > apply (const Vec< T, N > &p) const
 
const Vec< T, N > apply_vector (const Vec< T, N > &v) const
 
const Vec< T, N > apply_normal (const Vec< T, N > &n) const
 
const Vec< T, N > apply_inverse (const Vec< T, N > &p) const
 
const Vec< T, N > apply_inverse_vector (const Vec< T, N > &v) const
 
const Vec< T, N > apply_inverse_normal (const Vec< T, N > &n) const
 
const AffineTransform< T, N > apply (const AffineTransform< T, N > &xf) const
 
const AffineTransform< T, N > apply_inverse (const AffineTransform< T, N > &xf) const
 
const AffineTransform< T, N > inverse () const
 

Public Attributes

SimpleMatrix< T, N+1, N+1 > mat
 Matrix representing this transformation.
 
SimpleMatrix< T, N+1, N+1 > inv
 Matrix representing the inverse of this transformation.
 

Friends

Ray< T, N > operator* (const AffineTransform< T, N > &xf, Ray< T, N > r)
 
Ray< T, N > operator/ (Ray< T, N > r, const AffineTransform< T, N > &xf)
 
Vec< T, N > operator* (const AffineTransform< T, N > &xf, Vec< T, N > p)
 
Vec< T, N > operator/ (Vec< T, N > p, const AffineTransform< T, N > &xf)
 
AffineTransform< T, N > operator* (const AffineTransform< T, N > &xf1, const AffineTransform< T, N > &xf2)
 
AffineTransform< T, N > operator/ (const AffineTransform< T, N > &xf1, const AffineTransform< T, N > &xf2)
 

Related Functions

(Note that these are not member functions.)

template<typename T >
AffineTransform< T, 3 > rotation (Vec< T, 3 > axis, T radians)
 
template<typename T >
AffineTransform< T, 3 > rotation (Vec< T, 3 > axis, const Vec< T, 3 > &center, T radians)
 
template<typename T >
AffineTransform< T, 3 > rotation (Quat< T > q)
 
template<typename T >
AffineTransform< T, 2 > rotation (T radians)
 
template<typename T >
AffineTransform< T, 3 > direction_align (const Vec< T, 3 > &dir, const Vec< T, 3 > &align_with)
 
template<typename T , index_t N>
AffineTransform< T, N > translation (const Vec< T, N > &tx)
 
template<typename T , index_t N>
AffineTransform< T, N > scale (const Vec< T, N > &sx)
 
template<typename T , index_t N, MatrixLayout Lyt, StoragePolicy P>
AffineTransform< T, N > transformation (const SimpleMatrix< T, N, N, Lyt, P > &mat)
 
template<typename T >
AffineTransform< T, 3 > scale (T sx, T sy, T sz)
 
template<typename T >
AffineTransform< T, 2 > scale (T sx, T sy)
 
template<typename T >
AffineTransform< T, 3 > translation (T tx, T ty, T tz)
 
template<typename T >
AffineTransform< T, 2 > translation (T tx, T ty)
 

Detailed Description

template<typename T, index_t N>
class geom::AffineTransform< T, N >

Affine transformation class.

Vectors are assumed to be columns; therefore a transformation is ordered like:

T * v

and so:

A * B * v

applies B to v, then A to the result.

The transform which "undoes" a transform can be obtained with xf.inverse(). Because an AffineTransform internally stores both itself and its inverse, this construction is fairly inexpensive, as are all inverse-application functions.

Construction

Transforms are best constructed using the provided methods:

Vec<double,3> v = ... ;
AffineTransform<double,3> xf = rotation(axis, angle);
xf *= translation(v);
xf *= scale(v);
xf *= transformation(mat3x3);

These methods will generally be most efficient and robust, especially when constructing the internal inverse transformation matrix needed by AffineTransform objects.

Member Function Documentation

◆ apply() [1/2]

const AffineTransform< T, N > apply ( const AffineTransform< T, N > &  xf) const
inline

Concatenation of transforms.

Returns
A transformation representing a transform by this followed by a transform by xf.

◆ apply() [2/2]

const Vec< T, N > apply ( const Vec< T, N > &  p) const
inline

Transformation of a point.

◆ apply_inverse() [1/2]

const AffineTransform< T, N > apply_inverse ( const AffineTransform< T, N > &  xf) const
inline

Application of inverse.

Returns
A transformation representing a transform by this followed by the inverse of xf.

◆ apply_inverse() [2/2]

const Vec< T, N > apply_inverse ( const Vec< T, N > &  p) const
inline

Inverse transformation of a point.

◆ apply_inverse_normal()

const Vec< T, N > apply_inverse_normal ( const Vec< T, N > &  n) const
inline

Inverse transformation of a normal.

◆ apply_inverse_vector()

const Vec< T, N > apply_inverse_vector ( const Vec< T, N > &  v) const
inline

Inverse transformation of a direction vector; ignores any translation.

◆ apply_normal()

const Vec< T, N > apply_normal ( const Vec< T, N > &  n) const
inline

Transformation of a normal. Preserves surface direction of geometry transformed by this.

◆ apply_vector()

const Vec< T, N > apply_vector ( const Vec< T, N > &  v) const
inline

Transformation of a direction vector; ignores any translation.

◆ inverse()

const AffineTransform< T, N > inverse ( ) const
inline
Returns
The inverse transform of this.

◆ operator*=()

AffineTransform< T, N > & operator*= ( const AffineTransform< T, N > &  xf)
inline

Concatenation of transforms.

Assign a transform representing an application of this followed by xf.

◆ operator/=()

AffineTransform< T, N > & operator/= ( const AffineTransform< T, N > &  xf)
inline

Apply inverse transform.

Assign a transform representing an application of this followed by the inverse of xf.

Friends And Related Function Documentation

◆ direction_align()

AffineTransform< T, 3 > direction_align ( const Vec< T, 3 > &  dir,
const Vec< T, 3 > &  align_with 
)
related

Rotation to align one vector with another.

Parameters
dirUnit direction to be realigned.
align_withUnit direction to align with.
Returns
A rotation transform aligning dir with align_with.

◆ operator* [1/3]

Ray< T, N > operator* ( const AffineTransform< T, N > &  xf,
Ray< T, N >  r 
)
friend

Transformation of a ray.

◆ operator* [2/3]

Vec< T, N > operator* ( const AffineTransform< T, N > &  xf,
Vec< T, N >  p 
)
friend

Transformation of a point.

◆ operator* [3/3]

AffineTransform< T, N > operator* ( const AffineTransform< T, N > &  xf1,
const AffineTransform< T, N > &  xf2 
)
friend

Concatenation of transforms.

Returns
A transformation representing an application of xf2 followed by xf1.

◆ operator/ [1/3]

AffineTransform< T, N > operator/ ( const AffineTransform< T, N > &  xf1,
const AffineTransform< T, N > &  xf2 
)
friend

Inverse transform application.

Returns
A transformation representing an application of xf1 followed by the inverse of xf2.

◆ operator/ [2/3]

Ray< T, N > operator/ ( Ray< T, N >  r,
const AffineTransform< T, N > &  xf 
)
friend

Inverse transformation of a ray (xf-1* ray)

◆ operator/ [3/3]

Vec< T, N > operator/ ( Vec< T, N >  p,
const AffineTransform< T, N > &  xf 
)
friend

Inverse transformation of a point (xf-1* pt)

◆ rotation() [1/4]

AffineTransform< T, 3 > rotation ( Quat< T >  q)
related

Rotation from a quaternion.

Parameters
qRotation quaternion.
Returns
A rotation transformation.

◆ rotation() [2/4]

AffineTransform< T, 2 > rotation ( radians)
related

2D rotation about the origin by angle radians.

Parameters
radiansAngle of rotation in the counterclockwise direction
Returns
A 2D rotation transformation.

◆ rotation() [3/4]

AffineTransform< T, 3 > rotation ( Vec< T, 3 >  axis,
const Vec< T, 3 > &  center,
radians 
)
related

Rotation about a point.

This transformation will not be a pure rotation; it will include a translation component.

Parameters
axisAxis of rotation.
centerCenter of rotation.
radiansAngle of rotation.
Returns
A transformation representing a rotation around the point center by angle radians and axis axis.

◆ rotation() [4/4]

AffineTransform< T, 3 > rotation ( Vec< T, 3 >  axis,
radians 
)
related

Rotation about an axis.

Parameters
axisAxis of rotation.
radiansAngle of rotation.
Returns
A transformation representing a rotation about axis by angle radians.

◆ scale() [1/3]

AffineTransform< T, N > scale ( const Vec< T, N > &  sx)
related

Scale transform.

Parameters
sxVector whose elements describe a scaling along each axis.
Returns
A transform representing a non-uniform scale along each axis.

◆ scale() [2/3]

AffineTransform< T, 2 > scale ( sx,
sy 
)
related

Per-axis 2D scale

◆ scale() [3/3]

AffineTransform< T, 3 > scale ( sx,
sy,
sz 
)
related

Per-axis 3D scale

◆ transformation()

AffineTransform< T, N > transformation ( const SimpleMatrix< T, N, N, Lyt, P > &  mat)
related

Arbitrary transformation.

Parameters
matN x N matrix representing an arbitrary transformation.
Returns
A transformation by mat

◆ translation() [1/3]

AffineTransform< T, N > translation ( const Vec< T, N > &  tx)
related

Translation transform

◆ translation() [2/3]

AffineTransform< T, 2 > translation ( tx,
ty 
)
related

2D translation

◆ translation() [3/3]

AffineTransform< T, 3 > translation ( tx,
ty,
tz 
)
related

3D translation


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