openMSX
Functions | Variables
gl_vec.cc File Reference
#include "catch.hpp"
#include "gl_vec.hh"
Include dependency graph for gl_vec.cc:

Go to the source code of this file.

Functions

template<typename T >
bool approxEq (T x, T y)
 
template<int N, typename T >
bool approxEq (const vecN< N, T > &x, const vecN< N, T > &y)
 
 TEST_CASE ("gl_vec: rsqrt")
 
 TEST_CASE ("gl_vec: radians, degrees")
 
 TEST_CASE ("gl_vec: constructors")
 
 TEST_CASE ("gl_vec: modify elements")
 
 CHECK (vec2(1, 2) !=vec2(1, 4))
 
 CHECK (ivec2(1, 2)==ivec2(1, 2))
 
 CHECK (ivec2(1, 2) !=ivec2(1, 4))
 
 CHECK (vec3(1, 2, 3)==vec3(1, 2, 3))
 
 CHECK (vec3(1, 2, 3) !=vec3(1, 2, 4))
 
 CHECK (ivec3(1, 2, 3)==ivec3(1, 2, 3))
 
 CHECK (ivec3(1, 2, 3) !=ivec3(1, 2, 4))
 
 CHECK (vec4(1, 2, 3, 4)==vec4(1, 2, 3, 4))
 
 CHECK (vec4(1, 2, 3, 4) !=vec4(1, 2, 4, 4))
 
 CHECK (ivec4(1, 2, 3, 4)==ivec4(1, 2, 3, 4))
 
 CHECK (ivec4(1, 2, 3, 4) !=ivec4(1, 2, 4, 4))
 
 TEST_CASE ("gl_vec: copy constructor, assignment")
 
 TEST_CASE ("gl_vec: construct from larger vector")
 
 TEST_CASE ("gl_vec: vector add")
 
 TEST_CASE ("gl_vec: vector subtract")
 
 TEST_CASE ("gl_vec: vector negate")
 
 TEST_CASE ("gl_vec: component-wise vector multiplication")
 
 CHECK (approxEq(recip(vec4(4, 2, 0.5, 1)), vec4(0.25, 0.5, 2, 1)))
 
 CHECK ((v3/2.0f)==vec3(0, 0.5f, -2))
 
 CHECK ((6.0f/w3)==vec3(-6, -3, 3))
 
 CHECK ((v3/w3)==vec3(0, -0.5f, -2))
 
 CHECK (approxEq((v4/-2.0f), vec4(-1, -0.5f, 2, 1.5f)))
 
 CHECK (approxEq((6.0f/w4), vec4(-6, 3, 3, -1)))
 
 CHECK (approxEq((v4/w4), vec4(-2, 0.5f, -2, 0.5f)))
 
 TEST_CASE ("gl_vec: component-wise min/max")
 
 TEST_CASE ("gl_vec: minimum component within a vector")
 
 TEST_CASE ("gl_vec: clamp")
 
 TEST_CASE ("gl_vec: sum of vector components")
 
 TEST_CASE ("gl_vec: dot product")
 
 CHECK (cross(ivec3(4, -3, 2), ivec3(-1, 3, 2))==ivec3(-12, -10, 9))
 
 CHECK (length2(ivec3(4, -3, 2))==29)
 
 CHECK (length2(vec4(4, -3, 2, -1))==30.0f)
 
 CHECK (length2(ivec4(4, -3, 2, -1))==30)
 
 TEST_CASE ("gl_vec: vector length (2-norm), (only floating point)")
 
 TEST_CASE ("gl_vec: vector normalization, only floating point")
 
 TEST_CASE ("gl_vec: round")
 
 TEST_CASE ("gl_vec: trunc")
 

Variables

vec3 w3 (-1, -2, 2)
 
vec4 v4 (2, 1, -4, -3)
 
vec4 w4 (-1, 2, 2, -6)
 

Function Documentation

◆ approxEq() [1/2]

template<typename T >
bool approxEq ( x,
y 
)

Definition at line 8 of file gl_vec.cc.

◆ approxEq() [2/2]

template<int N, typename T >
bool approxEq ( const vecN< N, T > &  x,
const vecN< N, T > &  y 
)

Definition at line 13 of file gl_vec.cc.

◆ CHECK() [1/22]

CHECK ( vec2(1, 2) !  = vec2(1, 4))

◆ CHECK() [2/22]

CHECK ( ivec2(1, 2)  = =ivec2(1, 2))

◆ CHECK() [3/22]

CHECK ( ivec2(1, 2) !  = ivec2(1, 4))

◆ CHECK() [4/22]

CHECK ( vec3(1, 2, 3)  = =vec3(1, 2, 3))

◆ CHECK() [5/22]

CHECK ( vec3(1, 2, 3) !  = vec3(1, 2, 4))

◆ CHECK() [6/22]

CHECK ( ivec3(1, 2, 3)  = =ivec3(1, 2, 3))

◆ CHECK() [7/22]

CHECK ( ivec3(1, 2, 3) !  = ivec3(1, 2, 4))

◆ CHECK() [8/22]

CHECK ( vec4(1, 2, 3, 4)  = =vec4(1, 2, 3, 4))

◆ CHECK() [9/22]

CHECK ( vec4(1, 2, 3, 4) !  = vec4(1, 2, 4, 4))

◆ CHECK() [10/22]

CHECK ( ivec4(1, 2, 3, 4)  = =ivec4(1, 2, 3, 4))

◆ CHECK() [11/22]

CHECK ( ivec4(1, 2, 3, 4) !  = ivec4(1, 2, 4, 4))

◆ CHECK() [12/22]

CHECK ( approxEq(recip(vec4(4, 2, 0.5, 1)), vec4(0.25, 0.5, 2, 1))  )

◆ CHECK() [13/22]

CHECK ( (v3/2.0f)  = =vec3(0, 0.5f, -2))

◆ CHECK() [14/22]

CHECK ( (6.0f/w3)  = =vec3(-6, -3, 3))

◆ CHECK() [15/22]

CHECK ( (v3/w3 = =vec3(0, -0.5f, -2))

◆ CHECK() [16/22]

CHECK ( approxEq((v4/-2.0f), vec4(-1, -0.5f, 2, 1.5f))  )

◆ CHECK() [17/22]

CHECK ( approxEq((6.0f/w4), vec4(-6, 3, 3, -1))  )

◆ CHECK() [18/22]

CHECK ( approxEq((v4/w4), vec4(-2, 0.5f, -2, 0.5f))  )

◆ CHECK() [19/22]

CHECK ( cross(ivec3(4, -3, 2), ivec3(-1, 3, 2))  = =ivec3(-12, -10, 9))

◆ CHECK() [20/22]

CHECK ( length2(ivec3(4, -3, 2))  = =29)

◆ CHECK() [21/22]

CHECK ( length2(vec4(4, -3, 2, -1))  = =30.0f)

◆ CHECK() [22/22]

CHECK ( length2(ivec4(4, -3, 2, -1))  = =30)

◆ TEST_CASE() [1/19]

TEST_CASE ( "gl_vec: rsqrt"  )

Definition at line 19 of file gl_vec.cc.

◆ TEST_CASE() [2/19]

TEST_CASE ( "gl_vec:  radians,
degrees"   
)

Definition at line 25 of file gl_vec.cc.

◆ TEST_CASE() [3/19]

TEST_CASE ( "gl_vec: constructors"  )

Definition at line 39 of file gl_vec.cc.

◆ TEST_CASE() [4/19]

TEST_CASE ( "gl_vec: modify elements"  )

Definition at line 181 of file gl_vec.cc.

◆ TEST_CASE() [5/19]

TEST_CASE ( "gl_vec: copy  constructor,
assignment"   
)

Definition at line 245 of file gl_vec.cc.

◆ TEST_CASE() [6/19]

TEST_CASE ( "gl_vec: construct from larger vector"  )

Definition at line 284 of file gl_vec.cc.

◆ TEST_CASE() [7/19]

TEST_CASE ( "gl_vec: vector add"  )

Definition at line 303 of file gl_vec.cc.

◆ TEST_CASE() [8/19]

TEST_CASE ( "gl_vec: vector subtract"  )

Definition at line 322 of file gl_vec.cc.

◆ TEST_CASE() [9/19]

TEST_CASE ( "gl_vec: vector negate"  )

Definition at line 341 of file gl_vec.cc.

◆ TEST_CASE() [10/19]

TEST_CASE ( "gl_vec: component-wise vector multiplication"  )

Definition at line 349 of file gl_vec.cc.

◆ TEST_CASE() [11/19]

TEST_CASE ( "gl_vec: component-wise min/max"  )

Definition at line 403 of file gl_vec.cc.

◆ TEST_CASE() [12/19]

TEST_CASE ( "gl_vec: minimum component within a vector"  )

Definition at line 416 of file gl_vec.cc.

◆ TEST_CASE() [13/19]

TEST_CASE ( "gl_vec: clamp"  )

Definition at line 424 of file gl_vec.cc.

◆ TEST_CASE() [14/19]

TEST_CASE ( "gl_vec: sum of vector components"  )

Definition at line 436 of file gl_vec.cc.

◆ TEST_CASE() [15/19]

TEST_CASE ( "gl_vec: dot product"  )

Definition at line 447 of file gl_vec.cc.

◆ TEST_CASE() [16/19]

TEST_CASE ( "gl_vec: vector length   2-norm,
(only floating point)"   
)

Definition at line 471 of file gl_vec.cc.

◆ TEST_CASE() [17/19]

TEST_CASE ( "gl_vec: vector  normalization,
only floating point"   
)

Definition at line 477 of file gl_vec.cc.

◆ TEST_CASE() [18/19]

TEST_CASE ( "gl_vec: round"  )

Definition at line 483 of file gl_vec.cc.

◆ TEST_CASE() [19/19]

TEST_CASE ( "gl_vec: trunc"  )

Definition at line 491 of file gl_vec.cc.

Variable Documentation

◆ v4

vec4 v4(2, 1, -4, -3)

◆ w3

vec3 w3(-1, -2, 2)
Initial value:
{
vec3 v3( 0, 1, -4)

◆ w4

vec4 w4(-1, 2, 2, -6)