Kale
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Kale::Transform Class Reference

#include <Transform.hpp>

+ Inheritance diagram for Kale::Transform:

Public Member Functions

 Transform ()
 
 Transform (const Matrix3f &matrix)
 
 Transform (Matrix3f &&matrix)
 
 Transform (const std::array< float, 9 > &arr)
 
 Transform (std::array< float, 9 > &&arr)
 
 Transform (const Vector2f &translation, float rotation, const Vector2f &scaleFactor, AngleUnit unit)
 
 Transform (float translateX, float translateY, float rotation, float scaleX, float scaleY, AngleUnit unit)
 
void setIdentity ()
 
void scale (const Vector2f &vec)
 
void scale (float x, float y)
 
void scale (float factor)
 
void scale (float factor, const Vector2f &origin)
 
void scale (float x, float y, const Vector2f &origin)
 
void translate (const Vector2f &vec)
 
void translate (float x, float y)
 
void rotate (float angle, AngleUnit unit)
 
void rotate (float angle, AngleUnit unit, const Vector2f &origin)
 
void setTranslation (float x, float y)
 
void setTranslation (const Vector2f &vec)
 
Vector2f getTranslation () const
 
void setRotation (float angle, AngleUnit unit)
 
float getRotation (AngleUnit unit) const
 
void setScale (float scaleX, float scaleY)
 
void setScale (float scale)
 
Vector2f getScale () const
 
Vector2f transform (const Vector2f &vec) const
 
void transformInplace (Vector2f &vec) const
 
Vector2f inverseTransform (const Vector2f &vec) const
 
void inverseTransformInplace (Vector2f &vec) const
 
RotatedRect transform (const RotatedRect &rect) const
 
RotatedRect inverseTransform (const RotatedRect &rect) const
 
RotatedRect transform (const Rect &rect) const
 
RotatedRect inverseTransform (const Rect &rect) const
 
Ray transform (const Ray &ray) const
 
Ray inverseTransform (const Ray &ray) const
 
Line transform (const Line &line) const
 
Line inverseTransform (const Line &line) const
 
Circle transform (const Circle &circle) const
 
Circle inverseTransform (const Circle &circle) const
 
template<typename T >
std::enable_if< std::is_base_of< Geometry, T >::value, bool >::type isInView (const T &geometry, const Rect &sceneBounds)
 
- Public Member Functions inherited from Kale::Matrix< w, h, T >
 Matrix ()
 
 Matrix (const std::array< T, w *h > &arr)
 
 Matrix (std::array< T, w *h > &&arr)
 
size_t width () const
 
size_t height () const
 
Toperator[] (size_t i)
 
const Toperator[] (size_t i) const
 
Toperator() (size_t col, size_t row)
 
const Toperator() (size_t col, size_t row) const
 
Tget (size_t i)
 
const Tget (size_t i) const
 
Tget (size_t col, size_t row)
 
const Tget (size_t col, size_t row) const
 
Matrix< w, h, Toperator+ (const Matrix< w, h, T > &other) const
 
Matrix< w, h, Toperator+ (Matrix< w, h, T > &&other) const
 
void operator+= (const Matrix< w, h, T > &other)
 
Matrix< w, h, Toperator- (const Matrix< w, h, T > &other) const
 
Matrix< w, h, Toperator- (Matrix< w, h, T > &&other) const
 
void operator-= (const Matrix< w, h, T > &other)
 
Matrix< w, h, Toperator* (T scalar) const
 
void operator*= (T scalar)
 
template<size_t w2>
Matrix< w2, h, Toperator* (const Matrix< w2, w, T > &other) const
 
Matrix< h, w, Ttranspose () const
 
void swapRows (size_t row1, size_t row2)
 
void scaleRow (size_t row, T scalar)
 
void addScaledRow (size_t row1, size_t row2, T scalar)
 
template<size_t W = w, size_t H = h>
std::enable_if< W==2 &&H==2, Vector2< T > >::type operator* (const Vector2< T > &vec) const
 
template<size_t W = w, size_t H = h>
std::enable_if< W==2 &&H==2, Vector2< T > >::type operator* (Vector2< T > &&vec) const
 
template<size_t W = w, size_t H = h>
std::enable_if< W==3 &&H==3, Vector3< T > >::type operator* (const Vector3< T > &vec) const
 
template<size_t W = w, size_t H = h>
std::enable_if< W==3 &&H==3, Vector3< T > >::type operator* (Vector3< T > &&vec) const
 
template<size_t W = w, size_t H = h>
std::enable_if< W==4 &&H==4, Vector4< T > >::type operator* (const Vector4< T > &vec) const
 
template<size_t W = w, size_t H = h>
std::enable_if< W==4 &&H==4, Vector4< T > >::type operator* (Vector4< T > &&vec) const
 
template<typename R , size_t W = w, size_t H = h>
std::enable_if< W==2 &&H==2, R >::type det () const
 
template<typename R , size_t W = w, size_t H = h>
std::enable_if< W==3 &&H==3, R >::type det () const
 
template<typename R , size_t W = w, size_t H = h>
std::enable_if< W==H &&(W >3)&&std::is_signed< R >::value, R >::type det () const
 
template<size_t W = w, size_t H = h>
std::enable_if< W==2 &&H==2, Matrix< W, H, T > >::type inverse ()
 
template<size_t W = w, size_t H = h>
std::enable_if< W==3 &&H==3, Matrix< W, H, T > >::type inverse ()
 

Additional Inherited Members

- Public Attributes inherited from Kale::Matrix< w, h, T >
std::array< T, w *h > data
 

Detailed Description

Represents a single transformation matrix.

Definition at line 42 of file Transform.hpp.

Constructor & Destructor Documentation

◆ Transform() [1/7]

Transform::Transform ( )

Creates a transformation matrix with the identity matrix

Definition at line 28 of file Transform.cpp.

◆ Transform() [2/7]

Transform::Transform ( const Matrix3f & matrix)

Creates a transformation matrix from a matrix

Parameters
matrixThe matrix

Definition at line 40 of file Transform.cpp.

◆ Transform() [3/7]

Transform::Transform ( Matrix3f && matrix)

Creates a transformation matrix from a matrix

Parameters
matrixThe matrix

Definition at line 48 of file Transform.cpp.

◆ Transform() [4/7]

Transform::Transform ( const std::array< float, 9 > & arr)

Creates a transformation matrix given an array

Parameters
arrThe array

Definition at line 56 of file Transform.cpp.

◆ Transform() [5/7]

Transform::Transform ( std::array< float, 9 > && arr)

Creates a transformation matrix given an array

Parameters
arrThe array

Definition at line 64 of file Transform.cpp.

◆ Transform() [6/7]

Transform::Transform ( const Vector2f & translation,
float rotation,
const Vector2f & scaleFactor,
AngleUnit unit )

Creates a transformation matrix given the translation, rotation, and scale

Parameters
translationThe translation of the matrix
rotationThe rotation of the matrix
scaleFactorThe scale factor of the matrix
unitThe unit of the rotation

Definition at line 75 of file Transform.cpp.

◆ Transform() [7/7]

Transform::Transform ( float translateX,
float translateY,
float rotation,
float scaleX,
float scaleY,
AngleUnit unit )

Creates a transformation matrix given the translation, rotation, and scale

Parameters
translateXThe x translation of the matrix
translateYThe y translation of the matrix
rotationThe rotation of the matrix
scaleXThe x scale factor of the matrix
scaleYThe x scale factor of the matrix
unitThe unit of the rotation

Definition at line 92 of file Transform.cpp.

Member Function Documentation

◆ getRotation()

float Transform::getRotation ( AngleUnit unit) const

Gets the rotation

Parameters
unitThe unit to return the rotation in
Returns
the rotation

Definition at line 271 of file Transform.cpp.

◆ getScale()

Vector2f Transform::getScale ( ) const

Gets the scale of the matrix

Returns
the scale of the matrix

Definition at line 302 of file Transform.cpp.

◆ getTranslation()

Vector2f Transform::getTranslation ( ) const

Gets the translation

Parameters
Thetranslation

Definition at line 246 of file Transform.cpp.

◆ inverseTransform() [1/6]

Circle Transform::inverseTransform ( const Circle & circle) const

Inverse transforms a circle using this transformation matrix (Returns a circle transformed by this matrix to its original)

Parameters
circleThe circle to transform
Returns
The transformed circle

Definition at line 480 of file Transform.cpp.

◆ inverseTransform() [2/6]

Line Transform::inverseTransform ( const Line & line) const

Inverse transforms a line using this transformation matrix (Returns a line transformed by this matrix to its original)

Parameters
lineThe line to transform
Returns
The transformed line

Definition at line 458 of file Transform.cpp.

◆ inverseTransform() [3/6]

Ray Transform::inverseTransform ( const Ray & ray) const

Inverse transforms a ray using this transformation matrix (Returns a ray transformed by this matrix to its original)

Parameters
rayThe ray to transform
Returns
The transformed ray

Definition at line 435 of file Transform.cpp.

◆ inverseTransform() [4/6]

RotatedRect Transform::inverseTransform ( const Rect & rect) const

Inverse transforms a rect using this transformation matrix (Returns a rect transformed by this matrix to its original)

Parameters
rectThe rect to transform
Returns
The transformed rect as a path

Inverse transforms a rect using this transformation matrix (Returns a rect transformed by this matrix to its original)

Parameters
rectThe rect to transform
Returns
The transformed rect

Definition at line 407 of file Transform.cpp.

◆ inverseTransform() [5/6]

RotatedRect Transform::inverseTransform ( const RotatedRect & rect) const

Inverse transforms a rect using this transformation matrix (Returns a rect transformed by this matrix to its original)

Parameters
rectThe rect to transform
Returns
The transformed rect as a path

Inverse transforms a rect using this transformation matrix (Returns a rect transformed by this matrix to its original)

Parameters
rectThe rect to transform
Returns
The transformed rect

Definition at line 378 of file Transform.cpp.

◆ inverseTransform() [6/6]

Vector2f Transform::inverseTransform ( const Vector2f & vec) const

Inverse transforms a vector using this transformation matrix (Returns a vector transformed by this matrix to its original)

Parameters
vecThe vector to transform
Returns
The transformed vector

Definition at line 333 of file Transform.cpp.

◆ inverseTransformInplace()

void Transform::inverseTransformInplace ( Vector2f & vec) const

Transforms a vector using this transformation matrix (Returns a vector transformed by this matrix to its original)

Parameters
vecThe vector to transform

Definition at line 352 of file Transform.cpp.

◆ isInView()

template<typename T >
std::enable_if< std::is_base_of< Geometry, T >::value, bool >::type Kale::Transform::isInView ( const T & geometry,
const Rect & sceneBounds )
inline

Checks whether or not a geometry is within the view of this camera/transform

Parameters
geometryThe geometry to check for
sceneBoundsThe bounds of the scene
Returns
Whether or not the geometry is within the view

Definition at line 323 of file Transform.hpp.

◆ rotate() [1/2]

void Transform::rotate ( float angle,
AngleUnit unit )

Rotates the transformation matrix

Parameters
angleThe angle to rotate by
unitThe unit of the angle

Definition at line 201 of file Transform.cpp.

◆ rotate() [2/2]

void Transform::rotate ( float angle,
AngleUnit unit,
const Vector2f & origin )

Rotates the transformation matrix about an origin

Parameters
angleThe angle to rotate by
unitThe unit of the angle
originThe origin to rotate about

Definition at line 217 of file Transform.cpp.

◆ scale() [1/5]

void Transform::scale ( const Vector2f & vec)

Scales the transformation matrix

Parameters
vecThe vector to scale by

Definition at line 115 of file Transform.cpp.

◆ scale() [2/5]

void Transform::scale ( float factor)

Scales the transformation matrix

Parameters
factorThe scale factor

Definition at line 140 of file Transform.cpp.

◆ scale() [3/5]

void Transform::scale ( float factor,
const Vector2f & origin )

Scales the transformation matrix about an origin

Parameters
factorThe scale factor
originThe origin to scale from

Definition at line 153 of file Transform.cpp.

◆ scale() [4/5]

void Transform::scale ( float x,
float y )

Scales the transformation matrix

Parameters
xThe x scale factor
yThe y scale factor

Definition at line 128 of file Transform.cpp.

◆ scale() [5/5]

void Transform::scale ( float x,
float y,
const Vector2f & origin )

Scales the transformation matrix about an origin

Parameters
xThe x scale factor
yThe y scale factor
originThe origin to scale from

Definition at line 165 of file Transform.cpp.

◆ setIdentity()

void Transform::setIdentity ( )

Sets this matrix to the identity matrix

Definition at line 103 of file Transform.cpp.

◆ setRotation()

void Transform::setRotation ( float angle,
AngleUnit unit )

Sets the rotation of the matrix

Parameters
angleThe angle of the rotation
unitThe unit of the angle

Definition at line 255 of file Transform.cpp.

◆ setScale() [1/2]

void Transform::setScale ( float scale)

Sets the scale of the matrix

Parameters
scaleThe scale factor (applies for both horizontal/vertical scaling)

Definition at line 292 of file Transform.cpp.

◆ setScale() [2/2]

void Transform::setScale ( float scaleX,
float scaleY )

Sets the scale of the matrix

Parameters
scaleXThe x component
scaleYThe y component

Definition at line 282 of file Transform.cpp.

◆ setTranslation() [1/2]

void Transform::setTranslation ( const Vector2f & vec)

Sets the translation of the matrix

Parameters
vecThe translation

Definition at line 237 of file Transform.cpp.

◆ setTranslation() [2/2]

void Transform::setTranslation ( float x,
float y )

Sets the translation of the matrix

Parameters
xThe x component
yThe y component

Definition at line 228 of file Transform.cpp.

◆ transform() [1/6]

Circle Transform::transform ( const Circle & circle) const

Transforms a circle using this transformation matrix

Parameters
circleThe circle to transform
Returns
The transformed circle

Definition at line 467 of file Transform.cpp.

◆ transform() [2/6]

Line Transform::transform ( const Line & line) const

Transforms a line using this transformation matrix

Parameters
lineThe line to transform
Returns
The transformed line

Definition at line 448 of file Transform.cpp.

◆ transform() [3/6]

Ray Transform::transform ( const Ray & ray) const

Transforms a ray using this transformation matrix

Parameters
rayThe ray to transform
Returns
The transformed ray

Definition at line 421 of file Transform.cpp.

◆ transform() [4/6]

RotatedRect Transform::transform ( const Rect & rect) const

Transforms a rect using this transformation matrix

Parameters
rectThe rect to transform
Returns
The transformed rect as a path

Transforms a rect using this transformation matrix

Parameters
rectThe rect to transform
Returns
The transformed rect

Definition at line 392 of file Transform.cpp.

◆ transform() [5/6]

RotatedRect Transform::transform ( const RotatedRect & rect) const

Transforms a rect using this transformation matrix

Parameters
rectThe rect to transform
Returns
The transformed rect as a path

Transforms a rect using this transformation matrix

Parameters
rectThe rect to transform
Returns
The transformed rect

Definition at line 363 of file Transform.cpp.

◆ transform() [6/6]

Vector2f Transform::transform ( const Vector2f & vec) const

Transforms a vector using this transformation matrix

Parameters
vecThe vector to transform
Returns
The transformed vector

Definition at line 314 of file Transform.cpp.

◆ transformInplace()

void Transform::transformInplace ( Vector2f & vec) const

Transforms a vector using this transformation matrix

Parameters
vecThe vector to transform

Definition at line 322 of file Transform.cpp.

◆ translate() [1/2]

void Transform::translate ( const Vector2f & vec)

Translates the transformation matrix

Parameters
vecThe vector to translate by

Definition at line 175 of file Transform.cpp.

◆ translate() [2/2]

void Transform::translate ( float x,
float y )

Translates the transformation matrix

Parameters
xThe x displacement
yThe y displacement

Definition at line 188 of file Transform.cpp.


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