34#include <initializer_list>
56 std::enable_if_t<std::is_floating_point_v<Value_type>,
bool>>
111 std::enable_if_t<std::is_floating_point_v<Value_type>,
bool> =
true>
166 : m00(*m), m10(*(++m)), m20(*(++m)), m30(*(++m)),
167 m01(*(++m)), m11(*(++m)), m21(*(++m)), m31(*(++m)),
168 m02(*(++m)), m12(*(++m)), m22(*(++m)), m32(*(++m)),
169 m03(*(++m)), m13(*(++m)), m23(*(++m)), m33(*(++m))
176 constexpr Matrix4(std::initializer_list<value_type> m) noexcept
179 assert(m.size() >= 16 );
236 explicit operator pointer() noexcept {
return &m00; }
251 m00 = m11 = m22 = m33 =
one;
255 m30 = m31 = m32 =
zero;
290 return load( src.cbegin() );
321 assert( column < 4 );
322 return v_out.set(
get(0+column*4),
334 assert( column < 4 );
348 return v_out.
set(
get(0+column*4),
360 return v_out.
set(
get(row+0*4),
385 return v_out.set(
get(row+0*4),
424 constexpr std::vector<value_type>&
get(std::vector<value_type>& dst,
size_t dst_off)
const noexcept {
426 get( &dst[dst_off++] );
440 ret += m00 * ( + m11*(m22*m33 - m23*m32) - m12*(m21*m33 - m23*m31) + m13*(m21*m32 - m22*m31));
441 ret -= m01 * ( + m10*(m22*m33 - m23*m32) - m12*(m20*m33 - m23*m30) + m13*(m20*m32 - m22*m30));
442 ret += m02 * ( + m10*(m21*m33 - m23*m31) - m11*(m20*m33 - m23*m30) + m13*(m20*m31 - m21*m30));
443 ret -= m03 * ( + m10*(m21*m32 - m22*m31) - m11*(m20*m32 - m22*m30) + m12*(m20*m31 - m21*m30));
544 const value_type b00 = + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31);
545 const value_type b01 = -( + a10*(a22*a33 - a23*a32) - a12*(a20*a33 - a23*a30) + a13*(a20*a32 - a22*a30));
546 const value_type b02 = + a10*(a21*a33 - a23*a31) - a11*(a20*a33 - a23*a30) + a13*(a20*a31 - a21*a30);
547 const value_type b03 = -( + a10*(a21*a32 - a22*a31) - a11*(a20*a32 - a22*a30) + a12*(a20*a31 - a21*a30));
549 const value_type b10 = -( + a01*(a22*a33 - a23*a32) - a02*(a21*a33 - a23*a31) + a03*(a21*a32 - a22*a31));
550 const value_type b11 = + a00*(a22*a33 - a23*a32) - a02*(a20*a33 - a23*a30) + a03*(a20*a32 - a22*a30);
551 const value_type b12 = -( + a00*(a21*a33 - a23*a31) - a01*(a20*a33 - a23*a30) + a03*(a20*a31 - a21*a30));
552 const value_type b13 = + a00*(a21*a32 - a22*a31) - a01*(a20*a32 - a22*a30) + a02*(a20*a31 - a21*a30);
554 const value_type b20 = + a01*(a12*a33 - a13*a32) - a02*(a11*a33 - a13*a31) + a03*(a11*a32 - a12*a31);
555 const value_type b21 = -( + a00*(a12*a33 - a13*a32) - a02*(a10*a33 - a13*a30) + a03*(a10*a32 - a12*a30));
556 const value_type b22 = + a00*(a11*a33 - a13*a31) - a01*(a10*a33 - a13*a30) + a03*(a10*a31 - a11*a30);
557 const value_type b23 = -( + a00*(a11*a32 - a12*a31) - a01*(a10*a32 - a12*a30) + a02*(a10*a31 - a11*a30));
559 const value_type b30 = -( + a01*(a12*a23 - a13*a22) - a02*(a11*a23 - a13*a21) + a03*(a11*a22 - a12*a21));
560 const value_type b31 = + a00*(a12*a23 - a13*a22) - a02*(a10*a23 - a13*a20) + a03*(a10*a22 - a12*a20);
561 const value_type b32 = -( + a00*(a11*a23 - a13*a21) - a01*(a10*a23 - a13*a20) + a03*(a10*a21 - a11*a20));
562 const value_type b33 = + a00*(a11*a22 - a12*a21) - a01*(a10*a22 - a12*a20) + a02*(a10*a21 - a11*a20);
564 const value_type det = (a00*b00 + a01*b01 + a02*b02 + a03*b03) / scale;
623 const value_type b00 = + a11*(a22*a33 - a23*a32) - a12*(a21*a33 - a23*a31) + a13*(a21*a32 - a22*a31);
624 const value_type b01 = -( + a10*(a22*a33 - a23*a32) - a12*(a20*a33 - a23*a30) + a13*(a20*a32 - a22*a30));
625 const value_type b02 = + a10*(a21*a33 - a23*a31) - a11*(a20*a33 - a23*a30) + a13*(a20*a31 - a21*a30);
626 const value_type b03 = -( + a10*(a21*a32 - a22*a31) - a11*(a20*a32 - a22*a30) + a12*(a20*a31 - a21*a30));
628 const value_type b10 = -( + a01*(a22*a33 - a23*a32) - a02*(a21*a33 - a23*a31) + a03*(a21*a32 - a22*a31));
629 const value_type b11 = + a00*(a22*a33 - a23*a32) - a02*(a20*a33 - a23*a30) + a03*(a20*a32 - a22*a30);
630 const value_type b12 = -( + a00*(a21*a33 - a23*a31) - a01*(a20*a33 - a23*a30) + a03*(a20*a31 - a21*a30));
631 const value_type b13 = + a00*(a21*a32 - a22*a31) - a01*(a20*a32 - a22*a30) + a02*(a20*a31 - a21*a30);
633 const value_type b20 = + a01*(a12*a33 - a13*a32) - a02*(a11*a33 - a13*a31) + a03*(a11*a32 - a12*a31);
634 const value_type b21 = -( + a00*(a12*a33 - a13*a32) - a02*(a10*a33 - a13*a30) + a03*(a10*a32 - a12*a30));
635 const value_type b22 = + a00*(a11*a33 - a13*a31) - a01*(a10*a33 - a13*a30) + a03*(a10*a31 - a11*a30);
636 const value_type b23 = -( + a00*(a11*a32 - a12*a31) - a01*(a10*a32 - a12*a30) + a02*(a10*a31 - a11*a30));
638 const value_type b30 = -( + a01*(a12*a23 - a13*a22) - a02*(a11*a23 - a13*a21) + a03*(a11*a22 - a12*a21));
639 const value_type b31 = + a00*(a12*a23 - a13*a22) - a02*(a10*a23 - a13*a20) + a03*(a10*a22 - a12*a20);
640 const value_type b32 = -( + a00*(a11*a23 - a13*a21) - a01*(a10*a23 - a13*a20) + a03*(a10*a21 - a11*a20));
641 const value_type b33 = + a00*(a11*a22 - a12*a21) - a01*(a10*a22 - a12*a20) + a02*(a10*a21 - a11*a20);
643 const value_type det = (a00*b00 + a01*b01 + a02*b02 + a03*b03) / scale;
674 value_type absMax() const noexcept {
704 m00 *= s; m10 *= s; m20 *= s; m30 *= s;
705 m01 *= s; m11 *= s; m21 *= s; m31 *= s;
706 m02 *= s; m12 *= s; m22 *= s; m32 *= s;
707 m03 *= s; m13 *= s; m23 *= s; m33 *= s;
723 m00 = ai0 * b.m00 + ai1 * b.m10 + ai2 * b.m20 + ai3 * b.m30 ;
724 m01 = ai0 * b.m01 + ai1 * b.m11 + ai2 * b.m21 + ai3 * b.m31 ;
725 m02 = ai0 * b.m02 + ai1 * b.m12 + ai2 * b.m22 + ai3 * b.m32 ;
726 m03 = ai0 * b.m03 + ai1 * b.m13 + ai2 * b.m23 + ai3 * b.m33 ;
732 m10 = ai0 * b.m00 + ai1 * b.m10 + ai2 * b.m20 + ai3 * b.m30 ;
733 m11 = ai0 * b.m01 + ai1 * b.m11 + ai2 * b.m21 + ai3 * b.m31 ;
734 m12 = ai0 * b.m02 + ai1 * b.m12 + ai2 * b.m22 + ai3 * b.m32 ;
735 m13 = ai0 * b.m03 + ai1 * b.m13 + ai2 * b.m23 + ai3 * b.m33 ;
741 m20 = ai0 * b.m00 + ai1 * b.m10 + ai2 * b.m20 + ai3 * b.m30 ;
742 m21 = ai0 * b.m01 + ai1 * b.m11 + ai2 * b.m21 + ai3 * b.m31 ;
743 m22 = ai0 * b.m02 + ai1 * b.m12 + ai2 * b.m22 + ai3 * b.m32 ;
744 m23 = ai0 * b.m03 + ai1 * b.m13 + ai2 * b.m23 + ai3 * b.m33 ;
750 m30 = ai0 * b.m00 + ai1 * b.m10 + ai2 * b.m20 + ai3 * b.m30 ;
751 m31 = ai0 * b.m01 + ai1 * b.m11 + ai2 * b.m21 + ai3 * b.m31 ;
752 m32 = ai0 * b.m02 + ai1 * b.m12 + ai2 * b.m22 + ai3 * b.m32 ;
753 m33 = ai0 * b.m03 + ai1 * b.m13 + ai2 * b.m23 + ai3 * b.m33 ;
775 m00 = a.m00 * b.m00 + a.m01 * b.m10 + a.m02 * b.m20 + a.m03 * b.m30 ;
776 m01 = a.m00 * b.m01 + a.m01 * b.m11 + a.m02 * b.m21 + a.m03 * b.m31 ;
777 m02 = a.m00 * b.m02 + a.m01 * b.m12 + a.m02 * b.m22 + a.m03 * b.m32 ;
778 m03 = a.m00 * b.m03 + a.m01 * b.m13 + a.m02 * b.m23 + a.m03 * b.m33 ;
781 m10 = a.m10 * b.m00 + a.m11 * b.m10 + a.m12 * b.m20 + a.m13 * b.m30 ;
782 m11 = a.m10 * b.m01 + a.m11 * b.m11 + a.m12 * b.m21 + a.m13 * b.m31 ;
783 m12 = a.m10 * b.m02 + a.m11 * b.m12 + a.m12 * b.m22 + a.m13 * b.m32 ;
784 m13 = a.m10 * b.m03 + a.m11 * b.m13 + a.m12 * b.m23 + a.m13 * b.m33 ;
787 m20 = a.m20 * b.m00 + a.m21 * b.m10 + a.m22 * b.m20 + a.m23 * b.m30 ;
788 m21 = a.m20 * b.m01 + a.m21 * b.m11 + a.m22 * b.m21 + a.m23 * b.m31 ;
789 m22 = a.m20 * b.m02 + a.m21 * b.m12 + a.m22 * b.m22 + a.m23 * b.m32 ;
790 m23 = a.m20 * b.m03 + a.m21 * b.m13 + a.m22 * b.m23 + a.m23 * b.m33 ;
793 m30 = a.m30 * b.m00 + a.m31 * b.m10 + a.m32 * b.m20 + a.m33 * b.m30 ;
794 m31 = a.m30 * b.m01 + a.m31 * b.m11 + a.m32 * b.m21 + a.m33 * b.m31 ;
795 m32 = a.m30 * b.m02 + a.m31 * b.m12 + a.m32 * b.m22 + a.m33 * b.m32 ;
796 m33 = a.m30 * b.m03 + a.m31 * b.m13 + a.m32 * b.m23 + a.m33 * b.m33 ;
808 const value_type x = v_in.
x, y = v_in.y, z = v_in.z, w = v_in.w;
809 v_out.set( x * m00 + y * m01 + z * m02 + w * m03,
810 x * m10 + y * m11 + z * m12 + w * m13,
811 x * m20 + y * m21 + z * m22 + w * m23,
812 x * m30 + y * m31 + z * m32 + w * m33 );
822 const value_type x = rhs.
x, y = rhs.y, z = rhs.z, w = rhs.w;
823 return Vec4( x * m00 + y * m01 + z * m02 + w * m03,
824 x * m10 + y * m11 + z * m12 + w * m13,
825 x * m20 + y * m21 + z * m22 + w * m23,
826 x * m30 + y * m31 + z * m32 + w * m33 );
835 const value_type x = v_inout.
x, y = v_inout.y, z = v_inout.z, w = v_inout.w;
836 v_inout.set( x * m00 + y * m01 + z * m02 + w * m03,
837 x * m10 + y * m11 + z * m12 + w * m13,
838 x * m20 + y * m21 + z * m22 + w * m23,
839 x * m30 + y * m31 + z * m32 + w * m33 );
856 const value_type x = v_in.
x, y = v_in.y, z = v_in.z;
857 v_out.set( x * m00 + y * m01 + z * m02 +
one * m03,
858 x * m10 + y * m11 + z * m12 +
one * m13,
859 x * m20 + y * m21 + z * m22 +
one * m23 );
874 return Vec3( x * m00 + y * m01 + z * m02 +
one * m03,
875 x * m10 + y * m11 + z * m12 +
one * m13,
876 x * m20 + y * m21 + z * m22 +
one * m23 );
891 const value_type x = v_inout.
x, y = v_inout.y, z = v_inout.z;
892 v_inout.set( x * m00 + y * m01 + z * m02 +
one * m03,
893 x * m10 + y * m11 + z * m12 +
one * m13,
894 x * m20 + y * m21 + z * m22 +
one * m23 );
917 m00 = m11 = m22 = m33 =
one;
924 m30 = m31 = m32 =
zero;
941 return setToTranslation(t.x, t.y, t.z);
966 m30 = m31 = m32 =
zero;
983 return setToScale(s.x, s.y, s.z);
1008 x = tmp.
x; y = tmp.
y; z = tmp.
z;
1054 return setToRotationAxis(ang_rad, axis.x, axis.y, axis.z);
1094 m01 = sh*sb - ch*sa*cb;
1096 m21 = sh*sa*cb + ch*sb;
1099 m02 = ch*sa*sb + sh*cb;
1101 m22 = -sh*sa*sb + ch*cb;
1134 return setToRotationEuler(angradXYZ.x, angradXYZ.y, angradXYZ.z);
1159 m10 = m20 = m30 =
zero;
1160 m01 = m21 = m31 =
zero;
1161 m02 = m12 = m32 =
zero;
1205 if( zNear <=
zero || zFar <= zNear ) {
1208 if( left == right || top == bottom) {
1213 m10 = m20 = m30 =
zero;
1214 m01 = m21 = m31 =
zero;
1252 const value_type top = std::tan(fovy_rad/two) * zNear;
1256 return setToFrustum(left, right, bottom, top, zNear, zFar);
1276 return setToFrustum(left, right, bottom, top, zNear, zFar);
1301 const Vec3 fwd = ( center - eye ).normalize();
1329 return mul( tmp.setToTranslation( -eye.x, -eye.y, -eye.z ) );
1365 if (deltaX <= 0 || deltaY <= 0) {
1369 setToTranslation( ( viewport.width() - two * ( x - viewport.x() ) ) / deltaX,
1370 ( viewport.height() - two * ( y - viewport.y() ) ) / deltaY,
1372 mat4Tmp.setToScale( viewport.width() / deltaX, viewport.height() / deltaY,
one );
1392 return mul( tmp.setToRotationAxis(ang_rad, x, y, z) );
1404 return mul( tmp.setToRotationAxis(ang_rad, axis) );
1416 return mul( tmp.setToTranslation(x, y, z) );
1426 return mul( tmp.setToTranslation(t) );
1438 return mul( tmp.setToScale(x, y, z) );
1448 return mul( tmp.setToScale(s, s, s) );
1469 const Recti& viewport,
Vec3& winPos)
noexcept
1475 Vec4 vec4Tmp2 = mMv *
Vec4(obj, 1.0f);
1477 Vec4 rawWinPos = mP * vec4Tmp2;
1479 if (
zero == rawWinPos.
w ) {
1486 rawWinPos.
scale(s).
add(half, half, half, 0.0f);
1489 winPos.
set( rawWinPos.
x * viewport.width() + viewport.x(),
1490 rawWinPos.
y * viewport.height() + viewport.y(),
1509 const Recti& viewport,
Vec3& winPos)
noexcept
1512 Vec4 rawWinPos = mPMv *
Vec4(obj, 1);
1514 if (
zero == rawWinPos.
w ) {
1521 rawWinPos.
scale(s).
add(half, half, half, 0.0f);
1524 winPos.
set( rawWinPos.
x * viewport.width() + viewport.x(),
1525 rawWinPos.
y * viewport.height() + viewport.y(),
1549 const Recti& viewport,
1559 Vec4 winPos(winx, winy, winz, 1.0f);
1562 winPos.
add(-viewport.x(), -viewport.y(), 0.0f, 0.0f).
mul(1.0f/viewport.width(), 1.0f/viewport.height(), 1.0f, 1.0f);
1565 winPos.
mul(2.0f, 2.0f, 2.0f, 1.0f).
add(-1.0f, -1.0f, -1.0f, 0.0f);
1568 Vec4 rawObjPos = invPMv * winPos;
1570 if (
zero == rawObjPos.
w ) {
1594 const Recti& viewport,
1595 Vec3& objPos)
noexcept
1597 Vec4 winPos(winx, winy, winz, 1.0f);
1600 winPos.
add(-viewport.x(), -viewport.y(), 0.0f, 0.0f).
mul(1.0f/viewport.width(), 1.0f/viewport.height(), 1.0f, 1.0f);
1603 winPos.
mul(2.0f, 2.0f, 2.0f, 1.0f).
add(-1.0f, -1.0f, -1.0f, 0.0f);
1606 Vec4 rawObjPos = invPMv * winPos;
1608 if (
zero == rawObjPos.
w ) {
1634 const Recti& viewport,
1635 Vec3& objPos1,
Vec3& objPos2)
noexcept
1637 Vec4 winPos(winx, winy, winz1, 1.0f);
1640 winPos.
add(-viewport.x(), -viewport.y(), 0.0f, 0.0f).
mul(1.0f/viewport.width(), 1.0f/viewport.height(), 1.0f, 1.0f);
1643 winPos.
mul(2.0f, 2.0f, 2.0f, 1.0f).
add(-1.0f, -1.0f, -1.0f, 0.0f);
1646 Vec4 rawObjPos = invPMv * winPos;
1648 if (
zero == rawObjPos.
w ) {
1657 winPos.
z = winz2 * 2.0f - 1.0f;
1660 invPMv.mulVec4(winPos, rawObjPos);
1662 if (
zero == rawObjPos.
w ) {
1691 const Recti& viewport,
1701 Vec4 winPos(winx, winy, winz, clipw);
1704 winPos.
add(-viewport.x(), -viewport.y(), -near, 0.0f).
mul(1.0f/viewport.width(), 1.0f/viewport.height(), 1.0f/(far-near), 1.0f);
1707 winPos.
mul(2.0f, 2.0f, 2.0f, 1.0f).
add(-1.0f, -1.0f, -1.0f, 0.0f);
1710 invPMv.
mulVec4(winPos, objPos);
1712 if (
zero == objPos.w ) {
1737 const Recti& viewport,
1739 Vec4& objPos)
noexcept
1741 Vec4 winPos(winx, winy, winz, clipw);
1744 winPos.
add(-viewport.x(), -viewport.y(), -near, 0.0f).
mul(1.0f/viewport.width(), 1.0f/viewport.height(), 1.0f/(far-near), 1.0f);
1747 winPos.
mul(2.0f, 2.0f, 2.0f, 1.0f).
add(-1.0f, -1.0f, -1.0f, 0.0f);
1750 invPMv.mulVec4(winPos, objPos);
1752 if (
zero == objPos.w ) {
1784 const Recti& viewport,
1789 const Matrix4 invPMv = mat4Tmp1.
mul(mP, mMv);
1794 if( mapWinToObj(winx, winy, winz0, winz1, invPMv, viewport, ray.orig, ray.dir) ) {
1795 ray.dir.sub(ray.orig).normalize();
1825 const Recti& viewport,
1828 if( mapWinToObj(winx, winy, winz0, winz1, invPMv, viewport, ray.orig, ray.dir) ) {
1829 (ray.dir -= ray.orig).normalize();
1841 std::string
toString(
const std::string& rowPrefix,
const std::string& f)
const noexcept {
1852 std::string
toString(
const std::string& rowPrefix)
const noexcept {
return toString(rowPrefix,
"%13.9f"); }
1858 std::enable_if_t<std::is_floating_point_v<T>,
bool> =
true>
1864 std::enable_if_t<std::is_floating_point_v<T>,
bool> =
true>
1870 std::enable_if_t<std::is_floating_point_v<T>,
bool> =
true>
1876 std::enable_if_t<std::is_floating_point_v<T>,
bool> =
true>
1878 return out << v.toString();
1883static_assert(
alignof(float) ==
alignof(
Mat4f));
1884static_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.
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
Scale this matrix, i.e.
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.
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
Load the values of the given matrix src to this matrix w/o boundary check.
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
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.
Rectangle with x, y, width and height integer components.
3D vector using three value_type components.
constexpr Vector3F & set(const Vec2f &o, const value_type z_) noexcept
TODO constexpr bool operator<=>(const vec3f_t& rhs ) const noexcept { return ... }.
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::string to_string(const alphabet &v) noexcept
Entry * get(const EUI48 &addr, const std::string &name, AddressNameEntryMatchFunc m) noexcept
Returns a matching BTSecurityRegistry::Entry with the given addr and/or name.
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
std::enable_if< std::is_floating_point_v< T >, bool >::type 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.
uint_fast32_t nsize_t
Natural 'size_t' alternative using uint_fast32_t as its natural sized type.
constexpr T max(const T x, const T y) noexcept
Returns the maximum of two integrals (w/ branching) in O(1)
constexpr T abs(const T x) noexcept
Returns the absolute value of an arithmetic number (w/ branching) in O(1)
constexpr Matrix4< T > operator*(const Matrix4< T > &lhs, const Matrix4< T > &rhs) noexcept
std::ostream & operator<<(std::ostream &out, const Matrix4< T > &v) noexcept
constexpr const jau::fraction_i64 zero(0l, 1lu)
zero is 0/1
constexpr const jau::fraction_i64 one(1l, 1lu)
one is 10^0 or 1/1
Simple compound denoting a ray.