Calamity Engine 1.0.0
A cross-platform 2D game engine written in C++ and SDL3.
Loading...
Searching...
No Matches
Transform Struct Reference

#include <definitions.hpp>

Public Member Functions

void rotate (float angle)
 
void rotateRadians (float radians)
 
void setScale (Vector2 scale)
 
void scale (Vector2 scale)
 
void setAngle (float angle)
 
void setAngleRadians (float radians)
 
Vector2 applyTo (const Vector2 &point) const
 
Transform applyTo (const Transform &other) const
 
Transform inverse () const
 
float getAngle () const
 
float getAngleRadians () const
 
float getDegrees () const
 
Vector2 getScale () const
 
void lookAt (const Vector2 &point)
 
template<class Archive >
void serialize (Archive &ar)
 

Static Public Member Functions

static float degToRad (float degrees)
 
static float radToDeg (float radians)
 

Public Attributes

Vector2 position = {0, 0}
 
Matrix2 transformation = {{{1, 0}, {0, 1}}}
 

Detailed Description

Transform struct

This is the struct that represents the position, rotation and scale of a node among other things. The position is stored as a Vector2, and the rotation and scale are stored in a transformation matrix.

There are a lot of operations you can do to a Transform:

Transform myTransform;
myTransform.position = Vector2{0.0f, 0.0f};
myTransform.setScale(Vector2{3.0f, 3.0f}); // make it 3 times as big!
Logger::log("{}", myTransform.getAngleRadians()); // print out the angle of the Transform in radians!
myTransform.setAngleRadians(20.0f * (3.141592653f / 180.0f)) // set the angle to 20 degrees in radians
myTransform.rotate(-20.0f); // rotate it back 20 degrees, and now the rotation will be 0 degrees.
Definition definitions.hpp:259
Vector2 position
Definition definitions.hpp:260
void setScale(Vector2 scale)
Definition definitions.cpp:122
void setAngleRadians(float radians)
Definition definitions.cpp:158
float getAngleRadians() const
Definition definitions.cpp:142
void rotate(float angle)
Definition definitions.cpp:112
Definition definitions.hpp:77

Member Function Documentation

◆ applyTo() [1/2]

Transform Transform::applyTo ( const Transform other) const

◆ applyTo() [2/2]

Vector2 Transform::applyTo ( const Vector2 point) const

◆ degToRad()

float Transform::degToRad ( float  degrees)
static

◆ getAngle()

float Transform::getAngle ( ) const

◆ getAngleRadians()

float Transform::getAngleRadians ( ) const

◆ getDegrees()

float Transform::getDegrees ( ) const

◆ getScale()

Vector2 Transform::getScale ( ) const

◆ inverse()

Transform Transform::inverse ( ) const

◆ lookAt()

void Transform::lookAt ( const Vector2 point)

◆ radToDeg()

float Transform::radToDeg ( float  radians)
static

◆ rotate()

void Transform::rotate ( float  angle)

◆ rotateRadians()

void Transform::rotateRadians ( float  radians)

◆ scale()

void Transform::scale ( Vector2  scale)

◆ serialize()

template<class Archive >
void Transform::serialize ( Archive &  ar)
inline

◆ setAngle()

void Transform::setAngle ( float  angle)

◆ setAngleRadians()

void Transform::setAngleRadians ( float  radians)

◆ setScale()

void Transform::setScale ( Vector2  scale)

Member Data Documentation

◆ position

Vector2 Transform::position = {0, 0}

◆ transformation

Matrix2 Transform::transformation = {{{1, 0}, {0, 1}}}

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