CGPdocs

affine

Affine transform made of a rotation, uniform and per-axis scalings, and a translation (no shear).

module 09_geometric_transformationsource: affine.hpp
T * p scales, rotates and then translates: affine_rt gives R p + t, affine_rts gives R s p + t, and affine gives R s S p + t, where S = diag(scaling_xyz) stretches the local axes of the shape before the rotation.
T * p scales, rotates and then translates: affine_rt gives R p + t, affine_rts gives R s p + t, and affine gives R s S p + t, where S = diag(scaling_xyz) stretches the local axes of the shape before the rotation. Tap to enlarge.

Fields and methods

Members of the struct affine. Most of what you do with a CGP type goes through the free functions listed below.

Fields

rotation_transform rotationRotation part of the transform, applied after the scalings.
vec3 translationTranslation part of the transform, applied last.
float scalingUniform scaling factor (default 1), combined with scaling_xyz before the rotation.
vec3 scaling_xyzScaling factors along the local x, y and z axes, applied before the rotation (default (1,1,1)).

Methods

affine()Builds the identity transform (identity rotation, zero translation, scaling 1, scaling_xyz (1,1,1)).4 overloads src
affine(affine_rt const& T)Builds the affine transform equal to a rigid transform, with unit scalings (implicit conversion). src
affine(affine_rts const& T)Builds the affine transform equal to a similarity, keeping its scaling and setting scaling_xyz to (1,1,1) (implicit conversion). src
affine(rotation_transform const& rotation, vec3 const& translation = vec3{0,0,0}, float scaling = 1.0f, vec3 const& scaling_xyz = vec3{1,1,1})Builds the transform p -> rotation*(scaling*scaling_xyz*p) + translation, with defaults zero translation, scaling 1 and scaling_xyz (1,1,1) (explicit). src
Returns the 4x4 matrix ((R diag(scaling*scaling_xyz), t), (0, 1)) of the transform. src
Returns the affine transform of a mat4 whose linear block is a rotation times a diagonal scaling, taking the column norms as scalings (in scaling if uniform, else in scaling_xyz, x negated for a reflection); a degenerate block keeps the identity rotation and unit scalings. src
Sets the uniform scaling factor and returns a reference to the transform. src
Sets the per-axis scaling factors and returns a reference to the transform. src
Sets the translation and returns a reference to the transform. src
Sets the rotation and returns a reference to the transform. src

Functions taking a affine

Convert 2

std::string str(affine const& T)

String listing the rotation, translation, scaling and scaling_xyz of the affine transform.

std::string type_str(affine const&)

Type name "affine".

Functions returning a affine

None.

Operators

Show the 11 operators (+, -, *, ==, ...)

operator*

6 overloads
vec3 operator*(affine const& T, vec3 const& p)
source

Apply the affine transform to a point: rotation * (scaling * scaling_xyz * p) + translation (scaling_xyz stretches the local axes).

vec4 operator*(affine const& T, vec4 const& p)
source

Apply the affine transform to a homogeneous vector, the translation being weighted by w: a direction (w=0) is not translated.

affine operator*(affine const& T1, affine_rts const& T2)
source

Composition T1 o T2 of an affine transform with a rotation-translation-scaling, returned as an affine; asserts that T1.scaling_xyz is uniform (use T1.matrix()*T2.matrix() otherwise).

affine operator*(affine const& T1, affine_rt const& T2)
source

Composition T1 o T2 of an affine transform with a rigid transform, returned as an affine; asserts that T1.scaling_xyz is uniform (use T1.matrix()*T2.matrix() otherwise).

mat4 operator*(affine const& T1, mat4 const& T2)
source

Product of the 4x4 matrix of the affine transform with a mat4.

mat4 operator*(affine const& T1, mat3 const& T2)
source

Product of the 4x4 matrix of the affine transform with a mat3 extended to a mat4.

std::ostream& operator<<(std::ostream& s, affine const& T)

Write str(T) of the affine transform to the stream.

Documented on another page

  • operator*Composition T1 o T2 of a rotation-translation-scaling (parent) with an affine transform (child), exact for any scaling_xyz.on affine_rts
  • operator*Composition T1 o T2 of a rigid transform (parent) with an affine transform (child), exact for any scaling_xyz.on affine_rt
  • operator*Product of a mat4 with the 4x4 matrix of the affine transform.on mat4
  • operator*Product of a mat3 extended to a mat4 with the 4x4 matrix of the affine transform.on mat3
CGP - Computer Graphics Programming.