geomc 1.0
A c++ linear algebra template library
|
Affine transformation class. More...
#include <geomc/linalg/AffineTransform.h>
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, N > | apply (const AffineTransform< T, N > &xf) const |
Concatenation of transforms. | |
const VecType< T, N > | apply (const VecType< T, N > &p) const |
Transformation of a point. | |
const VecType< T, N > | apply_direction (const VecType< T, N > &v) const |
Transformation of a direction vector; ignores any translation. | |
const AffineTransform< T, N > | apply_inverse (const AffineTransform< T, N > &xf) const |
Application of inverse. | |
const VecType< T, N > | apply_inverse (const VecType< T, N > &p) const |
Inverse transformation of a point. | |
const VecType< T, N > | apply_inverse_direction (const VecType< T, N > &v) const |
Inverse transformation of a direction vector; ignores any translation. | |
const VecType< T, N > | apply_inverse_normal (const VecType< T, N > &n) const |
Inverse transformation of a normal. | |
const VecType< T, N > | apply_normal (const VecType< T, N > &n) const |
Transformation of a normal. | |
const SimpleMatrix< T, N, N > | direction_matrix () const |
Return the 3x3 matrix which transforms direction vectors. | |
const AffineTransform< T, N > | inverse () 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, N > | operator* (const AffineTransform< T, N > &xf, Ray< T, N > r) |
Transformation of a ray. | |
VecType< T, N > | operator* (const AffineTransform< T, N > &xf, VecType< T, N > p) |
Transformation of a point. | |
AffineTransform< T, N > | operator* (const AffineTransform< T, N > &xf1, const AffineTransform< T, N > &xf2) |
Concatenation of transforms. | |
AffineTransform< T, N > | operator/ (const AffineTransform< T, N > &xf1, const AffineTransform< T, N > &xf2) |
Inverse transform application. | |
Ray< T, N > | operator/ (Ray< T, N > r, const AffineTransform< T, N > &xf) |
Inverse transformation of a ray (xf -1 * ray ) | |
VecType< T, N > | operator/ (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 > ¢er, T radians) |
template<typename T> | |
AffineTransform< T, 3 > | rotation (Vec< T, 3 > axis, T radians) |
template<typename T, index_t N> | |
AffineTransform< T, N > | scale (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, N > | transformation (const SimpleMatrix< T, N, N, Lyt, P > &mat) |
template<typename T, index_t N> | |
AffineTransform< T, N > | translation (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) |
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.
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.
|
inherited |
The type of a point in this object's space.
An N-vector of T if N > 1, otherwise a T.
|
inline |
Concatenation of transforms.
this
followed by a transform by xf
.
|
inline |
Application of inverse.
this
followed by the inverse of xf
.
|
inline |
Transformation of a normal.
Preserves surface direction of geometry transformed by this
.
|
inline |
this
.
|
inline |
Concatenation of transforms.
Assign a transform representing an application of this
followed by xf
.
|
inline |
Apply inverse transform.
Assign a transform representing an application of this
followed by the inverse of xf
.
|
Rotation to align one vector with another.
dir | Unit direction to be realigned. |
align_with | Unit direction to align with. |
dir
with align_with
.
|
friend |
Concatenation of transforms.
xf2
followed by xf1
.
|
friend |
Inverse transform application.
xf1
followed by the inverse of xf2
.
|
|
2D rotation about the origin by angle radians
.
radians | Angle of rotation in the counterclockwise direction |
|
Rotation about a point.
This transformation will not be a pure rotation; it will include a translation component.
axis | Axis of rotation. |
center | Center of rotation. |
radians | Angle of rotation. |
center
by angle radians
and axis axis
.
|
Rotation about an axis.
axis | Axis of rotation. |
radians | Angle of rotation. |
axis
by angle radians
.
|
Scale transform.
sx | Vector whose elements describe a scaling along each axis. |
|
Per-axis 2D scale
|
Per-axis 3D scale
|
Arbitrary transformation.
mat | N x N matrix representing an arbitrary transformation. |
mat
|
Translation transform
|
2D translation
|
3D translation