diff --git a/math/float_types.hpp b/math/float_types.hpp index b1b852c..e88b9bb 100644 --- a/math/float_types.hpp +++ b/math/float_types.hpp @@ -1,11 +1,11 @@ #pragma once -#include "math/vec2.hpp" -#include "math/vec3.hpp" -#include "math/vec4.hpp" -#include "math/mat2x2.hpp" -#include "math/mat3x3.hpp" -#include "math/mat4x4.hpp" +#include "vec2.hpp" +#include "vec3.hpp" +#include "vec4.hpp" +#include "mat2x2.hpp" +#include "mat3x3.hpp" +#include "mat4x4.hpp" using vec2 = vec<2, float>; using vec3 = vec<3, float>; diff --git a/math/mat.hpp b/math/mat.hpp new file mode 100644 index 0000000..3fbeaea --- /dev/null +++ b/math/mat.hpp @@ -0,0 +1,26 @@ +#pragma once + +template +struct mat; + +template +inline constexpr typename mat::col_type +col(mat const& m, int c) +{ + typename mat::col_type v; + for (int r = 0; r < R; r++) { + v[r] = m[r][c]; + } + return v; +} + +template +inline constexpr vec<3, T> +col(mat const& m, int c) +{ + vec<3, T> v; + for (int r = 0; r < 3; r++) { + v[r] = m[r][c]; + } + return v; +} diff --git a/math/mat2x2.hpp b/math/mat2x2.hpp index da5f33c..8b8aec7 100644 --- a/math/mat2x2.hpp +++ b/math/mat2x2.hpp @@ -2,12 +2,10 @@ #include #include "vec2.hpp" - -template -struct mat; +#include "mat.hpp" // -// mat4x4 +// mat2x2 // template diff --git a/math/mat3x3.hpp b/math/mat3x3.hpp index 1117179..3bd64d9 100644 --- a/math/mat3x3.hpp +++ b/math/mat3x3.hpp @@ -2,9 +2,7 @@ #include #include "vec3.hpp" - -template -struct mat; +#include "mat.hpp" // // mat3x3 diff --git a/math/mat4x4.hpp b/math/mat4x4.hpp index 3008ef9..bcddf1f 100644 --- a/math/mat4x4.hpp +++ b/math/mat4x4.hpp @@ -2,9 +2,7 @@ #include #include "vec4.hpp" - -template -struct mat; +#include "mat.hpp" // // mat4x4 diff --git a/math/transform.hpp b/math/transform.hpp index 8e60b21..0e18fc4 100644 --- a/math/transform.hpp +++ b/math/transform.hpp @@ -1,5 +1,9 @@ #pragma once +#include "math.hpp" +#include "vec.hpp" +#include "mat.hpp" + template inline constexpr mat<4, 4, T> translate(vec<3, T> t) {