geomc 1.0
A c++ linear algebra template library
Loading...
Searching...
No Matches
AffineTransform< T, N > Class Template Reference

Affine transformation class. More...

#include <geomc/linalg/AffineTransform.h>

Inheritance diagram for AffineTransform< T, N >:
Dimensional< T, N >

Public Types

using elem_t
 The coordinate type of this object.
 
using point_t
 The type of a point in this object's space.
 

Public Member Functions

 AffineTransform ()
 Construct a new identity transform.
 
const AffineTransform< T, Napply (const AffineTransform< T, N > &xf) const
 Concatenation of transforms.
 
const VecType< T, Napply (const VecType< T, N > &p) const
 Transformation of a point.
 
const VecType< T, Napply_direction (const VecType< T, N > &v) const
 Transformation of a direction vector; ignores any translation.
 
const AffineTransform< T, Napply_inverse (const AffineTransform< T, N > &xf) const
 Application of inverse.
 
const VecType< T, Napply_inverse (const VecType< T, N > &p) const
 Inverse transformation of a point.
 
const VecType< T, Napply_inverse_direction (const VecType< T, N > &v) const
 Inverse transformation of a direction vector; ignores any translation.
 
const VecType< T, Napply_inverse_normal (const VecType< T, N > &n) const
 Inverse transformation of a normal.
 
const VecType< T, Napply_normal (const VecType< T, N > &n) const
 Transformation of a normal.
 
const SimpleMatrix< T, N, Ndirection_matrix () const
 Return the 3x3 matrix which transforms direction vectors.
 
const AffineTransform< T, Ninverse () const
 
template<typename U>
 operator AffineTransform< U, N > () const
 Cast elements to a different type.
 
AffineTransform< T, N > & operator*= (const AffineTransform< T, N > &xf)
 Concatenation of transforms.
 
AffineTransform< T, N > & operator/= (const AffineTransform< T, N > &xf)
 Apply inverse transform.
 
bool operator== (const AffineTransform< T, N > &xf) const
 Equality operator.
 
template<index_t M, typename U = T>
AffineTransform< U, M > resized () const
 

Public Attributes

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

Static Public Attributes

static constexpr index_t N
 The dimension of this object.
 

Friends

Ray< T, Noperator* (const AffineTransform< T, N > &xf, Ray< T, N > r)
 Transformation of a ray.
 
VecType< T, Noperator* (const AffineTransform< T, N > &xf, VecType< T, N > p)
 Transformation of a point.
 
AffineTransform< T, Noperator* (const AffineTransform< T, N > &xf1, const AffineTransform< T, N > &xf2)
 Concatenation of transforms.
 
AffineTransform< T, Noperator/ (const AffineTransform< T, N > &xf1, const AffineTransform< T, N > &xf2)
 Inverse transform application.
 
Ray< T, Noperator/ (Ray< T, N > r, const AffineTransform< T, N > &xf)
 Inverse transformation of a ray (xf-1* ray)
 
VecType< T, Noperator/ (VecType< T, N > p, const AffineTransform< T, N > &xf)
 Inverse transformation of a point (xf-1* pt)
 

Related Symbols

(Note that these are not member symbols.)

template<typename T>
AffineTransform< T, 3 > direction_align (const Vec< T, 3 > &dir, const Vec< T, 3 > &align_with)
 
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 > rotation (Vec< T, 3 > axis, const Vec< T, 3 > &center, T radians)
 
template<typename T>
AffineTransform< T, 3 > rotation (Vec< T, 3 > axis, T radians)
 
template<typename T, index_t N>
AffineTransform< T, Nscale (const Vec< T, N > &sx)
 
template<typename T>
AffineTransform< T, 2 > scale (T sx, T sy)
 
template<typename T>
AffineTransform< T, 3 > scale (T sx, T sy, T sz)
 
template<typename T, index_t N, MatrixLayout Lyt, StoragePolicy P>
AffineTransform< T, Ntransformation (const SimpleMatrix< T, N, N, Lyt, P > &mat)
 
template<typename T, index_t N>
AffineTransform< T, Ntranslation (const Vec< T, N > &tx)
 
template<typename T>
AffineTransform< T, 2 > translation (T tx, T ty)
 
template<typename T>
AffineTransform< T, 3 > translation (T tx, T ty, T tz)
 

Detailed Description

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

Affine transformation class.

AffineTransforms may represent any linear transformation, including rotations, translations, nonuniform scales, and shears. They are represented by an (N+1) x (N+1) matrix, where the last row is [0,0,...,1].

AffineTransforms meet the Transform concept. For transforms that preserve angles and relative distances, see Similarity. For transforms that preserve distance, see Isometry. For pure rotations, see Rotation.

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 Typedef Documentation

◆ point_t

using point_t
inherited

The type of a point in this object's space.

An N-vector of T if N > 1, otherwise a T.

Member Function Documentation

◆ apply()

template<typename T, index_t N>
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_inverse()

template<typename T, index_t N>
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_normal()

template<typename T, index_t N>
const VecType< T, N > apply_normal ( const VecType< T, N > & n) const
inline

Transformation of a normal.

Preserves surface direction of geometry transformed by this.

◆ inverse()

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

◆ operator*=()

template<typename T, index_t N>
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/=()

template<typename T, index_t N>
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 Symbol Documentation

◆ direction_align()

template<typename T>
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*

template<typename T, index_t N>
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/

template<typename T, index_t N>
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.

◆ rotation() [1/4]

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

Rotation from a quaternion.

Parameters
qRotation quaternion.
Returns
A rotation transformation.

◆ rotation() [2/4]

template<typename T>
AffineTransform< T, 2 > rotation ( T 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]

template<typename T>
AffineTransform< T, 3 > rotation ( Vec< T, 3 > axis,
const Vec< T, 3 > & center,
T 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]

template<typename T>
AffineTransform< T, 3 > rotation ( Vec< T, 3 > axis,
T 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]

template<typename T, index_t N>
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]

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

Per-axis 2D scale

◆ scale() [3/3]

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

Per-axis 3D scale

◆ transformation()

template<typename T, index_t N, MatrixLayout Lyt, StoragePolicy P>
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]

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

Translation transform

◆ translation() [2/3]

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

2D translation

◆ translation() [3/3]

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

3D translation


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