Gamedev Framework (gf)  0.6.0
A C++11 framework for 2D games
Public Member Functions | Public Attributes | Related Functions | List of all members
gf::Transform Struct Reference

A simple transformation (rotation then translation) More...

#include <gf/Transform.h>

Public Member Functions

 Transform ()
 Default constructor. More...
 
 Transform (float angle, Vector2f offset)
 Constructor with a rotation and a translation. More...
 
 Transform (float angle)
 Constructor with a rotation. More...
 
 Transform (Vector2f offset)
 Constructor with a translation. More...
 
void setAngle (float angle)
 Set the rotation angle. More...
 
float getAngle () const
 Get the rotation angle. More...
 
void setOffset (Vector2f offset) noexcept
 Set the translation offset. More...
 
Vector2f getOffset () const noexcept
 Get the translation offset. More...
 

Public Attributes

Rotation rotation
 The rotation of the transformation. More...
 
Translation translation
 The translation of the transformation. More...
 

Related Functions

(Note that these are not member functions.)

constexpr Vector2f transform (const Transform &trans, Vector2f point)
 Apply a transformation to a 2D point. More...
 
constexpr Vector2f inverseTransform (const Transform &trans, Vector2f point)
 Apply an inverse transformation to a 2D point. More...
 

Detailed Description

A simple transformation (rotation then translation)

This class is meant for simple transformation as can be seen in physics. It is the composition of a rotation and a translation.

For more complex affine transformation, you can use gf::Matrix3f.

See also
gf::Matrix3f, gf::Rotation, gf::Translation

Constructor & Destructor Documentation

◆ Transform() [1/4]

gf::Transform::Transform ( )
inline

Default constructor.

The default transform is the identity.

◆ Transform() [2/4]

gf::Transform::Transform ( float  angle,
Vector2f  offset 
)
inline

Constructor with a rotation and a translation.

Parameters
angleThe rotation angle
offsetThe translation offset

◆ Transform() [3/4]

gf::Transform::Transform ( float  angle)
inline

Constructor with a rotation.

There is no translation.

Parameters
angleThe rotation angle

◆ Transform() [4/4]

gf::Transform::Transform ( Vector2f  offset)
inline

Constructor with a translation.

There is no rotation.

Parameters
offsetThe translation offset

Member Function Documentation

◆ getAngle()

float gf::Transform::getAngle ( ) const
inline

Get the rotation angle.

Returns
The rotation angle

◆ getOffset()

Vector2f gf::Transform::getOffset ( ) const
inlinenoexcept

Get the translation offset.

Returns
The translation offset

◆ setAngle()

void gf::Transform::setAngle ( float  angle)
inline

Set the rotation angle.

Parameters
angleThe rotation angle

◆ setOffset()

void gf::Transform::setOffset ( Vector2f  offset)
inlinenoexcept

Set the translation offset.

Parameters
offsetThe translation offset

Friends And Related Function Documentation

◆ inverseTransform()

constexpr Vector2f inverseTransform ( const Transform trans,
Vector2f  point 
)
related

Apply an inverse transformation to a 2D point.

Parameters
transThe transformation
pointThe point to transform
Returns
The transformed point

◆ transform()

constexpr Vector2f transform ( const Transform trans,
Vector2f  point 
)
related

Apply a transformation to a 2D point.

Parameters
transThe transformation
pointThe point to transform
Returns
The transformed point

Member Data Documentation

◆ rotation

Rotation gf::Transform::rotation

The rotation of the transformation.

◆ translation

Translation gf::Transform::translation

The translation of the transformation.