LibGfx: Add Gfx::extract_2d_affine_transform(Matrix4x4) helper

This commit is contained in:
MacDue 2023-11-17 22:57:21 +00:00 committed by Alexander Kalenik
parent da00a5cdb5
commit 848b0d9c81
Notes: sideshowbarker 2024-07-17 06:28:38 +09:00

View file

@ -7,6 +7,7 @@
#pragma once
#include <AK/Math.h>
#include <LibGfx/AffineTransform.h>
#include <LibGfx/Matrix.h>
#include <LibGfx/Vector3.h>
#include <LibGfx/Vector4.h>
@ -76,6 +77,13 @@ constexpr static Matrix4x4<T> rotation_matrix(Vector3<T> const& axis, T angle)
0, 0, 0, 1);
}
template<typename T>
Gfx::AffineTransform extract_2d_affine_transform(Matrix4x4<T> const& matrix)
{
auto* m = matrix.elements();
return Gfx::AffineTransform(m[0][0], m[1][0], m[0][1], m[1][1], m[0][3], m[1][3]);
}
typedef Matrix4x4<float> FloatMatrix4x4;
typedef Matrix4x4<double> DoubleMatrix4x4;
}