42TEST_CASE(
"Test 01 Project PMVMatrixToMatrix4f",
"[project][mat4f][linear_algebra][math]" ) {
44 const Recti viewport(0,0,10,10);
46 Vec3f winA00, winA01, winA10, winA11;
47 Vec3f winB00, winB01, winB10, winB11;
55 std::cout <<
"A.0.0 - Project 1,0 -->" << winA00 << std::endl;
57 std::cout <<
"B.0.0 - Project 1,0 -->" << winB00 << std::endl;
60 std::cout <<
"A.0.1 - Project 0,0 -->" << winA01 << std::endl;
62 std::cout <<
"B.0.1 - Project 0,0 -->" << winB01 << std::endl;
64 m.
orthoP(0, 10, 0, 10, 1, -1);
65 std::cout <<
"MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale" << std::endl;
66 std::cout << m << std::endl;
68 std::cout << mat4PMv.
toString(
"mat4PMv",
"%10.5f") << std::endl;
71 std::cout <<
"A.1.0 - Project 1,0 -->" << winA10 << std::endl;
73 std::cout <<
"B.1.0 - Project 1,0 -->" << winB10 << std::endl;
76 std::cout <<
"A.1.1 - Project 0,0 -->" << winA11 << std::endl;
78 std::cout <<
"B.1.1 - Project 0,0 -->" << winB11 << std::endl;
80 REQUIRE_MSG(
"A/B 0.0 Project 1,0 failure", winB00 == winA00);
81 REQUIRE_MSG(
"A/B 0.1 Project 0,0 failure", winB01 == winA01);
82 REQUIRE_MSG(
"A/B 1.0 Project 1,0 failure", winB10 == winA10);
83 REQUIRE_MSG(
"A/B 1.1 Project 0,0 failure", winB11 == winA11);
91TEST_CASE(
"Test 02 Project PMVMatrixToMatrix4f 2",
"[project][mat4f][linear_algebra][math]" ) {
93 const Recti viewport(0,0,10,10);
95 Vec3f winA00, winA01, winA10, winA11;
96 Vec3f winB00, winB01, winB10, winB11;
101 float mat4Mv_f16[16];
109 mat4Mv.
load( mat4Mv_f16 );
110 mat4P.
load( mat4P_f16 );
111 REQUIRE(
Mat4f(mat4Mv_f16) == mat4Mv);
112 REQUIRE(
Mat4f(mat4P_f16) == mat4P);
113 REQUIRE( m.
getMv() == mat4Mv);
114 REQUIRE( m.
getP() == mat4P);
117 std::cout <<
"A.0.0 - Project 1,0 -->" << winA00 << std::endl;
119 std::cout <<
"B.0.0 - Project 1,0 -->" << winB00 << std::endl;
122 std::cout <<
"A.0.1 - Project 0,0 -->" << winA01 << std::endl;
124 std::cout <<
"B.0.1 - Project 0,0 -->" << winB01 << std::endl;
126 m.
orthoP(0, 10, 0, 10, 1, -1);
127 std::cout <<
"MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale" << std::endl;
128 std::cout << m << std::endl;
133 mat4Mv.
load( mat4Mv_f16 );
134 mat4P.
load( mat4P_f16 );
135 REQUIRE(
Mat4f(mat4Mv_f16) == mat4Mv);
136 REQUIRE(
Mat4f(mat4P_f16) == mat4P);
137 REQUIRE( m.
getMv() == mat4Mv);
138 REQUIRE( m.
getP() == mat4P);
141 std::cout <<
"A.1.0 - Project 1,0 -->" << winA10 << std::endl;
143 std::cout <<
"B.1.0 - Project 1,0 -->" << winB10 << std::endl;
146 std::cout <<
"A.1.1 - Project 0,0 -->" << winA11 << std::endl;
148 std::cout <<
"B.1.1 - Project 0,0 -->" << winB11 << std::endl;
150 REQUIRE_MSG(
"A/B 0.0 Project 1,0 failure", winB00 == winA00);
151 REQUIRE_MSG(
"A/B 0.1 Project 0,0 failure", winB01 == winA01);
152 REQUIRE_MSG(
"A/B 1.0 Project 1,0 failure", winB10 == winA10);
153 REQUIRE_MSG(
"A/B 1.1 Project 0,0 failure", winB11 == winA11);
156TEST_CASE(
"Test 10 Project Matrix4f 1",
"[project][mat4f][linear_algebra][math]" ) {
158 Vec2f winExp( 297, 360 );
160 Recti viewport(0, 0, 1280, 720);
163 0.40000000596046450000f, 0.00000000000000000000f, 0.00000000000000000000f, 0.00000000000000000000f,
164 0.00000000000000000000f, 0.40000000596046450000f, 0.00000000000000000000f, 0.00000000000000000000f,
165 0.00000000000000000000f, 0.00000000000000000000f, 1.00000000000000000000f, 0.00000000000000000000f,
166 -0.09278385341167450000f, -0.00471283448860049250f, -0.20000000298023224000f, 1.00000000000000000000f });
169 1.35799503326416020000f, 0.00000000000000000000f, 0.00000000000000000000f, 0.00000000000000000000f,
170 0.00000000000000000000f, 2.41421341896057130000f, 0.00000000000000000000f, 0.00000000000000000000f,
171 0.00000000000000000000f, 0.00000000000000000000f, -1.00002861022949220000f, -1.00000000000000000000f,
172 0.00000000000000000000f, 0.00000000000000000000f, -0.20000286400318146000f, 0.00000000000000000000f });
174 Vec3f objPos(0.02945519052445888500f, 0.01178207620978355400f, -0.00499999988824129100f);
176 std::cout <<
"pMv" << std::endl;
177 std::cout << mat4Mv.toString(
"",
"%25.20f") << std::endl;
178 std::cout <<
"pP" << std::endl;
179 std::cout << mat4P.toString(
"",
"%25.20f") << std::endl;
182 std::cout <<
"B.0.0 - Project 1,0 -->" << winHas << std::endl;
184 REQUIRE_THAT( winExp.
x, Catch::Matchers::WithinAbs(std::round(winHas.
x),
EPSILON<float>) );
185 REQUIRE_THAT( winExp.
y, Catch::Matchers::WithinAbs(std::round(winHas.
y),
EPSILON<float>) );
188TEST_CASE(
"Test 11 Project Matrix4f 2",
"[project][mat4f][linear_algebra][math]" ) {
190 Vec2f winExp( 136, 360 );
192 Recti viewport(0, 0, 1280, 720);
196 0.40000000596046450000f, 0.00000000000000000000f, 0.00000000000000000000f, 0.00000000000000000000f,
197 0.00000000000000000000f, 0.40000000596046450000f, 0.00000000000000000000f, 0.00000000000000000000f,
198 0.00000000000000000000f, 0.00000000000000000000f, 1.00000000000000000000f, 0.00000000000000000000f,
199 -0.13065303862094880000f, -0.00471283448860049250f, -0.20000000298023224000f, 1.00000000000000000000f });
202 1.35799503326416020000f, 0.00000000000000000000f, 0.00000000000000000000f, 0.00000000000000000000f,
203 0.00000000000000000000f, 2.41421341896057130000f, 0.00000000000000000000f, 0.00000000000000000000f,
204 0.00000000000000000000f, 0.00000000000000000000f, -1.00002861022949220000f, -1.00000000000000000000f,
205 0.00000000000000000000f, 0.00000000000000000000f, -0.20000286400318146000f, 0.00000000000000000000f });
207 Vec3f objPos(0.02945519052445888500f, 0.01178207620978355400f, -0.00499999988824129100f);
209 std::cout <<
"pMv" << std::endl;
210 std::cout << mat4Mv.toString(
"",
"%25.20ff") << std::endl;
211 std::cout <<
"pP" << std::endl;
212 std::cout << mat4P.toString(
"",
"%25.20ff") << std::endl;
215 std::cout <<
"B.0.0 - Project 1,0 -->" << winHas << std::endl;
217 REQUIRE_THAT( winExp.
x, Catch::Matchers::WithinAbs(std::round(winHas.
x),
EPSILON<float>) );
218 REQUIRE_THAT( winExp.
y, Catch::Matchers::WithinAbs(std::round(winHas.
y),
EPSILON<float>) );
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 void orthoP(const float left, const float right, const float bottom, const float top, const float zNear, const float zFar) noexcept
Multiply the projection matrix with the orthogonal matrix.