9template<std::
floating_po
int T>
12 return std::abs(x - y) < T(1.0e-5);
14template<
int N, std::
floating_po
int T>
17 return length2(x - y) < T(1.0e-4);
43 SECTION(
"default constructor") {
71 SECTION(
"broadcast constructor") {
99 SECTION(
"per-element constructor") {
127 SECTION(
"construct from smaller vectors/scalar") {
212 v4[0] = 9;
v4[2] = 8;
218 i4[0] = 9;
i4[2] = 8;
252 v[0] = 9;
CHECK(v != w);
253 w = v;
CHECK(v == w);
258 v[1] = 9;
CHECK(v != w);
259 w = v;
CHECK(v == w);
264 v[2] = 8;
CHECK(v != w);
265 w = v;
CHECK(v == w);
270 v[1] = 8;
CHECK(v != w);
271 w = v;
CHECK(v == w);
276 v[3] = 0;
CHECK(v != w);
277 w = v;
CHECK(v == w);
282 v[0] = 1;
CHECK(v != w);
283 w = v;
CHECK(v == w);
352TEST_CASE(
"gl_vec: component-wise vector multiplication")
385TEST_CASE(
"gl_vec: reciprocal (only floating point)")
391TEST_CASE(
"gl_vec: component-wise division (only floating point)")
410 CHECK(
min(
vec4(1, -2, 5, -7),
vec4(0, 2, -4, -3)) ==
vec4(0, -2, -4, -7));
411 CHECK(
min(
ivec4(1, -2, 5, -7),
ivec4(0, 2, -4, -3)) ==
ivec4(0, -2, -4, -7));
415 CHECK(
max(
vec4(1, -2, 5, -7),
vec4(0, 2, -4, -3)) ==
vec4(1, 2, 5, -3));
416 CHECK(
max(
ivec4(1, -2, 5, -7),
ivec4(0, 2, -4, -3)) ==
ivec4(1, 2, 5, -3));
428 CHECK(
clamp(
vec3(2, 3, 4),
vec3(0, 4, -4),
vec3(4, 7, 0)) ==
vec3(2, 4, 0));
429 CHECK(
clamp(
ivec3(2, 3, 4),
ivec3(0, 4, -4),
ivec3(4, 7, 0)) ==
ivec3(2, 4, 0));
430 CHECK(
clamp(
vec4(4, 2, 7, 1),
vec4(0, 3, 2, 1),
vec4(4, 6, 8, 3)) ==
vec4(4, 3, 7, 1));
431 CHECK(
clamp(
ivec4(4, 2, 7, 1),
ivec4(0, 3, 2, 1),
ivec4(4, 6, 8, 3)) ==
ivec4(4, 3, 7, 1));
461TEST_CASE(
"gl_vec: cross product (only for vectors of length 3)")
467TEST_CASE(
"gl_vec: vector length squared (2-norm squared)")
474TEST_CASE(
"gl_vec: vector length (2-norm), (only floating point)")
480TEST_CASE(
"gl_vec: vector normalization, only floating point")
510void test_constr(
vec4& z)
514void test_constr(
float x,
vec4& z)
518void test_constr(
float a,
float b,
float c,
float d,
vec4& z)
520 z =
vec4(a, b, c, d);
523void test_change0(
float x,
vec4& z)
527void test_change2(
float x,
vec4& z)
532void test_extract0(
const vec4& x,
float& z)
536void test_extract2(
const vec4& x,
float& z)
541bool test_equal(
const vec4& x,
const vec4& y)
545bool test_not_equal(
const vec4& x,
const vec4& y)
554void test_add(
vec4& x,
const vec4& y)
559void test_negate(
const vec4& x,
vec4& y)
568void test_mul(
float x,
const vec4& y,
vec4& z)
577void test_div(
float x,
const vec4& y,
vec4& z)
581void test_div(
const vec4& x,
float y,
vec4& z)
586void test_sum(
const vec4& x,
float& y)
590void test_sum_broadcast(
const vec4& x,
vec4& y)
595void test_dot(
const vec4& x,
const vec4& y,
float& z)
599void test_dot_broadcast(
const vec4& x,
const vec4& y,
vec4& z)
604void test_length2(
const vec4& x,
float& y)
609void test_length(
const vec4& x,
float& y)
614void test_normalize(
const vec4& x,
vec4& y)
619void test_recip(
const vec4& x,
vec4& y)
625void test_constr(
vec3& z)
629void test_constr(
float x,
vec3& z)
633void test_constr(
float a,
float b,
float c,
vec3& z)
642void test_change0(
float x,
vec3& z)
646void test_change2(
float x,
vec3& z)
651void test_extract0(
const vec3& x,
float& z)
655void test_extract2(
const vec3& x,
float& z)
660bool test_equal(
const vec3& x,
const vec3& y)
664bool test_not_equal(
const vec3& x,
const vec3& y)
673void test_add(
vec3& x,
const vec3& y)
678void test_negate(
const vec3& x,
vec3& y)
687void test_mul(
float x,
const vec3& y,
vec3& z)
696void test_div(
float x,
const vec3& y,
vec3& z)
700void test_div(
const vec3& x,
float y,
vec3& z)
725void test_clamp(
const vec3& x,
float y,
float z,
vec3& w)
730void test_clamp(
const vec4& x,
float y,
float z,
vec4& w)
735void test_clamp(
const vec4& x,
vec4& y)
737 y =
clamp(x, 0.0f, 1.0f);
740void test_sum(
const vec3& x,
float& y)
745void test_dot(
const vec3& x,
const vec3& y,
float& z)
750void test_length2(
const vec3& x,
float& y)
755void test_length(
const vec3& x,
float& y)
760void test_normalize(
const vec3& x,
vec3& y)
imat4 k4(ivec4(1, 2, 3, 4), ivec4(3, 4, 0, 6), ivec4(5, 6, 7, 8), ivec4(7, 8, 9, 0))
imat4 i4(ivec4(1, 2, 3, 4), ivec4(3, 4, 5, 6), ivec4(5, 6, 7, 8), ivec4(7, 8, 9, 0))
imat4 j4(ivec4(1, 0, 3, 4), ivec4(3, 4, 5, 6), ivec4(5, 6, 7, 8), ivec4(7, 8, 9, 0))
imat3 j3(ivec3(1, 2, 3), ivec3(4, 5, 6), ivec3(7, 0, 9))
imat3 i3(ivec3(1, 2, 3), ivec3(4, 5, 6), ivec3(7, 8, 9))
CHECK(vec2(1, 2) !=vec2(1, 4))
TEST_CASE("gl_vec: rsqrt")
constexpr double round(double x)
constexpr vecN< N, T > recip(const vecN< N, T > &x)
constexpr vecN< 3, T > cross(const vecN< 3, T > &x, const vecN< 3, T > &y)
constexpr T min_component(const vecN< N, T > &x)
constexpr T dot(const vecN< N, T > &x, const vecN< N, T > &y)
constexpr vecN< N, int > trunc(const vecN< N, T > &x)
T length(const vecN< N, T > &x)
constexpr T length2(const vecN< N, T > &x)
constexpr vecN< N, T > min(const vecN< N, T > &x, const vecN< N, T > &y)
constexpr vecN< N, T > dot_broadcast(const vecN< N, T > &x, const vecN< N, T > &y)
constexpr vecN< N, T > sum_broadcast(const vecN< N, T > &x)
vecN< N, T > normalize(const vecN< N, T > &x)
constexpr vecN< N, T > max(const vecN< N, T > &x, const vecN< N, T > &y)
constexpr vecN< N, T > clamp(const vecN< N, T > &x, const vecN< N, T > &minVal, const vecN< N, T > &maxVal)
auto sum(InputRange &&range, Proj proj={})