File include/brisk/graphics/Matrix.hpp
¶
MatrixOf
class¶
template <typename T> MatrixOf
Represents a 2D matrix of floating point values.
This template class provides a 2D transformation matrix implementation with
support for translation, scaling, rotation, reflection, and skewing. It
works on any floating-point type (e.g., float, double).
Template param T
The type of floating-point values (e.g., float or double).
v
variable (MatrixOf::v
)¶
vec_type v
Array of SIMD vectors for efficient storage.
(anonymous)
class (MatrixOf::(anonymous struct at /src/include/brisk/graphics/Matrix.hpp:25:9)
)¶
(anonymous struct at / src / include / brisk / graphics /
Matrix.hpp : 25 : 9)
a
variable (MatrixOf::(anonymous struct at /src/include/brisk/graphics/Matrix.hpp:25:9)::a
)¶
T a
Individual matrix coefficients.
b
variable (MatrixOf::(anonymous struct at /src/include/brisk/graphics/Matrix.hpp:25:9)::b
)¶
T a, b
Individual matrix coefficients.
c
variable (MatrixOf::(anonymous struct at /src/include/brisk/graphics/Matrix.hpp:25:9)::c
)¶
T a, b, c
Individual matrix coefficients.
d
variable (MatrixOf::(anonymous struct at /src/include/brisk/graphics/Matrix.hpp:25:9)::d
)¶
T a, b, c, d
Individual matrix coefficients.
e
variable (MatrixOf::(anonymous struct at /src/include/brisk/graphics/Matrix.hpp:25:9)::e
)¶
T a, b, c, d, e
Individual matrix coefficients.
f
variable (MatrixOf::(anonymous struct at /src/include/brisk/graphics/Matrix.hpp:25:9)::f
)¶
T a, b, c, d, e, f
Individual matrix coefficients.
MatrixOf<T>
function (MatrixOf::MatrixOf<T>
)¶
constexpr MatrixOf() : MatrixOf(1, 0, 0, 1, 0, 0)
Constructs an identity matrix.
constexpr MatrixOf(T a, T b, T c, T d, T e, T f) : v
Constructs a matrix with specified coefficients.
Param a
Matrix coefficient at position (0,0).
Param b
Matrix coefficient at position (0,1).
Param c
Matrix coefficient at position (1,0).
Param d
Matrix coefficient at position (1,1).
Param e
Matrix translation component along the x-axis.
Param f
Matrix translation component along the y-axis.
coefficients
function (MatrixOf::coefficients
)¶
constexpr std::array<T, 6> coefficients() const
Returns the matrix coefficients as an array.
Returns std::array<T, 6> The array of coefficients {a, b, c, d, e, f}.
MatrixOf<T>
function (MatrixOf::MatrixOf<T>
)¶
constexpr explicit MatrixOf(const vec_type &v) : v(v)
Constructs a matrix from a given vector type.
Param v
The vector type representing the matrix.
translate
function (MatrixOf::translate
)¶
constexpr MatrixOf translate(PointOf<T> offset) const
Translates the matrix by a given point offset.
Param offset
The point by which to translate.
Returns MatrixOf The translated matrix.
constexpr MatrixOf translate(T x, T y) const
Translates the matrix by given x and y offsets.
Param x
The x-axis translation.
Param y
The y-axis translation.
Returns MatrixOf The translated matrix.
scale
function (MatrixOf::scale
)¶
constexpr MatrixOf scale(T x, T y) const
Scales the matrix by the given x and y scaling factors.
Param x
The x-axis scaling factor.
Param y
The y-axis scaling factor.
Returns MatrixOf The scaled matrix.
constexpr MatrixOf scale(T x, T y, PointOf<T> origin) const
Scales the matrix by the given x and y scaling factors with respect to an origin point.
Param x
The x-axis scaling factor.
Param y
The y-axis scaling factor.
Param origin
The origin point.
Returns MatrixOf The scaled matrix.
constexpr MatrixOf scale(T x, T y, T originx,
T originy) const
Scales the matrix by the given x and y scaling factors with respect to a specified origin.
Param x
The x-axis scaling factor.
Param y
The y-axis scaling factor.
Param originx
The x-coordinate of the origin.
Param originy
The y-coordinate of the origin.
Returns MatrixOf The scaled matrix.
skew
function (MatrixOf::skew
)¶
constexpr MatrixOf skew(T x, T y) const
Skews the matrix by the given x and y skewness coefficients.
Param x
The x-axis skew coefficient.
Param y
The y-axis skew coefficient.
Returns MatrixOf The skewed matrix.
constexpr MatrixOf skew(T x, T y, PointOf<T> origin) const
Skews the matrix by the given x and y skewness coefficients with respect to an origin point.
Param x
The x-axis skew coefficient.
Param y
The y-axis skew coefficient.
Param origin
The origin point.
Returns MatrixOf The skewed matrix.
constexpr MatrixOf skew(T x, T y, T originx,
T originy) const
Skews the matrix by the given x and y skewness coefficients with respect to a specified origin.
Param x
The x-axis skew coefficient.
Param y
The y-axis skew coefficient.
Param originx
The x-coordinate of the origin.
Param originy
The y-coordinate of the origin.
Returns MatrixOf The skewed matrix.
rotate
function (MatrixOf::rotate
)¶
constexpr MatrixOf rotate(T angle) const
Rotates the matrix by the given angle (in degrees).
Param angle
The angle in degrees.
Returns MatrixOf The rotated matrix.
constexpr MatrixOf rotate(T angle, PointOf<T> origin) const
Rotates the matrix by the given angle (in degrees) with respect to an origin point.
Param angle
The angle in degrees.
Param origin
The origin point for rotation.
Returns MatrixOf The rotated matrix.
constexpr MatrixOf rotate(T angle, T originx,
T originy) const
Rotates the matrix by the given angle (in degrees) with respect to a specified origin.
Param angle
The angle in degrees.
Param originx
The x-coordinate of the origin.
Param originy
The y-coordinate of the origin.
Returns MatrixOf The rotated matrix.
rotate90
function (MatrixOf::rotate90
)¶
constexpr MatrixOf rotate90(int angle) const
Rotates the matrix by a multiple of 90 degrees.
Param angle
The multiple of 90 degrees to rotate (e.g., 90, 180, 270).
Returns MatrixOf The rotated matrix.
constexpr MatrixOf rotate90(int angle,
PointOf<T> origin) const
Rotates the matrix by a multiple of 90 degrees with respect to a point.
Param angle
The multiple of 90 degrees to rotate (e.g., 90, 180, 270).
Param origin
The origin point for rotation.
Returns MatrixOf The rotated matrix.
constexpr MatrixOf rotate90(int angle, T originx,
T originy) const
Rotates the matrix by a multiple of 90 degrees with respect to an origin.
Param angle
The multiple of 90 degrees to rotate (e.g., 90, 180, 270).
Param originx
The x-coordinate of the origin.
Param originy
The y-coordinate of the origin.
Returns MatrixOf The rotated matrix.
reflect
function (MatrixOf::reflect
)¶
constexpr MatrixOf reflect(FlipAxis axis) const
Reflects the matrix over the specified axis.
Param axis
The axis of reflection (X, Y, or Both).
Returns MatrixOf The reflected matrix.
constexpr MatrixOf reflect(FlipAxis axis,
PointOf<T> origin) const
Reflects the matrix over the specified axis with respect to a point.
Param axis
The axis of reflection (X, Y, or Both).
Param origin
The origin point for the reflection.
Returns MatrixOf The reflected matrix.
constexpr MatrixOf reflect(FlipAxis axis, T originx,
T originy) const
Reflects the matrix over the specified axis with respect to an origin.
Param axis
The axis of reflection (X, Y, or Both).
Param originx
The x-coordinate of the origin.
Param originy
The y-coordinate of the origin.
Returns MatrixOf The reflected matrix.
translation
function (MatrixOf::translation
)¶
static constexpr MatrixOf translation(T x, T y)
Creates a translation matrix.
Param x
Translation along the x-axis.
Param y
Translation along the y-axis.
Returns MatrixOf The translation matrix.
scaling
function (MatrixOf::scaling
)¶
static constexpr MatrixOf scaling(T x, T y)
Creates a scaling matrix.
Param x
Scaling factor along the x-axis.
Param y
Scaling factor along the y-axis.
Returns MatrixOf The scaling matrix.
rotation
function (MatrixOf::rotation
)¶
static constexpr MatrixOf rotation(T angle)
Creates a rotation matrix.
Param angle
The rotation angle in degrees.
Returns MatrixOf The rotation matrix.
rotation90
function (MatrixOf::rotation90
)¶
static constexpr MatrixOf rotation90(int angle)
Creates a 90-degree rotation matrix.
Param angle
The multiple of 90 degrees (0, 90, 180, or 270).
Returns MatrixOf The 90-degree rotation matrix.
reflection
function (MatrixOf::reflection
)¶
static constexpr MatrixOf reflection(FlipAxis axis)
Creates a reflection matrix over the specified axis.
Param axis
The axis of reflection (X, Y, or Both).
Returns MatrixOf The reflection matrix.
skewness
function (MatrixOf::skewness
)¶
static constexpr MatrixOf skewness(T x, T y)
Creates a skewness matrix.
Param x
The x-axis skew factor.
Param y
The y-axis skew factor.
Returns MatrixOf The skewness matrix.
flatten
function (MatrixOf::flatten
)¶
constexpr SIMD<T, 6> flatten() const noexcept
Flattens the matrix coefficients into a SIMD array.
Returns SIMD<T, 6> The flattened matrix.
operator==
function (MatrixOf::operator==
)¶
constexpr bool operator==(const MatrixOf<T> &m) const
Checks if two matrices are equal.
Param m
The matrix to compare with.
Returns true if the matrices are equal, false otherwise.
operator!=
function (MatrixOf::operator!=
)¶
constexpr bool operator!=(const MatrixOf<T> &m) const
Checks if two matrices are not equal.
Param m
The matrix to compare with.
Returns true if the matrices are not equal, false otherwise.
transform
function (MatrixOf::transform
)¶
constexpr RectangleOf<T> transform(RectangleOf<T> pt) const
Transforms a rectangle using the matrix.
Param pt
The rectangle to transform.
Returns RectangleOf<T> The transformed rectangle.
estimateScale
function (MatrixOf::estimateScale
)¶
constexpr T estimateScale() const
Estimates the average scaling factor of the matrix.
This method calculates an average scale by computing the hypotenuse of
the matrix's first two columns and averaging them.
Returns T The estimated scaling factor.
transform
function (MatrixOf::transform
)¶
constexpr PointOf<T> transform(PointOf<T> pt) const
Transforms a point using the matrix.
Applies a 2D transformation to a given point using the current matrix.
The transformation follows the formula: \(x' = x \cdot a + y \cdot c + e\) \(y' = x \cdot b + y \cdot d + f\)
Param pt
The point to transform.
Returns PointOf<T> The transformed point.
constexpr void transform(std::span<PointOf<T>> points) const
Transforms a collection of points using the matrix.
Applies a 2D transformation to a span of points in an optimized SIMD
approach, processing multiple points in parallel when possible.
Param points
The span of points to transform.
invert
function (MatrixOf::invert
)¶
std::optional<MatrixOf> invert() const
Inverts the matrix, if possible.
Returns std::optional<MatrixOf> The inverse of the matrix if it is invertible, or std::nullopt
if
the matrix is singular (non-invertible).
Auto-generated from sources, Revision , https://github.com/brisklib/brisk/blob//include/brisk/