15 #include <vsg/maths/vec3.h>
35 constexpr
explicit t_mat3(value_type v) :
40 constexpr
t_mat3(value_type v0, value_type v1, value_type v2,
41 value_type v3, value_type v4, value_type v5,
42 value_type v6, value_type v7, value_type v8) :
49 constexpr
explicit t_mat3(value_type v[9]) :
50 value{{v[0], v[1], v[2]},
52 {v[6], v[7], v[8]}} {}
69 constexpr std::size_t size()
const {
return 9; }
70 constexpr std::size_t columns()
const {
return 3; }
71 constexpr std::size_t rows()
const {
return 3; }
73 column_type& operator[](std::size_t c) {
return value[c]; }
74 const column_type& operator[](std::size_t c)
const {
return value[c]; }
76 value_type& operator()(std::size_t c, std::size_t r) {
return value[c][r]; }
77 value_type operator()(std::size_t c, std::size_t r)
const {
return value[c][r]; }
88 void set(value_type v0, value_type v1, value_type v2,
89 value_type v3, value_type v4, value_type v5,
90 value_type v6, value_type v7, value_type v8)
92 value[0].set(v0, v1, v2);
93 value[1].set(v3, v4, v5);
94 value[2].set(v6, v7, v8);
97 T* data() {
return value[0].data(); }
98 const T* data()
const {
return value[0].data(); }
110 return lhs.value[0] == rhs.value[0] &&
111 lhs.value[1] == rhs.value[1] &&
112 lhs.value[2] == rhs.value[2];
116 bool operator!=(
const t_mat3<T>& lhs,
const t_mat3<T>& rhs)
118 return lhs.value[0] != rhs.value[0] ||
119 lhs.value[1] != rhs.value[1] ||
120 lhs.value[2] != rhs.value[2];
124 bool operator<(
const t_mat3<T>& lhs,
const t_mat3<T>& rhs)
126 if (lhs.value[0] < rhs.value[0])
return true;
127 if (rhs.value[0] < lhs.value[0])
return false;
128 if (lhs.value[1] < rhs.value[1])
return true;
129 if (rhs.value[1] < lhs.value[1])
return false;
130 return lhs.value[2] < rhs.value[2];
134 T dot(
const t_mat3<T>& lhs,
const t_mat3<T>& rhs,
int c,
int r)
136 return lhs[0][r] * rhs[c][0] +
137 lhs[1][r] * rhs[c][1] +
138 lhs[2][r] * rhs[c][2];
142 t_mat3<T> operator*(
const t_mat3<T>& lhs,
const t_mat3<T>& rhs)
144 return t_mat3<T>(dot(lhs, rhs, 0, 0), dot(lhs, rhs, 0, 1), dot(lhs, rhs, 0, 2),
145 dot(lhs, rhs, 1, 0), dot(lhs, rhs, 1, 1), dot(lhs, rhs, 1, 2),
146 dot(lhs, rhs, 2, 0), dot(lhs, rhs, 2, 1), dot(lhs, rhs, 2, 2));
150 t_vec3<T> operator*(
const t_mat3<T>& lhs,
const t_vec3<T>& rhs)
152 return t_vec3<T>((lhs[0][0] * rhs[0] + lhs[1][0] * rhs[1] + lhs[2][0] * rhs[2]),
153 (lhs[0][1] * rhs[0] + lhs[1][1] * rhs[1] + lhs[2][1] * rhs[2]),
154 (lhs[0][2] * rhs[0] + lhs[1][2] * rhs[1] + lhs[2][2] * rhs[2]));
158 t_vec3<T> operator*(
const t_vec3<T>& lhs,
const t_mat3<T>& rhs)
160 return t_vec3<T>(lhs[0] * rhs[0][0] + lhs[1] * rhs[0][1] + lhs[2] * rhs[0][2],
161 lhs[0] * rhs[1][0] + lhs[1] * rhs[1][1] + lhs[2] * rhs[1][2],
162 lhs[0] * rhs[2][0] + lhs[1] * rhs[2][1] + lhs[2] * rhs[2][2]);
t_mat3 template class that represents a 3x3 matrix.
Definition: mat3.h:23
t_vec3 template class that represents a 3D vector
Definition: vec3.h:34