44TEST_CASE(
"Test 01 Project PMVMatrixToMatrix4f",
"[project][mat4f][linear_algebra][math]" ) {
46 const Recti viewport(0,0,10,10);
48 Vec3f winA00, winA01, winA10, winA11;
49 Vec3f winB00, winB01, winB10, winB11;
57 std::cout <<
"A.0.0 - Project 1,0 -->" << winA00 << std::endl;
59 std::cout <<
"B.0.0 - Project 1,0 -->" << winB00 << std::endl;
62 std::cout <<
"A.0.1 - Project 0,0 -->" << winA01 << std::endl;
64 std::cout <<
"B.0.1 - Project 0,0 -->" << winB01 << std::endl;
66 m.
orthoP(0, 10, 0, 10, 1, -1);
67 std::cout <<
"MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale" << std::endl;
68 std::cout << m << std::endl;
70 std::cout << mat4PMv.
toString(
"mat4PMv",
"%10.5f") << std::endl;
73 std::cout <<
"A.1.0 - Project 1,0 -->" << winA10 << std::endl;
75 std::cout <<
"B.1.0 - Project 1,0 -->" << winB10 << std::endl;
78 std::cout <<
"A.1.1 - Project 0,0 -->" << winA11 << std::endl;
80 std::cout <<
"B.1.1 - Project 0,0 -->" << winB11 << std::endl;
82 REQUIRE_MSG(
"A/B 0.0 Project 1,0 failure", winB00 == winA00);
83 REQUIRE_MSG(
"A/B 0.1 Project 0,0 failure", winB01 == winA01);
84 REQUIRE_MSG(
"A/B 1.0 Project 1,0 failure", winB10 == winA10);
85 REQUIRE_MSG(
"A/B 1.1 Project 0,0 failure", winB11 == winA11);
93TEST_CASE(
"Test 02 Project PMVMatrixToMatrix4f 2",
"[project][mat4f][linear_algebra][math]" ) {
95 const Recti viewport(0,0,10,10);
97 Vec3f winA00, winA01, winA10, winA11;
98 Vec3f winB00, winB01, winB10, winB11;
103 float mat4Mv_f16[16];
111 mat4Mv.
load( mat4Mv_f16 );
112 mat4P.
load( mat4P_f16 );
113 REQUIRE(
Mat4f(mat4Mv_f16) == mat4Mv);
114 REQUIRE(
Mat4f(mat4P_f16) == mat4P);
115 REQUIRE( m.
getMv() == mat4Mv);
116 REQUIRE( m.
getP() == mat4P);
119 std::cout <<
"A.0.0 - Project 1,0 -->" << winA00 << std::endl;
121 std::cout <<
"B.0.0 - Project 1,0 -->" << winB00 << std::endl;
124 std::cout <<
"A.0.1 - Project 0,0 -->" << winA01 << std::endl;
126 std::cout <<
"B.0.1 - Project 0,0 -->" << winB01 << std::endl;
128 m.
orthoP(0, 10, 0, 10, 1, -1);
129 std::cout <<
"MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale" << std::endl;
130 std::cout << m << std::endl;
135 mat4Mv.
load( mat4Mv_f16 );
136 mat4P.
load( mat4P_f16 );
137 REQUIRE(
Mat4f(mat4Mv_f16) == mat4Mv);
138 REQUIRE(
Mat4f(mat4P_f16) == mat4P);
139 REQUIRE( m.
getMv() == mat4Mv);
140 REQUIRE( m.
getP() == mat4P);
143 std::cout <<
"A.1.0 - Project 1,0 -->" << winA10 << std::endl;
145 std::cout <<
"B.1.0 - Project 1,0 -->" << winB10 << std::endl;
148 std::cout <<
"A.1.1 - Project 0,0 -->" << winA11 << std::endl;
150 std::cout <<
"B.1.1 - Project 0,0 -->" << winB11 << std::endl;
152 REQUIRE_MSG(
"A/B 0.0 Project 1,0 failure", winB00 == winA00);
153 REQUIRE_MSG(
"A/B 0.1 Project 0,0 failure", winB01 == winA01);
154 REQUIRE_MSG(
"A/B 1.0 Project 1,0 failure", winB10 == winA10);
155 REQUIRE_MSG(
"A/B 1.1 Project 0,0 failure", winB11 == winA11);
158TEST_CASE(
"Test 10 Project Matrix4f 1",
"[project][mat4f][linear_algebra][math]" ) {
160 Vec2f winExp( 297, 360 );
162 Recti viewport(0, 0, 1280, 720);
165 0.40000000596046450000f, 0.00000000000000000000f, 0.00000000000000000000f, 0.00000000000000000000f,
166 0.00000000000000000000f, 0.40000000596046450000f, 0.00000000000000000000f, 0.00000000000000000000f,
167 0.00000000000000000000f, 0.00000000000000000000f, 1.00000000000000000000f, 0.00000000000000000000f,
168 -0.09278385341167450000f, -0.00471283448860049250f, -0.20000000298023224000f, 1.00000000000000000000f });
171 1.35799503326416020000f, 0.00000000000000000000f, 0.00000000000000000000f, 0.00000000000000000000f,
172 0.00000000000000000000f, 2.41421341896057130000f, 0.00000000000000000000f, 0.00000000000000000000f,
173 0.00000000000000000000f, 0.00000000000000000000f, -1.00002861022949220000f, -1.00000000000000000000f,
174 0.00000000000000000000f, 0.00000000000000000000f, -0.20000286400318146000f, 0.00000000000000000000f });
176 Vec3f objPos(0.02945519052445888500f, 0.01178207620978355400f, -0.00499999988824129100f);
178 std::cout <<
"pMv" << std::endl;
179 std::cout << mat4Mv.toString(
"",
"%25.20f") << std::endl;
180 std::cout <<
"pP" << std::endl;
181 std::cout << mat4P.toString(
"",
"%25.20f") << std::endl;
184 std::cout <<
"B.0.0 - Project 1,0 -->" << winHas << std::endl;
186 REQUIRE_THAT( winExp.
x, Catch::Matchers::WithinAbs(std::round(winHas.
x),
EPSILON) );
187 REQUIRE_THAT( winExp.
y, Catch::Matchers::WithinAbs(std::round(winHas.
y),
EPSILON) );
190TEST_CASE(
"Test 11 Project Matrix4f 2",
"[project][mat4f][linear_algebra][math]" ) {
192 Vec2f winExp( 136, 360 );
194 Recti viewport(0, 0, 1280, 720);
198 0.40000000596046450000f, 0.00000000000000000000f, 0.00000000000000000000f, 0.00000000000000000000f,
199 0.00000000000000000000f, 0.40000000596046450000f, 0.00000000000000000000f, 0.00000000000000000000f,
200 0.00000000000000000000f, 0.00000000000000000000f, 1.00000000000000000000f, 0.00000000000000000000f,
201 -0.13065303862094880000f, -0.00471283448860049250f, -0.20000000298023224000f, 1.00000000000000000000f });
204 1.35799503326416020000f, 0.00000000000000000000f, 0.00000000000000000000f, 0.00000000000000000000f,
205 0.00000000000000000000f, 2.41421341896057130000f, 0.00000000000000000000f, 0.00000000000000000000f,
206 0.00000000000000000000f, 0.00000000000000000000f, -1.00002861022949220000f, -1.00000000000000000000f,
207 0.00000000000000000000f, 0.00000000000000000000f, -0.20000286400318146000f, 0.00000000000000000000f });
209 Vec3f objPos(0.02945519052445888500f, 0.01178207620978355400f, -0.00499999988824129100f);
211 std::cout <<
"pMv" << std::endl;
212 std::cout << mat4Mv.toString(
"",
"%25.20ff") << std::endl;
213 std::cout <<
"pP" << std::endl;
214 std::cout << mat4P.toString(
"",
"%25.20ff") << std::endl;
217 std::cout <<
"B.0.0 - Project 1,0 -->" << winHas << std::endl;
219 REQUIRE_THAT( winExp.
x, Catch::Matchers::WithinAbs(std::round(winHas.
x),
EPSILON) );
220 REQUIRE_THAT( winExp.
y, Catch::Matchers::WithinAbs(std::round(winHas.
y),
EPSILON) );
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.