34#include <initializer_list>
57 std::enable_if_t<std::is_floating_point_v<Value_type>,
bool>>
112 std::enable_if_t<std::is_floating_point_v<Value_type>,
bool> =
true>
167 : m00(*m), m10(*(++m)), m20(*(++m)), m30(*(++m)),
168 m01(*(++m)), m11(*(++m)), m21(*(++m)), m31(*(++m)),
169 m02(*(++m)), m12(*(++m)), m22(*(++m)), m32(*(++m)),
170 m03(*(++m)), m13(*(++m)), m23(*(++m)), m33(*(++m))
177 constexpr Matrix4(std::initializer_list<value_type> m) noexcept
180 assert(m.size() >= 16 );
237 explicit operator pointer() noexcept {
return &m00; }
252 m00 = m11 = m22 = m33 =
one;
256 m30 = m31 = m32 =
zero;
291 return load( src.cbegin() );
322 assert( column < 4 );
323 return v_out.set(
get(0+column*4),
335 assert( column < 4 );
349 return v_out.set(
get(0+column*4),
362 return v_out.set(
get( row + 0*4_unz),
365 get( row + 3*4_unz) );
389 return v_out.set(
get(row+0*4_unz),
428 constexpr std::vector<value_type>&
get(std::vector<value_type>& dst,
size_t dst_off)
const noexcept {
429 assert( dst.size() >= dst_off+16 && dst_off <= std::numeric_limits<size_t>::max() - 15 );
430 get( &dst[dst_off++] );
444 ret += m00 * ( + m11*(m22*m33 - m23*m32) - m12*(m21*m33 - m23*m31) + m13*(m21*m32 - m22*m31));
445 ret -= m01 * ( + m10*(m22*m33 - m23*m32) - m12*(m20*m33 - m23*m30) + m13*(m20*m32 - m22*m30));
446 ret += m02 * ( + m10*(m21*m33 - m23*m31) - m11*(m20*m33 - m23*m30) + m13*(m20*m31 - m21*m30));
447 ret -= m03 * ( + m10*(m21*m32 - m22*m31) - m11*(m20*m32 - m22*m30) + m12*(m20*m31 - m21*m30));
548 const value_type b00 = + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31);
549 const value_type b01 = -( + a10*(a22*a33 - a23*a32) - a12*(a20*a33 - a23*a30) + a13*(a20*a32 - a22*a30));
550 const value_type b02 = + a10*(a21*a33 - a23*a31) - a11*(a20*a33 - a23*a30) + a13*(a20*a31 - a21*a30);
551 const value_type b03 = -( + a10*(a21*a32 - a22*a31) - a11*(a20*a32 - a22*a30) + a12*(a20*a31 - a21*a30));
553 const value_type b10 = -( + a01*(a22*a33 - a23*a32) - a02*(a21*a33 - a23*a31) + a03*(a21*a32 - a22*a31));
554 const value_type b11 = + a00*(a22*a33 - a23*a32) - a02*(a20*a33 - a23*a30) + a03*(a20*a32 - a22*a30);
555 const value_type b12 = -( + a00*(a21*a33 - a23*a31) - a01*(a20*a33 - a23*a30) + a03*(a20*a31 - a21*a30));
556 const value_type b13 = + a00*(a21*a32 - a22*a31) - a01*(a20*a32 - a22*a30) + a02*(a20*a31 - a21*a30);
558 const value_type b20 = + a01*(a12*a33 - a13*a32) - a02*(a11*a33 - a13*a31) + a03*(a11*a32 - a12*a31);
559 const value_type b21 = -( + a00*(a12*a33 - a13*a32) - a02*(a10*a33 - a13*a30) + a03*(a10*a32 - a12*a30));
560 const value_type b22 = + a00*(a11*a33 - a13*a31) - a01*(a10*a33 - a13*a30) + a03*(a10*a31 - a11*a30);
561 const value_type b23 = -( + a00*(a11*a32 - a12*a31) - a01*(a10*a32 - a12*a30) + a02*(a10*a31 - a11*a30));
563 const value_type b30 = -( + a01*(a12*a23 - a13*a22) - a02*(a11*a23 - a13*a21) + a03*(a11*a22 - a12*a21));
564 const value_type b31 = + a00*(a12*a23 - a13*a22) - a02*(a10*a23 - a13*a20) + a03*(a10*a22 - a12*a20);
565 const value_type b32 = -( + a00*(a11*a23 - a13*a21) - a01*(a10*a23 - a13*a20) + a03*(a10*a21 - a11*a20));
566 const value_type b33 = + a00*(a11*a22 - a12*a21) - a01*(a10*a22 - a12*a20) + a02*(a10*a21 - a11*a20);
568 const value_type det = (a00*b00 + a01*b01 + a02*b02 + a03*b03) /
scale;
627 const value_type b00 = + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31);
628 const value_type b01 = -( + a10*(a22*a33 - a23*a32) - a12*(a20*a33 - a23*a30) + a13*(a20*a32 - a22*a30));
629 const value_type b02 = + a10*(a21*a33 - a23*a31) - a11*(a20*a33 - a23*a30) + a13*(a20*a31 - a21*a30);
630 const value_type b03 = -( + a10*(a21*a32 - a22*a31) - a11*(a20*a32 - a22*a30) + a12*(a20*a31 - a21*a30));
632 const value_type b10 = -( + a01*(a22*a33 - a23*a32) - a02*(a21*a33 - a23*a31) + a03*(a21*a32 - a22*a31));
633 const value_type b11 = + a00*(a22*a33 - a23*a32) - a02*(a20*a33 - a23*a30) + a03*(a20*a32 - a22*a30);
634 const value_type b12 = -( + a00*(a21*a33 - a23*a31) - a01*(a20*a33 - a23*a30) + a03*(a20*a31 - a21*a30));
635 const value_type b13 = + a00*(a21*a32 - a22*a31) - a01*(a20*a32 - a22*a30) + a02*(a20*a31 - a21*a30);
637 const value_type b20 = + a01*(a12*a33 - a13*a32) - a02*(a11*a33 - a13*a31) + a03*(a11*a32 - a12*a31);
638 const value_type b21 = -( + a00*(a12*a33 - a13*a32) - a02*(a10*a33 - a13*a30) + a03*(a10*a32 - a12*a30));
639 const value_type b22 = + a00*(a11*a33 - a13*a31) - a01*(a10*a33 - a13*a30) + a03*(a10*a31 - a11*a30);
640 const value_type b23 = -( + a00*(a11*a32 - a12*a31) - a01*(a10*a32 - a12*a30) + a02*(a10*a31 - a11*a30));
642 const value_type b30 = -( + a01*(a12*a23 - a13*a22) - a02*(a11*a23 - a13*a21) + a03*(a11*a22 - a12*a21));
643 const value_type b31 = + a00*(a12*a23 - a13*a22) - a02*(a10*a23 - a13*a20) + a03*(a10*a22 - a12*a20);
644 const value_type b32 = -( + a00*(a11*a23 - a13*a21) - a01*(a10*a23 - a13*a20) + a03*(a10*a21 - a11*a20));
645 const value_type b33 = + a00*(a11*a22 - a12*a21) - a01*(a10*a22 - a12*a20) + a02*(a10*a21 - a11*a20);
647 const value_type det = (a00*b00 + a01*b01 + a02*b02 + a03*b03) /
scale;
678 value_type absMax() const noexcept {
679 value_type
max = std::abs(m00);
680 max = std::max(
max, std::abs(m01));
681 max = std::max(
max, std::abs(m02));
682 max = std::max(
max, std::abs(m03));
684 max = std::max(
max, std::abs(m10));
685 max = std::max(
max, std::abs(m11));
686 max = std::max(
max, std::abs(m12));
687 max = std::max(
max, std::abs(m13));
689 max = std::max(
max, std::abs(m20));
690 max = std::max(
max, std::abs(m21));
691 max = std::max(
max, std::abs(m22));
692 max = std::max(
max, std::abs(m23));
694 max = std::max(
max, std::abs(m30));
695 max = std::max(
max, std::abs(m31));
696 max = std::max(
max, std::abs(m32));
697 max = std::max(
max, std::abs(m33));
708 m00 *= s; m10 *= s; m20 *= s; m30 *= s;
709 m01 *= s; m11 *= s; m21 *= s; m31 *= s;
710 m02 *= s; m12 *= s; m22 *= s; m32 *= s;
711 m03 *= s; m13 *= s; m23 *= s; m33 *= s;
727 m00 = ai0 * b.m00 + ai1 * b.m10 + ai2 * b.m20 + ai3 * b.m30 ;
728 m01 = ai0 * b.m01 + ai1 * b.m11 + ai2 * b.m21 + ai3 * b.m31 ;
729 m02 = ai0 * b.m02 + ai1 * b.m12 + ai2 * b.m22 + ai3 * b.m32 ;
730 m03 = ai0 * b.m03 + ai1 * b.m13 + ai2 * b.m23 + ai3 * b.m33 ;
736 m10 = ai0 * b.m00 + ai1 * b.m10 + ai2 * b.m20 + ai3 * b.m30 ;
737 m11 = ai0 * b.m01 + ai1 * b.m11 + ai2 * b.m21 + ai3 * b.m31 ;
738 m12 = ai0 * b.m02 + ai1 * b.m12 + ai2 * b.m22 + ai3 * b.m32 ;
739 m13 = ai0 * b.m03 + ai1 * b.m13 + ai2 * b.m23 + ai3 * b.m33 ;
745 m20 = ai0 * b.m00 + ai1 * b.m10 + ai2 * b.m20 + ai3 * b.m30 ;
746 m21 = ai0 * b.m01 + ai1 * b.m11 + ai2 * b.m21 + ai3 * b.m31 ;
747 m22 = ai0 * b.m02 + ai1 * b.m12 + ai2 * b.m22 + ai3 * b.m32 ;
748 m23 = ai0 * b.m03 + ai1 * b.m13 + ai2 * b.m23 + ai3 * b.m33 ;
754 m30 = ai0 * b.m00 + ai1 * b.m10 + ai2 * b.m20 + ai3 * b.m30 ;
755 m31 = ai0 * b.m01 + ai1 * b.m11 + ai2 * b.m21 + ai3 * b.m31 ;
756 m32 = ai0 * b.m02 + ai1 * b.m12 + ai2 * b.m22 + ai3 * b.m32 ;
757 m33 = ai0 * b.m03 + ai1 * b.m13 + ai2 * b.m23 + ai3 * b.m33 ;
779 m00 = a.m00 * b.m00 + a.m01 * b.m10 + a.m02 * b.m20 + a.m03 * b.m30 ;
780 m01 = a.m00 * b.m01 + a.m01 * b.m11 + a.m02 * b.m21 + a.m03 * b.m31 ;
781 m02 = a.m00 * b.m02 + a.m01 * b.m12 + a.m02 * b.m22 + a.m03 * b.m32 ;
782 m03 = a.m00 * b.m03 + a.m01 * b.m13 + a.m02 * b.m23 + a.m03 * b.m33 ;
785 m10 = a.m10 * b.m00 + a.m11 * b.m10 + a.m12 * b.m20 + a.m13 * b.m30 ;
786 m11 = a.m10 * b.m01 + a.m11 * b.m11 + a.m12 * b.m21 + a.m13 * b.m31 ;
787 m12 = a.m10 * b.m02 + a.m11 * b.m12 + a.m12 * b.m22 + a.m13 * b.m32 ;
788 m13 = a.m10 * b.m03 + a.m11 * b.m13 + a.m12 * b.m23 + a.m13 * b.m33 ;
791 m20 = a.m20 * b.m00 + a.m21 * b.m10 + a.m22 * b.m20 + a.m23 * b.m30 ;
792 m21 = a.m20 * b.m01 + a.m21 * b.m11 + a.m22 * b.m21 + a.m23 * b.m31 ;
793 m22 = a.m20 * b.m02 + a.m21 * b.m12 + a.m22 * b.m22 + a.m23 * b.m32 ;
794 m23 = a.m20 * b.m03 + a.m21 * b.m13 + a.m22 * b.m23 + a.m23 * b.m33 ;
797 m30 = a.m30 * b.m00 + a.m31 * b.m10 + a.m32 * b.m20 + a.m33 * b.m30 ;
798 m31 = a.m30 * b.m01 + a.m31 * b.m11 + a.m32 * b.m21 + a.m33 * b.m31 ;
799 m32 = a.m30 * b.m02 + a.m31 * b.m12 + a.m32 * b.m22 + a.m33 * b.m32 ;
800 m33 = a.m30 * b.m03 + a.m31 * b.m13 + a.m32 * b.m23 + a.m33 * b.m33 ;
812 const value_type x = v_in.x, y = v_in.y, z = v_in.z, w = v_in.w;
813 v_out.set( x * m00 + y * m01 + z * m02 + w * m03,
814 x * m10 + y * m11 + z * m12 + w * m13,
815 x * m20 + y * m21 + z * m22 + w * m23,
816 x * m30 + y * m31 + z * m32 + w * m33 );
826 const value_type x = rhs.x, y = rhs.y, z = rhs.z, w = rhs.w;
827 return Vec4( x * m00 + y * m01 + z * m02 + w * m03,
828 x * m10 + y * m11 + z * m12 + w * m13,
829 x * m20 + y * m21 + z * m22 + w * m23,
830 x * m30 + y * m31 + z * m32 + w * m33 );
839 const value_type x = v_inout.x, y = v_inout.y, z = v_inout.z, w = v_inout.w;
840 v_inout.set( x * m00 + y * m01 + z * m02 + w * m03,
841 x * m10 + y * m11 + z * m12 + w * m13,
842 x * m20 + y * m21 + z * m22 + w * m23,
843 x * m30 + y * m31 + z * m32 + w * m33 );
860 const value_type x = v_in.x, y = v_in.y, z = v_in.z;
861 v_out.set( x * m00 + y * m01 + z * m02 +
one * m03,
862 x * m10 + y * m11 + z * m12 +
one * m13,
863 x * m20 + y * m21 + z * m22 +
one * m23 );
877 const value_type x = rhs.x, y = rhs.y, z = rhs.z;
878 return Vec3( x * m00 + y * m01 + z * m02 +
one * m03,
879 x * m10 + y * m11 + z * m12 +
one * m13,
880 x * m20 + y * m21 + z * m22 +
one * m23 );
895 const value_type x = v_inout.x, y = v_inout.y, z = v_inout.z;
896 v_inout.set( x * m00 + y * m01 + z * m02 +
one * m03,
897 x * m10 + y * m11 + z * m12 +
one * m13,
898 x * m20 + y * m21 + z * m22 +
one * m23 );
921 m00 = m11 = m22 = m33 =
one;
928 m30 = m31 = m32 =
zero;
970 m30 = m31 = m32 =
zero;
1012 x = tmp.
x; y = tmp.
y; z = tmp.
z;
1098 m01 = sh*sb - ch*sa*cb;
1100 m21 = sh*sa*cb + ch*sb;
1103 m02 = ch*sa*sb + sh*cb;
1105 m22 = -sh*sa*sb + ch*cb;
1163 m10 = m20 = m30 =
zero;
1164 m01 = m21 = m31 =
zero;
1165 m02 = m12 = m32 =
zero;
1209 if( zNear <=
zero || zFar <= zNear ) {
1212 if( left == right || top == bottom) {
1217 m10 = m20 = m30 =
zero;
1218 m01 = m21 = m31 =
zero;
1260 return setToFrustum(left, right, bottom, top, zNear, zFar);
1280 return setToFrustum(left, right, bottom, top, zNear, zFar);
1305 const Vec3 fwd = ( center - eye ).normalize();
1333 return mul( tmp.setToTranslation( -eye.x, -eye.y, -eye.z ) );
1369 if (deltaX <= 0 || deltaY <= 0) {
1374 ( viewport.height() -
two * ( y - viewport.y() ) ) / deltaY,
1376 mat4Tmp.setToScale( viewport.width() / deltaX, viewport.height() / deltaY,
one );
1396 return mul( tmp.setToRotationAxis(ang_rad, x, y, z) );
1408 return mul( tmp.setToRotationAxis(ang_rad, axis) );
1420 return mul( tmp.setToTranslation(x, y, z) );
1430 return mul( tmp.setToTranslation(t) );
1442 return mul( tmp.setToScale(x, y, z) );
1452 return mul( tmp.setToScale(s, s, s) );
1473 const Recti& viewport,
Vec3& winPos)
noexcept
1481 Vec4 rawWinPos = mP * vec4Tmp2;
1483 if (
zero == rawWinPos.
w ) {
1493 winPos.
set( rawWinPos.
x * viewport.width() + viewport.x(),
1494 rawWinPos.
y * viewport.height() + viewport.y(),
1513 const Recti& viewport,
Vec3& winPos)
noexcept
1518 if (
zero == rawWinPos.
w ) {
1528 winPos.
set( rawWinPos.
x * viewport.width() + viewport.x(),
1529 rawWinPos.
y * viewport.height() + viewport.y(),
1553 const Recti& viewport,
1558 Matrix4& invPMv = mat4Tmp.mul(mP, mMv);
1563 Vec4 winPos(winx, winy, winz,
one);
1572 Vec4 rawObjPos = invPMv * winPos;
1574 if (
zero == rawObjPos.
w ) {
1598 const Recti& viewport,
1599 Vec3& objPos)
noexcept
1601 Vec4 winPos(winx, winy, winz,
one);
1610 Vec4 rawObjPos = invPMv * winPos;
1612 if (
zero == rawObjPos.
w ) {
1638 const Recti& viewport,
1639 Vec3& objPos1,
Vec3& objPos2)
noexcept
1641 Vec4 winPos(winx, winy, winz1,
one);
1650 Vec4 rawObjPos = invPMv * winPos;
1652 if (
zero == rawObjPos.
w ) {
1664 invPMv.mulVec4(winPos, rawObjPos);
1666 if (
zero == rawObjPos.
w ) {
1695 const Recti& viewport,
1701 Matrix4& invPMv = mat4Tmp.mul(mP, mMv);
1705 Vec4 winPos(winx, winy, winz, clipw);
1708 winPos.
add(-viewport.x(), -viewport.y(), -near,
zero).
mul(
one/viewport.width(),
one/viewport.height(),
one/(far-near),
one);
1714 invPMv.
mulVec4(winPos, objPos);
1716 if (
zero == objPos.w ) {
1741 const Recti& viewport,
1743 Vec4& objPos)
noexcept
1745 Vec4 winPos(winx, winy, winz, clipw);
1748 winPos.
add(-viewport.x(), -viewport.y(), -near,
zero).
mul(
one/viewport.width(),
one/viewport.height(),
one/(far-near),
one);
1754 invPMv.mulVec4(winPos, objPos);
1756 if (
zero == objPos.w ) {
1788 const Recti& viewport,
1793 const Matrix4 invPMv = mat4Tmp1.mul(mP, mMv);
1798 if(
mapWinToObj(winx, winy, winz0, winz1, invPMv, viewport, ray.orig, ray.dir) ) {
1799 ray.dir.sub(ray.orig).normalize();
1829 const Recti& viewport,
1832 if(
mapWinToObj(winx, winy, winz0, winz1, invPMv, viewport, ray.orig, ray.dir) ) {
1833 (ray.dir -= ray.orig).normalize();
1845 std::string
toString(
const std::string& rowPrefix,
const std::string& f)
const noexcept {
1856 std::string
toString(
const std::string& rowPrefix)
const noexcept {
return toString(rowPrefix,
"%13.9f"); }
1862 std::enable_if_t<std::is_floating_point_v<T>,
bool> =
true>
1868 std::enable_if_t<std::is_floating_point_v<T>,
bool> =
true>
1874 std::enable_if_t<std::is_floating_point_v<T>,
bool> =
true>
1880 std::enable_if_t<std::is_floating_point_v<T>,
bool> =
true>
1882 return out << v.toString();
1887static_assert(
alignof(float) ==
alignof(
Mat4f));
1888static_assert(
sizeof(float)*16 ==
sizeof(
Mat4f));
Horizontal and vertical field of view (FOV) halves, allowing a non-centered projection.
float top
Half vertical FOV from center to top, either in inTangents or radians.
float right
Half horizontal FOV from center to right, either in inTangents or radians.
float left
Half horizontal FOV from center to left, either in inTangents or radians.
FovHVHalves toTangents() const noexcept
Returns this instance in tangent values.
float bottom
Half vertical FOV from center to bottom, either in inTangents or radians.
Basic 4x4 value_type matrix implementation using fields for intensive use-cases (host operations).
constexpr Matrix4 & translate(const value_type x, const value_type y, const value_type z, Matrix4 &tmp) noexcept
Translate this matrix, i.e.
static bool mapWinToObj(const value_type winx, const value_type winy, const value_type winz1, const value_type winz2, const Matrix4 &invPMv, const Recti &viewport, Vec3 &objPos1, Vec3 &objPos2) noexcept
Map two window coordinates to two object coordinates, distinguished by their z component.
constexpr Matrix4 & setToScale(const value_type x, const value_type y, const value_type z) noexcept
Set this matrix to scale.
constexpr bool operator==(const Matrix4 &rhs) const noexcept
constexpr value_type get(const jau::nsize_t i) const noexcept
Returns the ith component of the given column-major order matrix, 0 <= i < 16, w/o boundary check.
constexpr iterator get(iterator dst) const noexcept
Get this matrix into the given value_type[16] array in column major order w/o boundary check.
Vector4F< value_type, std::is_floating_point_v< Value_type > > Vec4
constexpr_cxx26 Matrix4 & setToRotationAxis(const value_type ang_rad, value_type x, value_type y, value_type z) noexcept
Set this matrix to rotation from the given axis and angle in radians.
constexpr Vec4 getRow(const jau::nsize_t row) const noexcept
Get the named column of the given column-major matrix to v_out w/o boundary check.
static constexpr const value_type one
std::string toString() const noexcept
constexpr void set(const jau::nsize_t i, const value_type v) noexcept
Sets the ith component of this column-major order matrix with value_type v, 0 <= i < 16 w/o boundary ...
constexpr value_type operator[](size_t i) const noexcept
Returns read-only ith component of the given column-major order matrix, 0 <= i < 16 w/o boundary chec...
static bool mapWinToObj4(const value_type winx, const value_type winy, const value_type winz, const value_type clipw, const Matrix4 &mMv, const Matrix4 &mP, const Recti &viewport, const value_type near, const value_type far, Vec4 &objPos, Matrix4 &mat4Tmp) noexcept
Map window coordinates to object coordinates.
constexpr_cxx26 Matrix4 & setToRotationAxis(const value_type ang_rad, const Vec3 &axis) noexcept
Set this matrix to rotation from the given axis and angle in radians.
bool invert() noexcept
Invert this matrix.
Matrix4 & setToPerspective(const FovHVHalves &fovhv, const value_type zNear, const value_type zFar)
Set this matrix to perspective frustum projection.
static bool mapWinToRay(const value_type winx, const value_type winy, const value_type winz0, const value_type winz1, const Matrix4 &mMv, const Matrix4 &mP, const Recti &viewport, Ray3 &ray, Matrix4 &mat4Tmp1) noexcept
Map two window coordinates w/ shared X/Y and distinctive Z to a Ray.
constexpr Vec3 & getColumn(const jau::nsize_t column, Vec3 &v_out) const noexcept
Get the named column of the given column-major matrix to v_out w/o boundary check.
constexpr Vec3 & mulVec3(const Vec3 &v_in, Vec3 &v_out) const noexcept
Affine 3f-vector transformation by 4x4 matrix.
constexpr const_iterator cbegin() const noexcept
constexpr reference operator[](size_t i) noexcept
Returns writable reference to the ith component of this column-major order matrix,...
Ray3F< value_type, std::is_floating_point_v< Value_type > > Ray3
Matrix4 & transpose() noexcept
Transpose this matrix.
constexpr bool setToPick(const value_type x, const value_type y, const value_type deltaX, const value_type deltaY, const Recti &viewport, Matrix4 &mat4Tmp) noexcept
Set this matrix to the pick matrix based on given parameters.
constexpr Vec4 & mulVec4(const Vec4 &v_in, Vec4 &v_out) const noexcept
constexpr Vec4 getColumn(const jau::nsize_t column) const noexcept
Get the named column of the given column-major matrix to v_out w/o boundary check.
static bool mapWinToRay(const value_type winx, const value_type winy, const value_type winz0, const value_type winz1, const Matrix4 &invPMv, const Recti &viewport, Ray3 &ray) noexcept
Map two window coordinates w/ shared X/Y and distinctive Z to a Ray.
value_type determinant() const noexcept
Returns the determinant of this matrix.
constexpr Matrix4 & scale(const value_type x, const value_type y, const value_type z, Matrix4 &tmp) noexcept
Matrix4 & setToPerspective(const value_type fovy_rad, const value_type aspect, const value_type zNear, const value_type zFar)
Set this matrix to perspective frustum projection.
constexpr bool equals(const Matrix4 &o, const value_type epsilon=std::numeric_limits< value_type >::epsilon()) const noexcept
const value_type & const_reference
constexpr Vec3 & mulVec3(Vec3 &v_inout) const noexcept
Affine 3f-vector transformation by 4x4 matrix.
constexpr iterator begin() noexcept
static bool mapObjToWin(const Vec3 &obj, const Matrix4 &mPMv, const Recti &viewport, Vec3 &winPos) noexcept
Map object coordinates to window coordinates.
std::string toString(const std::string &rowPrefix, const std::string &f) const noexcept
Returns a formatted string representation of this matrix.
static bool mapWinToObj(const value_type winx, const value_type winy, const value_type winz, const Matrix4 &invPMv, const Recti &viewport, Vec3 &objPos) noexcept
Map window coordinates to object coordinates.
Matrix4 & setToFrustum(const value_type left, const value_type right, const value_type bottom, const value_type top, const value_type zNear, const value_type zFar)
Set this matrix to frustum.
constexpr Vec3 operator*(const Vec3 &rhs) const noexcept
Returns new Vec3, with affine 3f-vector transformation by this 4x4 matrix: this * v_in.
constexpr Matrix4 & mul(const Matrix4 &a, const Matrix4 &b) noexcept
Multiply matrix: [this] = [a] x [b].
Matrix4 & transpose(const Matrix4 &src) noexcept
Transpose the given src matrix into this matrix.
constexpr Matrix4 & scale(const value_type s, Matrix4 &tmp) noexcept
Scale this matrix, i.e.
constexpr Vec4 & getColumn(const jau::nsize_t column, Vec4 &v_out) const noexcept
Get the named column of the given column-major matrix to v_out w/o boundary check.
static bool mapObjToWin(const Vec3 &obj, const Matrix4 &mMv, const Matrix4 &mP, const Recti &viewport, Vec3 &winPos) noexcept
Map object coordinates to window coordinates.
constexpr Vec4 operator*(const Vec4 &rhs) const noexcept
Returns new Vec4, with this * v_in.
constexpr Matrix4 & setToLookAt(const Vec3 &eye, const Vec3 ¢er, const Vec3 &up, Matrix4 &tmp) noexcept
Set this matrix to the look-at matrix based on given parameters.
constexpr Vec4 & getRow(const jau::nsize_t row, Vec4 &v_out) const noexcept
Get the named row of the given column-major matrix to v_out w/ boundary check.
constexpr Matrix4 & operator*=(const Matrix4 &rhs) noexcept
Multiply matrix: [this] = [this] x [b].
constexpr Matrix4 & loadIdentity() noexcept
Set this matrix to identity.
constexpr_cxx26 Matrix4 & rotate(const value_type ang_rad, const value_type x, const value_type y, const value_type z, Matrix4 &tmp) noexcept
Rotate this matrix about give axis and angle in radians, i.e.
constexpr Matrix4 & operator=(const Matrix4 &o) noexcept
Copy assignment using the the values of the given src matrix.
static constexpr const value_type half
static constexpr const value_type inv_deviation
static constexpr const value_type zero
constexpr Vec4 & mulVec4(Vec4 &v_inout) const noexcept
std::string toString(const std::string &rowPrefix) const noexcept
Returns a formatted string representation of this matrix.
constexpr Matrix4 & setToOrtho(const value_type left, const value_type right, const value_type bottom, const value_type top, const value_type zNear, const value_type zFar) noexcept
Set this matrix to orthogonal projection.
constexpr_cxx26 Matrix4 & setToRotationEuler(const value_type bankX, const value_type headingY, const value_type attitudeZ) noexcept
Set this matrix to rotation from the given Euler rotation angles in radians.
constexpr_cxx26 Matrix4 & rotate(const value_type ang_rad, const Vec3 &axis, Matrix4 &tmp) noexcept
Rotate this matrix about give axis and angle in radians, i.e.
constexpr std::vector< value_type > & get(std::vector< value_type > &dst, size_t dst_off) const noexcept
Get this matrix into the given FloatBuffer in column major order.
constexpr Matrix4 & setToScale(const Vec3 &s) noexcept
Set this matrix to scale.
Vector3F< value_type, std::is_floating_point_v< Value_type > > Vec3
static bool mapWinToObj(const value_type winx, const value_type winy, const value_type winz, const Matrix4 &mMv, const Matrix4 &mP, const Recti &viewport, Vec3 &objPos, Matrix4 &mat4Tmp) noexcept
Map window coordinates to object coordinates.
constexpr Matrix4 & operator*=(const value_type s) noexcept
Multiply matrix with scalar: [this] = [this] x [s].
constexpr Matrix4(const_iterator m) noexcept
Creates a new matrix based on given value_type[4*4] column major order.
bool invert(const Matrix4 &src) noexcept
Invert the src matrix values into this matrix.
constexpr_cxx26 Matrix4 & setToRotationEuler(const Vec3 &angradXYZ) noexcept
Set this matrix to rotation from the given Euler rotation angles in radians.
constexpr Matrix4 & setToTranslation(const Vec3 &t) noexcept
Set this matrix to translation.
constexpr Matrix4() noexcept
Creates a new identity matrix.
const value_type * const_iterator
constexpr Matrix4 & mul(const Matrix4 &b) noexcept
Multiply matrix: [this] = [this] x [b].
constexpr Matrix4 & translate(const Vec3 &t, Matrix4 &tmp) noexcept
Translate this matrix, i.e.
constexpr Matrix4 & load(const_iterator src) noexcept
static bool mapWinToObj4(const value_type winx, const value_type winy, const value_type winz, const value_type clipw, const Matrix4 &invPMv, const Recti &viewport, const value_type near, const value_type far, Vec4 &objPos) noexcept
Map window coordinates to object coordinates.
constexpr Matrix4(const Matrix4 &o) noexcept
Creates a new matrix copying the values of the given src matrix.
constexpr Vec3 & getRow(const jau::nsize_t row, Vec3 &v_out) const noexcept
Get the named row of the given column-major matrix to v_out w/o boundary check.
constexpr Matrix4 & load(const Matrix4 &src) noexcept
Load the values of the given matrix src to this matrix w/o boundary check.
constexpr Matrix4 & setToTranslation(const value_type x, const value_type y, const value_type z) noexcept
Set this matrix to translation.
const value_type * const_pointer
static constexpr const value_type two
constexpr Matrix4(std::initializer_list< value_type > m) noexcept
Creates a new matrix based on given value_type initializer list in column major order.
Quaternion implementation supporting Gimbal-Lock free rotations.
Simple compound denoting a ray.
3D vector using three value_type components.
constexpr Vector3F & normalize() noexcept
Normalize this vector in place.
constexpr Vector3F cross(const Vector3F &b) const noexcept
cross product this x b
4D vector using four value_type components.
constexpr Vector4F & mul(const value_type sx, const value_type sy, const value_type sz, const value_type sw) noexcept
this = this * {sx, sy, sz, sw}, returns this.
constexpr Vector4F & set(const Vec3f &o, const value_type w_) noexcept
TODO constexpr bool operator<=>(const vec4f_t& rhs ) const noexcept { return ... }...
constexpr Vec3 & getVec3(Vec3 &out) const noexcept
out = { this.x, this.y, this.z } dropping w, returns out.
constexpr Vector4F & add(const value_type dx, const value_type dy, const value_type dz, const value_type dw) noexcept
this = this + {dx, dy, dz, dw}, returns this.
constexpr Vector4F & scale(const value_type s) noexcept
this = this * s, returns this.
Providing frustum planes derived by different inputs (P*MV, ..) used to classify objects.
std::enable_if_t< std::is_floating_point_v< T >, bool > constexpr equals(const T &a, const T &b, const T &epsilon=std::numeric_limits< T >::epsilon()) noexcept
Returns true if both values are equal, i.e.
std::string & mat_to_string(std::string &sb, const std::string &rowPrefix, const std::string &f, const T a[], const jau::nsize_t rows, const jau::nsize_t columns, const bool rowMajorOrder) noexcept
Appends a matrix of floating points to the given string sb
uint_fast32_t nsize_t
Natural 'size_t' alternative using uint_fast32_t as its natural sized type.
constexpr Vector2F< T > max(const Vector2F< T > &lhs, const Vector2F< T > &rhs) noexcept
constexpr Matrix4< T > operator*(const Matrix4< T > &lhs, const Matrix4< T > &rhs) noexcept
std::ostream & operator<<(std::ostream &out, const Addr48Bit &a)