21 #ifndef GF_TRANSFORM_H
22 #define GF_TRANSFORM_H
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
62 :
cos(std::cos(angle)),
sin(std::sin(angle))
73 cos = std::cos(angle);
74 sin = std::sin(angle);
83 return std::atan2(
sin,
cos);
98 rotation
.cos * point.x - rotation
.sin * point.y
,
99 rotation
.sin * point.x + rotation
.cos * point.y
114 rotation
.cos * point.x + rotation
.sin * point.y
,
115 -rotation
.sin * point.x + rotation
.cos * point.y
331 Vector2f
transform(
const Matrix3f& mat, Vector2f point) {
332 return { mat.xx * point.x + mat.xy * point.y + mat.xz
, mat.yx * point.x + mat.yy * point.y + mat.yz
};
355 return Matrix3f
(1.0f
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, 0.0f
, 0.0f
, 0.0f
, 1.0f
);
368 1.0f
, 0.0f
, offset.x
,
369 0.0f
, 1.0f
, offset.y
,
392 float cos = std::cos(angle);
393 float sin = std::sin(angle);
411 float cos = std::cos(angle);
412 float sin = std::sin(angle);
414 cos
, -sin
, center.x * (1 - cos) + center.y * sin
,
415 sin
, cos
, center.y * (1 - cos) - center.x * sin
,
437 GF_API void rotate(Matrix3f& mat,
float angle, Vector2f center);
449 factor.x
, 0.0f
, 0.0f
,
450 0.0f
, factor.y
, 0.0f
,
464 Matrix3f
scaling(Vector2f factor, Vector2f center) {
466 factor.x
, 0.0f
, center.x * (1.0f - factor.x)
,
467 0.0f
, factor.y
, center.y * (1.0f - factor.y)
,
489 GF_API void scale(Matrix3f& mat, Vector2f factor, Vector2f center);
491 #ifndef DOXYGEN_SHOULD_SKIP_THIS
constexpr Vector2f inverseTransform(const Translation &translation, Vector2f point)
Apply an inverse translation to a 2D point.
Definition: Transform.h:190
Rotation(float angle)
Constructor with an angle.
Definition: Transform.h:61
void scale(Matrix3f &mat, Vector2f factor)
Combine the current transform with a scaling.
void setOffset(Vector2f newOffset) noexcept
Set the translation offset.
Definition: Transform.h:154
constexpr Vector2f transform(const Matrix3f &mat, Vector2f point)
Apply an affine transformation to a 2D point.
Definition: Transform.h:331
Vector2f offset
The offset of the translation.
Definition: Transform.h:125
float getAngle() const
Get the rotation angle.
Definition: Transform.h:82
Matrix3f rotation(float angle, Vector2f center)
Get a rotation matrix.
Definition: Transform.h:410
Matrix3f scaling(Vector2f factor)
Get a scaling matrix.
Definition: Transform.h:447
constexpr Vector(T x, T y)
Constructor that takes 2 components.
Definition: Vector.h:348
constexpr Vector2f transform(const Rotation &rotation, Vector2f point)
Apply a rotation to a 2D point.
Definition: Transform.h:96
float sin
The sine of the rotation angle.
Definition: Transform.h:43
A translation.
Definition: Transform.h:124
Matrix3f scaling(Vector2f factor, Vector2f center)
Get a scaling matrix.
Definition: Transform.h:464
constexpr Vector2f transform(const Translation &translation, Vector2f point)
Apply a translation to a 2D point.
Definition: Transform.h:177
Translation()
Default constructor.
Definition: Transform.h:132
void scale(Matrix3f &mat, Vector2f factor, Vector2f center)
Combine the current transform with a scaling.
Vector2f getOffset() const noexcept
Get the translation offset.
Definition: Transform.h:163
Translation(Vector2f translationOffset)
Constructor with an offset.
Definition: Transform.h:143
The namespace for gf classes.
Definition: Action.h:34
Matrix3f rotation(float angle)
Get a rotation matrix.
Definition: Transform.h:391
void rotate(Matrix3f &mat, float angle)
Combine the current transform with a rotation.
Matrix3f translation(Vector2f offset)
Get a translation matrix.
Definition: Transform.h:366
void translate(Matrix3f &mat, Vector2f offset)
Combine the current transform with a translation.
Vector(const Vector &other)=default
Default copy constructor.
RectF transform(const Matrix3f &mat, const RectF &rect)
Apply an affine transformaton to a rectangle.
constexpr Matrix(T xx, T xy, T xz, T yx, T yy, T yz, T zx, T zy, T zz)
Constructor that takes all the elements.
Definition: Matrix.h:219
constexpr Vector2f inverseTransform(const Rotation &rotation, Vector2f point)
Apply an inverse rotation to a 2D point.
Definition: Transform.h:112
void setAngle(float angle)
Set the rotation angle.
Definition: Transform.h:72
A rotation.
Definition: Transform.h:41
void rotate(Matrix3f &mat, float angle, Vector2f center)
Combine the current transform with a rotation.
Rotation()
Default constructor.
Definition: Transform.h:50
#define GF_API
Definition: Portability.h:35
constexpr Matrix3f identityTransform()
Identity transform.
Definition: Transform.h:354
float cos
The cosine of the rotation angle.
Definition: Transform.h:42