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

A similarity transform, which is a rotation, scaling, and translation. More...

#include <geomc/linalg/Similarity.h>

Inheritance diagram for Similarity< 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

 Similarity (const Isometry< T, N > &s, T sx=1)
 
 Similarity (const Rotation< T, N > &rx)
 
 Similarity (const Vec< T, N > &tx)
 
 Similarity (T sx)
 
 Similarity (T sx, const Rotation< T, N > &rx)
 
 Similarity (T sx, const Rotation< T, N > &rx, const Vec< T, N > &tx)
 
Vec< T, Napply_direction (const Vec< T, N > &v) const
 Transform a direction vector.
 
Vec< T, Napply_inverse_direction (const Vec< T, N > &v) const
 Inverse-transform a direction vector.
 
Similarity< T, Ninverse () const
 Compute the inverse of the similarity.
 
 operator AffineTransform< T, N > () const
 Represent this similarity as an affine transform.
 
template<index_t M>
requires (M > N)
 operator Similarity< T, M > () const
 Extend the dimensionality of this similarity.
 
template<typename U, index_t M>
requires (M > N)
 operator Similarity< U, M > () const
 Extend the dimensionality of this similarity and change the coordinate type.
 
template<typename U>
 operator Similarity< U, N > () const
 Cast the underlying coordinate type.
 
Similarity< T, Noperator* (const Similarity< T, N > &other) const
 Compose two similarity transforms.
 
Vec< T, Noperator* (const Vec< T, N > &p) const
 Transform a point.
 
Similarity< T, N > & operator*= (const Similarity< T, N > &other)
 Compose in-place.
 
Similarity< T, Noperator+= (const Vec< T, N > &v)
 
Similarity< T, Noperator/ (const Similarity< T, N > &other) const
 Compose with the inverse of a similarity.
 
Similarity< T, N > & operator/= (const Similarity< T, N > &other)
 In-place apply inverse.
 
Similarity< T, Nscaled (T s) const
 

Public Attributes

Rotation< T, Nrx
 Rotation component.
 
sx = 1
 Scale component.
 
Vec< T, Ntx
 Translation component.
 

Static Public Attributes

static constexpr index_t N
 The dimension of this object.
 

Related Symbols

(Note that these are not member symbols.)

template<typename T, index_t N>
Capsule< T, Noperator* (const Similarity< T, N > &xf, const Capsule< T, N > &c)
 Transform a capsule by a similarity transform.
 
template<typename T, index_t N>
Cylinder< T, Noperator* (const Similarity< T, N > &xf, const Cylinder< T, N > &c)
 Transform a cylinder by a similarity transform.
 
template<typename T, index_t N, typename Shape>
Dilated< Shape > operator* (const Similarity< T, N > &xf, const Dilated< Shape > &s)
 Transform a dilated shape by a similarity transform.
 
template<typename T, index_t N>
Simplex< T, Noperator* (const Similarity< T, N > &xf, const Simplex< T, N > &s)
 Transform a simplex by a similarity transform.
 
template<typename T, index_t N>
Sphere< T, Noperator* (const Similarity< T, N > &xf, const Sphere< T, N > &s)
 Transform a sphere by a similarity transform.
 
template<typename T, index_t N>
Similarity< T, Noperator+ (const Similarity< T, N > &i, const Vec< T, N > &v)
 Apply a translation to a similarity.
 
template<typename T, index_t N>
Similarity< T, Noperator+ (const Vec< T, N > &v, const Similarity< T, N > &i)
 Apply a translation to a similarity.
 
template<typename T, index_t N>
Capsule< T, Noperator/ (const Capsule< T, N > &c, const Similarity< T, N > &xf)
 Inverse-transform a capsule by a similarity transform.
 
template<typename T, index_t N>
Cylinder< T, Noperator/ (const Cylinder< T, N > &c, const Similarity< T, N > &xf)
 Inverse-transform a cylinder by a similarity transform.
 
template<typename T, index_t N, typename Shape>
Dilated< Shape > operator/ (const Dilated< Shape > &s, const Similarity< T, N > &xf)
 Inverse-transform a dilated shape by a similarity transform.
 
template<typename T, index_t N>
Simplex< T, Noperator/ (const Simplex< T, N > &s, const Similarity< T, N > &xf)
 Inverse-transform a simplex by a similarity transform.
 
template<typename T, index_t N>
Sphere< T, Noperator/ (const Sphere< T, N > &s, const Similarity< T, N > &xf)
 Inverse-transform a sphere by a similarity transform.
 
template<typename T, index_t N>
Vec< T, Noperator/ (const Vec< T, N > &v, const Similarity< T, N > &i)
 Transform a point.
 

Detailed Description

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

A similarity transform, which is a rotation, scaling, and translation.

Similar transforms do not have any skew or nonuniform scales; they preserve shapes, angles, and relative distances.

Similarities meet the Transform concept. For transforms which do not include a scaling, see Isometry. For nonuniform scaling or skew transforms, see AffineTransform.

Similarity transforms compose like transforms, with multiplication on the left:

Similarity<T,N> s1, s2;
Similarity<T,N> s3 = s2 * s1; // similarity which applies s1, then s2
Vec<T,N> v = s3 * s1 * v0;    // apply s1 to v0, then s3 to the result
Sphere<T,N> s = s1 * sphere;  // apply s1 to a sphere

Similarity transforms can be inverted with the / operator:

Similarity<T,N> s1, s2;
Similarity<T,N> s3 = s2 / s1; // similarity which takes s1 to s2
Vec<T,N> v = v0 / s3;         // apply the inverse of s3 to v0

Compose with rotations and translations:

Similarity<T,3> s;
Rotation<T,3> r;
Similarity<T,3> s2 = r * s; // s2 is s with r applied
Similarity<T,3> s3 = s + Vec<T,3>(1,2,3); // s3 is s translated by (1,2,3)

Scaling is done explicitly with .scaled() or the .sx member:

Similarity<T,3> s;
Similarity<T,3> s2 = s.scaled(2); // s2 is s with double the scale
Similarity<T,3> s3 = s * 2; // s3 is s with double the scale

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.


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