Simple program for testing your math library.
Matrices should be stored in row major order.
Add your class files (vec3.h, vec4.h, mat4.h) to the root directory and add them to the list of files located in CMakeLists.txt
Build and run test by executing the run_test.bat file, or by using CMake GUI.
Make sure to implement according to the following class descriptions, or modify the test so that it uses your own naming convention and coding style.
name: type
= variable or parameter/argumentf32
= 32 bit floating point numberconst&
= const reference+
= public variable or method-
= private variable or methodname(args) [const]:return_type
= function or method, const denotes the method should not modify the object.
+x: f32
+y: f32
+z: f32
+vec3() // zero length vector
+vec3(x: f32 const, y: f32 const, z: f32 const)
+vec3(v: vec3 const&)
+operator=(rhs: vec3 const&):vec3&
+operator-() const:vec3
+operator+(rhs: vec3 const&) const:vec3
+operator+=(rhs: vec3 const&):vec3&
+operator-(rhs: vec3 const&) const:vec3
+operator-=(rhs: vec3 const&):vec3&
+operator*=(scalar: f32 const):vec3&
+operator*(scalar: f32 const) const:vec3
+operator==(rhs: vec3 const&) const:bool
+operator!=(rhs: vec3 const&) const:bool
+operator[](i: ui32 const):f32& // range [0,2]
+operator[](i: ui32 const) const:f32 const& // range [0,2]
dot(a: vec3 const&, b: vec3 const&):f32
length(v: vec3 const&):f32
cross(a: vec3 const&, b: vec3 const&):vec3
normalize(v: vec3 const&):vec3
+x: f32
+y: f32
+z: f32
+w: f32
+vec4() // zero length vector
+vec4(x: f32 const, y: f32 const, z: f32 const, w: f32 const)
+vec4(v: vec4 const&)
+operator=(rhs: vec4 const&):vec4&
+operator-() const:vec4
+operator+(rhs: vec4 const&) const:vec4
+operator+=(rhs: vec4 const&):vec4&
+operator-(rhs: vec4 const&) const:vec4
+operator-=(rhs: vec4 const&):vec4&
+operator*=(scalar: f32 const):vec4&
+operator*(scalar: f32 const) const:vec4
+operator==(rhs: vec4 const&) const:bool
+operator!=(rhs: vec4 const&) const:bool
+operator[](i: ui32 const):f32& // range [0,3]
+operator[](i: ui32 const) const:f32 const& // range [0,3]
dot(a: vec4 const&, b: vec4 const&):f32
length(v: vec4 const&):f32
normalize(v: vec4 const&):vec4
+m: vec4[4]
+mat4() // identity matrix
+mat4(r0: vec4 const&, r1: vec4 const&, r2: vec4 const&, r3: vec4 const&)
+mat4(m: mat4 const&)
+operator=(rhs: mat4 const&):mat4&
+operator*(rhs: mat4 const&) const:mat4
+operator*(rhs: vec4 const&) const:vec4
+operator==(rhs: mat4 const&) const:bool
+operator!=(rhs: mat4 const&) const:bool
+operator[](i: ui32 const):vec4& // range [0,3]
+operator[](i: ui32 const) const:vec4 const& // range [0,3]
determinant(m: mat4 const&):f32
inverse(m: mat4 const&):mat4 // returns identity upon failure
transpose(m: mat4 const&):mat4
rotationx(rad: f32 const):mat4 // radians
rotationy(rad: f32 const):mat4
rotationz(rad: f32 const):mat4
rotationaxis(v: vec3 const&, rad: f32 const):mat4
perspective(fovy: f32 const, aspect: f32 const, near: f32 const, far: f32 const): mat4 // fovy expressed in radians
lookat(eye: vec3 const&, at: vec3 const&, up: vec3 const&): mat4
Add #define TEST_VIEW_PERSPECTIVE
to top of main.cc to test perspective and view matrix functions.
Add #define USE_LH
to configure perspective and view to be left-handed instead of right-handed