CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
Math::TAffineTransform< T > Struct Template Reference

An affine transformation matrix for use in drawing 2D graphics. More...

#include <CeresEngine/Math/Rect.hpp>

Public Member Functions

 TAffineTransform ()=default
 
 TAffineTransform (const TMatrix3< T > &raw)
 
TAffineTransform concatenating (const TAffineTransform &t) const
 Returns an affine transformation matrix constructed by combining two existing affine transforms.
 
TAffineTransform operator* (const TAffineTransform &rhs) const
 Returns an affine transformation matrix constructed by combining two existing affine transforms.
 
TAffineTransform rotatedBy (T angle) const
 Returns an affine transformation matrix constructed by rotating an existing affine transform.
 
TAffineTransform operator>> (T angle)
 Returns an affine transformation matrix constructed by rotating an existing affine transform.
 
TAffineTransform operator<< (T angle)
 Returns an affine transformation matrix constructed by rotating an existing affine transform.
 
TAffineTransform scaledBy (T sx, T sy) const
 Returns an affine transformation matrix constructed by scaling an existing affine transform.
 
TAffineTransform operator* (const TVector2< T > &point)
 Returns an affine transformation matrix constructed by scaling an existing affine transform.
 
TAffineTransform operator/ (const TVector2< T > &point)
 Returns an affine transformation matrix constructed by scaling an existing affine transform.
 
TAffineTransform operator* (const T &scale)
 Returns an affine transformation matrix constructed by scaling an existing affine transform.
 
TAffineTransform operator/ (const T &scale)
 Returns an affine transformation matrix constructed by scaling an existing affine transform.
 
TAffineTransform translatedBy (T x, T y) const
 Returns an affine transformation matrix constructed by translating an existing affine transform.
 
TAffineTransform operator+ (const TVector2< T > &point)
 Returns an affine transformation matrix constructed by translating an existing affine transform.
 
TAffineTransform operator- (const TVector2< T > &point)
 Returns an affine transformation matrix constructed by translating an existing affine transform.
 
TAffineTransform invert () const
 Returns an affine transformation matrix constructed by inverting an existing affine transform.
 
TPoint2< T > operator() (const TPoint2< T > &point) const
 Returns the point resulting from an affine transformation of an existing point.
 
TSize2< T > operator() (const TSize2< T > &size) const
 Returns the size resulting from an affine transformation of an existing size.
 
TRect2< T > operator() (TRect2< T > rect) const
 Applies an affine transform to a rectangle.
 

Static Public Member Functions

static TAffineTransform rotation (T angle)
 Returns an affine transformation matrix constructed by rotating an existing affine transform.
 
static TAffineTransform scaling (T sx, T sy)
 Returns an affine transformation matrix constructed by scaling an existing affine transform.
 
static TAffineTransform translation (T x, T y)
 Returns an affine transformation matrix constructed by translating an existing affine transform.
 

Public Attributes

TMatrix3< T > raw = glm::identity<TMatrix3<T>>()
 

Friends

bool operator== (const TAffineTransform &lhs, const TAffineTransform &rhs)
 
bool operator!= (const TAffineTransform &lhs, const TAffineTransform &rhs)
 

Detailed Description

template<typename T>
struct Math::TAffineTransform< T >

An affine transformation matrix for use in drawing 2D graphics.

An affine transformation matrix is used to rotate, scale, translate, or skew the objects you draw in a graphics context. The TAffineTransform type provides functions for creating, concatenating, and applying affine transformations.

Affine transforms are represented by a 3 by 3 matrix.

Constructor & Destructor Documentation

◆ TAffineTransform() [1/2]

template<typename T >
Math::TAffineTransform< T >::TAffineTransform ( )
default

◆ TAffineTransform() [2/2]

template<typename T >
Math::TAffineTransform< T >::TAffineTransform ( const TMatrix3< T > &  raw)
inline

Member Function Documentation

◆ concatenating()

template<typename T >
TAffineTransform Math::TAffineTransform< T >::concatenating ( const TAffineTransform< T > &  t) const
inline

Returns an affine transformation matrix constructed by combining two existing affine transforms.

Concatenation combines two affine transformation matrices by multiplying them together. You might perform several concatenations in order to create a single affine transform that contains the cumulative effects of several transformations.

Note that matrix operations are not commutative—the order in which you concatenate matrices is important. That is, the result of multiplying matrix t1 by matrix t2 does not necessarily equal the result of multiplying matrix t2 by matrix t1.

Parameters
tThe affine transform to concatenate to this affine transform.
Returns
A new affine transformation matrix. That is, t’ = t1*t2.

◆ invert()

template<typename T >
TAffineTransform Math::TAffineTransform< T >::invert ( ) const
inline

Returns an affine transformation matrix constructed by inverting an existing affine transform.

Inversion is generally used to provide reverse transformation of points within transformed objects. Given the coordinates (x,y), which have been transformed by a given matrix to new coordinates (x’,y’), transforming the coordinates (x’,y’) by the inverse matrix produces the original coordinates (x,y).

Returns
A new affine transformation matrix. If the affine transform passed in parameter t cannot be inverted, the affine transform is returned unchanged.

◆ operator()() [1/3]

template<typename T >
TPoint2< T > Math::TAffineTransform< T >::operator() ( const TPoint2< T > &  point) const
inline

Returns the point resulting from an affine transformation of an existing point.

Parameters
pointA point that specifies the x- and y-coordinates to transform.
Returns
A new point resulting from applying the specified affine transform to the existing point.

◆ operator()() [2/3]

template<typename T >
TSize2< T > Math::TAffineTransform< T >::operator() ( const TSize2< T > &  size) const
inline

Returns the size resulting from an affine transformation of an existing size.

Parameters
sizeA size that specifies the x- and y-dimensions to transform.
Returns
A new size resulting from applying the specified affine transform to the existing size.

◆ operator()() [3/3]

template<typename T >
TRect2< T > Math::TAffineTransform< T >::operator() ( TRect2< T >  rect) const
inline

Applies an affine transform to a rectangle.

Because affine transforms do not preserve rectangles in general, this function returns the smallest rectangle that contains the transformed corner points of the rect parameter. If the affine transform consists solely of scaling and translation operations, then the returned rectangle coincides with the rectangle constructed from the four transformed corners.

Parameters
rectThe rectangle whose corner points you want to transform.
Returns
The transformed rectangle.

◆ operator*() [1/3]

template<typename T >
TAffineTransform Math::TAffineTransform< T >::operator* ( const T &  scale)
inline

Returns an affine transformation matrix constructed by scaling an existing affine transform.

You use this function to create a new affine transformation matrix by adding scaling values to an existing affine transform. The resulting structure represents a new affine transform, which you can use (and reuse, if you want) to scale a coordinate system.

Parameters
sxThe value by which to scale x values of the affine transform.
syThe value by which to scale y values of the affine transform.
Returns
A new affine transformation matrix.

◆ operator*() [2/3]

template<typename T >
TAffineTransform Math::TAffineTransform< T >::operator* ( const TAffineTransform< T > &  rhs) const
inline

Returns an affine transformation matrix constructed by combining two existing affine transforms.

Concatenation combines two affine transformation matrices by multiplying them together. You might perform several concatenations in order to create a single affine transform that contains the cumulative effects of several transformations.

Note that matrix operations are not commutative—the order in which you concatenate matrices is important. That is, the result of multiplying matrix t1 by matrix t2 does not necessarily equal the result of multiplying matrix t2 by matrix t1.

Parameters
tThe affine transform to concatenate to this affine transform.
Returns
A new affine transformation matrix. That is, t’ = t1*t2.

◆ operator*() [3/3]

template<typename T >
TAffineTransform Math::TAffineTransform< T >::operator* ( const TVector2< T > &  point)
inline

Returns an affine transformation matrix constructed by scaling an existing affine transform.

You use this function to create a new affine transformation matrix by adding scaling values to an existing affine transform. The resulting structure represents a new affine transform, which you can use (and reuse, if you want) to scale a coordinate system.

Parameters
sxThe value by which to scale x values of the affine transform.
syThe value by which to scale y values of the affine transform.
Returns
A new affine transformation matrix.

◆ operator+()

template<typename T >
TAffineTransform Math::TAffineTransform< T >::operator+ ( const TVector2< T > &  point)
inline

Returns an affine transformation matrix constructed by translating an existing affine transform.

You use this function to create a new affine transformation matrix by adding translation values to an existing affine transform. The resulting structure represents a new affine transform, which you can use (and reuse, if you want) to move a coordinate system.

Parameters
xThe value by which to move x values with the affine transform.
yThe value by which to move y values with the affine transform.
Returns
A new affine transformation matrix.

◆ operator-()

template<typename T >
TAffineTransform Math::TAffineTransform< T >::operator- ( const TVector2< T > &  point)
inline

Returns an affine transformation matrix constructed by translating an existing affine transform.

You use this function to create a new affine transformation matrix by adding translation values to an existing affine transform. The resulting structure represents a new affine transform, which you can use (and reuse, if you want) to move a coordinate system.

Parameters
xThe value by which to move x values with the affine transform.
yThe value by which to move y values with the affine transform.
Returns
A new affine transformation matrix.

◆ operator/() [1/2]

template<typename T >
TAffineTransform Math::TAffineTransform< T >::operator/ ( const T &  scale)
inline

Returns an affine transformation matrix constructed by scaling an existing affine transform.

You use this function to create a new affine transformation matrix by adding scaling values to an existing affine transform. The resulting structure represents a new affine transform, which you can use (and reuse, if you want) to scale a coordinate system.

Parameters
sxThe value by which to scale x values of the affine transform.
syThe value by which to scale y values of the affine transform.
Returns
A new affine transformation matrix.

◆ operator/() [2/2]

template<typename T >
TAffineTransform Math::TAffineTransform< T >::operator/ ( const TVector2< T > &  point)
inline

Returns an affine transformation matrix constructed by scaling an existing affine transform.

You use this function to create a new affine transformation matrix by adding scaling values to an existing affine transform. The resulting structure represents a new affine transform, which you can use (and reuse, if you want) to scale a coordinate system.

Parameters
sxThe value by which to scale x values of the affine transform.
syThe value by which to scale y values of the affine transform.
Returns
A new affine transformation matrix.

◆ operator<<()

template<typename T >
TAffineTransform Math::TAffineTransform< T >::operator<< ( angle)
inline

Returns an affine transformation matrix constructed by rotating an existing affine transform.

You use this function to create a new affine transformation matrix by adding a rotation value to an existing affine transform. The resulting structure represents a new affine transform, which you can use (and reuse, if you want) to rotate a coordinate system.

Parameters
angleThe angle, in radians, by which to rotate the affine transform. A positive value specifies clockwise rotation and a negative value specifies counterclockwise rotation.
Returns
A new affine transformation matrix.

◆ operator>>()

template<typename T >
TAffineTransform Math::TAffineTransform< T >::operator>> ( angle)
inline

Returns an affine transformation matrix constructed by rotating an existing affine transform.

You use this function to create a new affine transformation matrix by adding a rotation value to an existing affine transform. The resulting structure represents a new affine transform, which you can use (and reuse, if you want) to rotate a coordinate system.

Parameters
angleThe angle, in radians, by which to rotate the affine transform. A positive value specifies clockwise rotation and a negative value specifies counterclockwise rotation.
Returns
A new affine transformation matrix.

◆ rotatedBy()

template<typename T >
TAffineTransform Math::TAffineTransform< T >::rotatedBy ( angle) const
inline

Returns an affine transformation matrix constructed by rotating an existing affine transform.

You use this function to create a new affine transformation matrix by adding a rotation value to an existing affine transform. The resulting structure represents a new affine transform, which you can use (and reuse, if you want) to rotate a coordinate system.

Parameters
angleThe angle, in radians, by which to rotate the affine transform. A positive value specifies clockwise rotation and a negative value specifies counterclockwise rotation.
Returns
A new affine transformation matrix.

◆ rotation()

template<typename T >
static TAffineTransform Math::TAffineTransform< T >::rotation ( angle)
inlinestatic

Returns an affine transformation matrix constructed by rotating an existing affine transform.

You use this function to create a new affine transformation matrix by adding a rotation value to an existing affine transform. The resulting structure represents a new affine transform, which you can use (and reuse, if you want) to rotate a coordinate system.

Parameters
angleThe angle, in radians, by which to rotate the affine transform. A positive value specifies clockwise rotation and a negative value specifies counterclockwise rotation.
Returns
A new affine transformation matrix.

◆ scaledBy()

template<typename T >
TAffineTransform Math::TAffineTransform< T >::scaledBy ( sx,
sy 
) const
inline

Returns an affine transformation matrix constructed by scaling an existing affine transform.

You use this function to create a new affine transformation matrix by adding scaling values to an existing affine transform. The resulting structure represents a new affine transform, which you can use (and reuse, if you want) to scale a coordinate system.

Parameters
sxThe value by which to scale x values of the affine transform.
syThe value by which to scale y values of the affine transform.
Returns
A new affine transformation matrix.

◆ scaling()

template<typename T >
static TAffineTransform Math::TAffineTransform< T >::scaling ( sx,
sy 
)
inlinestatic

Returns an affine transformation matrix constructed by scaling an existing affine transform.

You use this function to create a new affine transformation matrix by adding scaling values to an existing affine transform. The resulting structure represents a new affine transform, which you can use (and reuse, if you want) to scale a coordinate system.

Parameters
sxThe value by which to scale x values of the affine transform.
syThe value by which to scale y values of the affine transform.
Returns
A new affine transformation matrix.

◆ translatedBy()

template<typename T >
TAffineTransform Math::TAffineTransform< T >::translatedBy ( x,
y 
) const
inline

Returns an affine transformation matrix constructed by translating an existing affine transform.

You use this function to create a new affine transformation matrix by adding translation values to an existing affine transform. The resulting structure represents a new affine transform, which you can use (and reuse, if you want) to move a coordinate system.

Parameters
xThe value by which to move x values with the affine transform.
yThe value by which to move y values with the affine transform.
Returns
A new affine transformation matrix.

◆ translation()

template<typename T >
static TAffineTransform Math::TAffineTransform< T >::translation ( x,
y 
)
inlinestatic

Returns an affine transformation matrix constructed by translating an existing affine transform.

You use this function to create a new affine transformation matrix by adding translation values to an existing affine transform. The resulting structure represents a new affine transform, which you can use (and reuse, if you want) to move a coordinate system.

Parameters
xThe value by which to move x values with the affine transform.
yThe value by which to move y values with the affine transform.
Returns
A new affine transformation matrix.

Friends And Related Symbol Documentation

◆ operator!=

template<typename T >
bool operator!= ( const TAffineTransform< T > &  lhs,
const TAffineTransform< T > &  rhs 
)
friend

◆ operator==

template<typename T >
bool operator== ( const TAffineTransform< T > &  lhs,
const TAffineTransform< T > &  rhs 
)
friend

Member Data Documentation

◆ raw

template<typename T >
TMatrix3<T> Math::TAffineTransform< T >::raw = glm::identity<TMatrix3<T>>()

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