21 #ifndef GF_TRANSFORM_H
22 #define GF_TRANSFORM_H
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
47 Vector2f
transform(
const Matrix3f& mat, Vector2f point) {
48 Vector3f homogeneousPoint
{point
, 1.0f
};
49 Vector3f result = mat
* homogeneousPoint;
73 return Matrix3f
(1.0f
, 0.0f
, 0.0f
, 0.0f
, 1.0f
, 0.0f
, 0.0f
, 0.0f
, 1.0f
);
110 float cos = std::cos(angle);
111 float sin = std::sin(angle);
129 float cos = std::cos(angle);
130 float sin = std::sin(angle);
132 cos
, -sin
, center.x * (1 - cos) + center.y * sin
,
133 sin
, cos
, center.y * (1 - cos) - center.x * sin
,
155 GF_API void rotate(Matrix3f& mat,
float angle, Vector2f center);
167 factor.x
, 0.0f
, 0.0f
,
168 0.0f
, factor.y
, 0.0f
,
182 Matrix3f
scaling(Vector2f factor, Vector2f center) {
184 factor.x
, 0.0f
, center.x * (1.0f - factor.x)
,
185 0.0f
, factor.y
, center.y * (1.0f - factor.y)
,
207 GF_API void scale(Matrix3f& mat, Vector2f factor, Vector2f center);
209 #ifndef DOXYGEN_SHOULD_SKIP_THIS
Vector2f transform(const Matrix3f &mat, Vector2f point)
Apply an affine transformation to a 2D point.
Definition: Transform.h:47
void scale(Matrix3f &mat, Vector2f factor)
Combine the current transform with a scaling.
Matrix3f rotation(float angle, Vector2f center)
Get a rotation matrix.
Definition: Transform.h:128
Matrix3f scaling(Vector2f factor)
Get a scaling matrix.
Definition: Transform.h:165
Vector< T, S1 > operator*(const Matrix< T, S1, S2 > &lhs, const Vector< T, S2 > &rhs)
Matrix-vector multiplication.
Definition: Matrix.h:566
Matrix3f scaling(Vector2f factor, Vector2f center)
Get a scaling matrix.
Definition: Transform.h:182
void scale(Matrix3f &mat, Vector2f factor, Vector2f center)
Combine the current transform with a scaling.
Matrix3f rotation(float angle)
Get a rotation matrix.
Definition: Transform.h:109
void rotate(Matrix3f &mat, float angle)
Combine the current transform with a rotation.
Matrix3f translation(Vector2f offset)
Get a translation matrix.
Definition: Transform.h:84
void translate(Matrix3f &mat, Vector2f offset)
Combine the current transform with a translation.
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 Vector(Vector< T, 2 > xy, T z)
Constructor that takes a 2D vector and a z component.
Definition: Vector.h:605
void rotate(Matrix3f &mat, float angle, Vector2f center)
Combine the current transform with a rotation.
#define GF_API
Definition: Portability.h:35
constexpr Matrix3f identityTransform()
Identity transform.
Definition: Transform.h:72