7static bool approxEq(
float x,
float y)
9 return fabsf(x - y) < 1.0e-5f;
11static constexpr bool approxEq(
const vec4& x,
const vec4&y)
13 return length2(x - y) < 1.0e-4f;
15static constexpr bool approxEq(
const mat4& x,
const mat4&y)
17 return norm2_2(x - y) < 1.0e-3f;
25 CHECK(S1 ==
mat4(
vec4(1, 0, 0, 0),
vec4(0, 2, 0, 0),
vec4(0, 0, 3, 0),
vec4(0, 0, 0, 1)));
26 CHECK(S2 ==
mat4(
vec4(2, 0, 0, 0),
vec4(0, 6, 0, 0),
vec4(0, 0, 12, 0),
vec4(0, 0, 0, 1)));
35 CHECK(S1 * S2 == S2 * S1);
45 CHECK(T1 ==
mat4(
vec4(1, 0, 0, 0),
vec4(0, 1, 0, 0),
vec4(0, 0, 1, 0),
vec4( 1, 2, 3, 1)));
46 CHECK(T2 ==
mat4(
vec4(1, 0, 0, 0),
vec4(0, 1, 0, 0),
vec4(0, 0, 1, 0),
vec4(-1, 3, 2, 1)));
51 CHECK((T1 * p) == (p +
vec4( 1, 2, 3, 0)));
53 CHECK((T2 * p) == (p +
vec4(-1, 3, 2, 0)));
56 CHECK(T1 * T2 == T2 * T1);
95 CHECK(approxEq(R0,
mat4(
vec4(1, 0, 0, 0),
vec4(0, 1, 0, 0),
vec4(0, 0, 1, 0),
vec4(0, 0, 0, 1))));
96 CHECK(approxEq(R90,
mat4(
vec4(1, 0, 0, 0),
vec4(0, 0, 1, 0),
vec4(0, -1, 0, 0),
vec4(0, 0, 0, 1))));
97 CHECK(approxEq(R180,
mat4(
vec4(1, 0, 0, 0),
vec4(0, -1, 0, 0),
vec4(0, 0, -1, 0),
vec4(0, 0, 0, 1))));
98 CHECK(approxEq(R270,
mat4(
vec4(1, 0, 0, 0),
vec4(0, 0, -1, 0),
vec4(0, 1, 0, 0),
vec4(0, 0, 0, 1))));
114 CHECK(approxEq(R0,
mat4(
vec4( 1, 0, 0, 0),
vec4(0, 1, 0, 0),
vec4( 0, 0, 1, 0),
vec4(0, 0, 0, 1))));
115 CHECK(approxEq(R90,
mat4(
vec4( 0, 0, -1, 0),
vec4(0, 1, 0, 0),
vec4( 1, 0, 0, 0),
vec4(0, 0, 0, 1))));
116 CHECK(approxEq(R180,
mat4(
vec4(-1, 0, 0, 0),
vec4(0, 1, 0, 0),
vec4( 0, 0, -1, 0),
vec4(0, 0, 0, 1))));
117 CHECK(approxEq(R270,
mat4(
vec4( 0, 0, 1, 0),
vec4(0, 1, 0, 0),
vec4(-1, 0, 0, 0),
vec4(0, 0, 0, 1))));
133 CHECK(approxEq(R0,
mat4(
vec4( 1, 0, 0, 0),
vec4( 0, 1, 0, 0),
vec4(0, 0, 1, 0),
vec4(0, 0, 0, 1))));
134 CHECK(approxEq(R90,
mat4(
vec4( 0, 1, 0, 0),
vec4(-1, 0, 0, 0),
vec4(0, 0, 1, 0),
vec4(0, 0, 0, 1))));
135 CHECK(approxEq(R180,
mat4(
vec4(-1, 0, 0, 0),
vec4( 0, -1, 0, 0),
vec4(0, 0, 1, 0),
vec4(0, 0, 0, 1))));
136 CHECK(approxEq(R270,
mat4(
vec4( 0, -1, 0, 0),
vec4( 1, 0, 0, 0),
vec4(0, 0, 1, 0),
vec4(0, 0, 0, 1))));
147 SECTION(
"arbitrary axis") {
152 mat4 rot3 = Rx90 * rot1;
153 CHECK(approxEq(rot2, rot3));
156 CHECK(approxEq(q,
vec4(-1.05647f, 0.231566f, 2.19778f, 1.0f)));
167 CHECK(approxEq(O1, O2));
169 vec4(0.0f, -0.00416667f, 0.0f, 0.0f),
170 vec4(0.0f, 0.0f, -1.0f, 0.0f),
171 vec4(-1.0f, 1.0f, 0.0f, 1.0f))));
178 vec4(0.0f, 0.00416667f, 0.0f, 0.0f),
179 vec4(1.0f, 1.0f, 0.0f, -1.0f),
180 vec4(0.0f, 0.0f, 1.0f, 0.0f))));
190void test_scale(
float x,
float y,
float z,
mat4& A)
194void test_scale(
mat4& A,
float x,
float y,
float z,
mat4& B)
199void test_translate(
float x,
float y,
float z,
mat4& A)
203void test_translate(
mat4& A,
float x,
float y,
float z,
mat4& B)
208void test_rotate(
float a,
float x,
float y,
float z,
mat4& A)
213void test_ortho(
float l,
float r,
float b,
float t,
float n,
float f,
mat4& A)
218void test_frustum(
float l,
float r,
float b,
float t,
float n,
float f,
mat4& A)
constexpr T norm2_2(const matMxN< M, N, T > &A)
mat4 rotateZ(float angle)
mat4 rotate(float angle, const vec3 &axis)
mat4 rotateY(float angle)
mat4 rotateX(float angle)
constexpr mat4 ortho(float left, float right, float bottom, float top, float nearVal, float farVal)
matMxN< 4, 4, float > mat4
T length(const vecN< N, T > &x)
constexpr T length2(const vecN< N, T > &x)
constexpr matMxN< N, M, T > transpose(const matMxN< M, N, T > &A)
constexpr matMxN< 2, 2, T > inverse(const matMxN< 2, 2, T > &A)
constexpr mat4 frustum(float left, float right, float bottom, float top, float nearVal, float farVal)
vecN< N, T > normalize(const vecN< N, T > &x)
constexpr mat4 translate(const vec3 &xyz)
constexpr mat4 scale(const vec3 &xyz)
std::array< const EDStorage, 4 > A