12#include "translate3.hpp"
15#include "../macros.hpp"
21hi_export_module(hikogui.geometry : matrix3);
23hi_export
namespace hi {
inline namespace v1 {
26[[nodiscard]]
constexpr matrix3
operator*(matrix3
const& lhs, matrix3
const& rhs)
noexcept;
27[[nodiscard]]
constexpr matrix3
operator*(translate3
const& lhs, scale3
const& rhs)
noexcept;
28[[nodiscard]]
constexpr matrix3
operator*(translate3
const& lhs, rotate3
const& rhs)
noexcept;
47 auto const a = f32x4::broadcast(1.0f);
120 _col0(
c0r0,
c0r1,
c0r2, 0.0f), _col1(
c1r0,
c1r1,
c1r2, 0.0f), _col2(
c2r0,
c2r1,
c2r2, 0.0f), _col3(0.0f, 0.0f, 0.0f, 1.0f)
163 _col0(
c0r0,
c0r1,
c0r2,
c0r3), _col1(
c1r0,
c1r1,
c1r2,
c1r3), _col2(
c2r0,
c2r1,
c2r2,
c2r3), _col3(
c3r0,
c3r1,
c3r2,
c3r3)
195 _col0 = f32x4{rhs}.x000();
196 _col1 = f32x4{rhs}._0y00();
197 _col2 = f32x4{rhs}._00z0();
198 _col3 = f32x4{rhs}._000w();
203 auto const ones = f32x4::broadcast(1.0f);
205 _col1 =
ones._0y00();
206 _col2 =
ones._00z0();
207 _col3 =
ones._000w() + f32x4{rhs};
230 auto twos =
f32x4{-2.0f, 2.0f, 2.0f, 0.0f};
231 auto one =
f32x4{1.0f, 0.0f, 0.0f, 0.0f};
246 hi_axiom(holds_invariant());
247 return {_col0, _col1, _col2, _col3};
273 if constexpr (I == 0) {
275 }
else if constexpr (I == 1) {
277 }
else if constexpr (I == 2) {
279 }
else if constexpr (I == 3) {
282 hi_static_no_default();
294 if constexpr (I == 0) {
296 }
else if constexpr (I == 1) {
298 }
else if constexpr (I == 2) {
300 }
else if constexpr (I == 3) {
303 hi_static_no_default();
319 return {_col0 * rhs.xxxx() + _col1 * rhs.yyyy() + _col2 * rhs.zzzz() + _col3 * rhs.wwww()};
327 auto tmp =
transpose(rhs._col0, rhs._col1, rhs._col2, rhs._col3);
364 template<
char DstX,
char DstY,
char DstZ,
char DstW = 'w'>
377 return equal(lhs._col0, rhs._col0)
and equal(lhs._col1, rhs._col1)
and equal(lhs._col2, rhs._col2)
and
378 equal(lhs._col3, rhs._col3);
390 auto const s0c0 = _col0 * _col1.yxwz();
396 auto const s1c1 = _col0 * _col2.yxwz();
403 auto const s2c2 = _col0 * _col3.yxwz();
409 auto const s3c3 = _col1 * _col2.yxwz();
416 auto const s4c4 = _col1 * _col3.yxwz();
422 auto const s5c5 = _col2 * _col3.yxwz();
444 if (det.x() == 0.0f) {
448 auto const invdet = rcp(det);
501 if constexpr (
Axis ==
'x') {
502 return f32x4{1.0f, 0.0f, 0.0f, 0.0f};
503 }
else if constexpr (
Axis ==
'X') {
504 return f32x4{-1.0f, 0.0f, 0.0f, 0.0f};
505 }
else if constexpr (
Axis ==
'y') {
506 return f32x4{0.0f, 1.0f, 0.0f, 0.0f};
507 }
else if constexpr (
Axis ==
'Y') {
508 return f32x4{0.0f, -1.0f, 0.0f, 0.0f};
509 }
else if constexpr (
Axis ==
'z') {
510 return f32x4{0.0f, 0.0f, 1.0f, 0.0f};
511 }
else if constexpr (
Axis ==
'Z') {
512 return f32x4{0.0f, 0.0f, -1.0f, 0.0f};
513 }
else if constexpr (
Axis ==
'w') {
514 return f32x4{0.0f, 0.0f, 0.0f, 1.0f};
515 }
else if constexpr (
Axis ==
'W') {
516 return f32x4{0.0f, 0.0f, 0.0f, -1.0f};
518 hi_static_no_default();
@ other
The gui_event does not have associated data.
The HikoGUI namespace.
Definition array_generic.hpp:20
@ one
The number was one, and this means something in the current language.
constexpr matrix2 operator*(matrix2 const &lhs, matrix2 const &rhs) noexcept
Matrix/Matrix multiplication.
Definition transform.hpp:69
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
Class which represents an axis-aligned rectangle.
Definition aarectangle.hpp:33
Horizontal/Vertical alignment combination.
Definition alignment.hpp:244
A 2D or 3D homogenius matrix for transforming homogenious vectors and points.
Definition matrix2.hpp:39
static constexpr matrix2 uniform(aarectangle src_rectangle, aarectangle dst_rectangle, alignment alignment) noexcept
Create a transformation matrix to translate and uniformly-scale a src_rectangle to a dst_rectangle.
Definition matrix2.hpp:241
A 2D or 3D homogenius matrix for transforming homogenious vectors and points.
Definition matrix3.hpp:36
friend constexpr matrix3 transpose(matrix3 const &rhs) noexcept
Matrix transpose.
Definition matrix3.hpp:325
constexpr f32x4 operator*(f32x4 const &rhs) const noexcept
Transform a f32x4 numeric array by the matrix.
Definition matrix3.hpp:317
friend constexpr matrix3 reflect(matrix3 const &rhs) noexcept
Reflect axis of a matrix.
Definition matrix3.hpp:365
constexpr matrix3(f32x4 col0, f32x4 col1, f32x4 col2, f32x4 col3=f32x4{0.0f, 0.0f, 0.0f, 1.0f}) noexcept
Construct a matrix from four columns.
Definition matrix3.hpp:61
constexpr matrix3(float c0r0, float c1r0, float c2r0, float c3r0, float c0r1, float c1r1, float c2r1, float c3r1, float c0r2, float c1r2, float c2r2, float c3r2, float c0r3, float c1r3, float c2r3, float c3r3) noexcept
Construct a 4x4 matrix from scalar values.
Definition matrix3.hpp:146
constexpr matrix3(matrix2 const &other) noexcept
Copy-construct a matrix from a smaller matrix.
Definition matrix3.hpp:169
constexpr matrix3(rotate3 const &rhs) noexcept
Convert quaternion to matrix.
Definition matrix3.hpp:213
constexpr friend bool operator==(matrix3 const &lhs, matrix3 const &rhs) noexcept
Compare two matrices potentially of different dimensions.
Definition matrix3.hpp:375
constexpr matrix3() noexcept
Constructs an identity matrix.
Definition matrix3.hpp:45
friend constexpr f32x4 & get(matrix3 &rhs) noexcept
Get a column.
Definition matrix3.hpp:292
constexpr matrix3 operator~() const
Invert matrix.
Definition matrix3.hpp:383
friend constexpr f32x4 const & get(matrix3 const &rhs) noexcept
Get a column.
Definition matrix3.hpp:271
constexpr matrix3(float c0r0, float c1r0, float c2r0, float c0r1, float c1r1, float c2r1, float c0r2, float c1r2, float c2r2) noexcept
Construct a matrix from two vectors.
Definition matrix3.hpp:110
static constexpr matrix3 uniform(aarectangle src_rectangle, aarectangle dst_rectangle, alignment alignment) noexcept
Create a transformation matrix to translate and uniformly-scale a src_rectangle to a dst_rectangle.
Definition matrix3.hpp:260
constexpr matrix3(vector3 col0, vector3 col1, vector3 col2, vector3 col3=vector3{}) noexcept
Construct a matrix from four vectors.
Definition matrix3.hpp:73
Definition rotate3.hpp:17
A high-level geometric vector Part of the high-level vector, point, mat and color types.
Definition vector3.hpp:26