affine
Affine transform made of a rotation, uniform and per-axis scalings, and a translation (no shear).
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 rotation | Rotation part of the transform, applied after the scalings. |
vec3 translation | Translation part of the transform, applied last. |
float scaling | Uniform scaling factor (default 1), combined with scaling_xyz before the rotation. |
vec3 scaling_xyz | Scaling 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.
Functions returning a affine
None.
Operators
Show the 11 operators (+, -, *, ==, ...)
operator*
6 overloadsvec3 operator*(affine const& T, vec3 const& p)sourceApply 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)sourceApply 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)sourceComposition 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)sourceComposition 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)sourceProduct of the 4x4 matrix of the affine transform with a mat4.
mat4 operator*(affine const& T1, mat3 const& T2)sourceProduct 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.onaffine_rtsoperator*Composition T1 o T2 of a rigid transform (parent) with an affine transform (child), exact for any scaling_xyz.onaffine_rtoperator*Product of a mat4 with the 4x4 matrix of the affine transform.onmat4operator*Product of a mat3 extended to a mat4 with the 4x4 matrix of the affine transform.onmat3