math/mat: add col function
This commit is contained in:
parent
13200501ef
commit
284310244c
@ -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>;
|
||||
|
26
math/mat.hpp
Normal file
26
math/mat.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
template <int R, int C, typename T>
|
||||
struct mat;
|
||||
|
||||
template <int R, int C, typename T>
|
||||
inline constexpr typename mat<R, C, T>::col_type
|
||||
col(mat<R, C, T> const& m, int c)
|
||||
{
|
||||
typename mat<R, C, T>::col_type v;
|
||||
for (int r = 0; r < R; r++) {
|
||||
v[r] = m[r][c];
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
template <int R, typename T>
|
||||
inline constexpr vec<3, T>
|
||||
col(mat<R, 4, T> const& m, int c)
|
||||
{
|
||||
vec<3, T> v;
|
||||
for (int r = 0; r < 3; r++) {
|
||||
v[r] = m[r][c];
|
||||
}
|
||||
return v;
|
||||
}
|
@ -2,12 +2,10 @@
|
||||
|
||||
#include <utility>
|
||||
#include "vec2.hpp"
|
||||
|
||||
template <int R, int C, typename T>
|
||||
struct mat;
|
||||
#include "mat.hpp"
|
||||
|
||||
//
|
||||
// mat4x4
|
||||
// mat2x2
|
||||
//
|
||||
|
||||
template <typename T>
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
#include <utility>
|
||||
#include "vec3.hpp"
|
||||
|
||||
template <int R, int C, typename T>
|
||||
struct mat;
|
||||
#include "mat.hpp"
|
||||
|
||||
//
|
||||
// mat3x3
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
#include <utility>
|
||||
#include "vec4.hpp"
|
||||
|
||||
template <int R, int C, typename T>
|
||||
struct mat;
|
||||
#include "mat.hpp"
|
||||
|
||||
//
|
||||
// mat4x4
|
||||
|
@ -1,5 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "math.hpp"
|
||||
#include "vec.hpp"
|
||||
#include "mat.hpp"
|
||||
|
||||
template<typename T>
|
||||
inline constexpr mat<4, 4, T> translate(vec<3, T> t)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user