Gamedev Framework (gf)  0.4.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

gf::Transform::Transform ( )
inline

Default constructor.

The default transform is the identity.

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

Constructor with a rotation and a translation.

Parameters
angleThe rotation angle
offsetThe translation offset
gf::Transform::Transform ( float  angle)
inline

Constructor with a rotation.

There is no translation.

Parameters
angleThe rotation angle
gf::Transform::Transform ( Vector2f  offset)
inline

Constructor with a translation.

There is no rotation.

Parameters
offsetThe translation offset

Member Function Documentation

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

Get the rotation angle.

Returns
The rotation angle
Vector2f gf::Transform::getOffset ( ) const
inlinenoexcept

Get the translation offset.

Returns
The translation offset
void gf::Transform::setAngle ( float  angle)
inline

Set the rotation angle.

Parameters
angleThe rotation angle
void gf::Transform::setOffset ( Vector2f  offset)
inlinenoexcept

Set the translation offset.

Parameters
offsetThe translation offset

Friends And Related Function Documentation

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
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 gf::Transform::rotation

The rotation of the transformation.

Translation gf::Transform::translation

The translation of the transformation.