94 Matrix3(
const std::vector<std::vector<double>> &m) {
95 for (
size_t i=0; i<3; i++)
96 for (
size_t j=0; j<3; j++)
106 for (
size_t i=0; i<3; i++)
107 for (
size_t j=0; j<3; j++)
118 std::string
printStr(
int nt = 0,
int lvl = 0)
const {
120 std::string tabS =
"";
121 for (
int i = 0; i < nt; i++)
124 std::ostringstream oss;
125 for (
size_t i=0; i<3; i++)
126 oss << tabS <<
"[" << (*
this)(i, 0) <<
", " << (*
this)(i, 1) <<
", "
127 << (*
this)(i, 2) <<
"]" << std::endl;
139 void print(
int nt = 0,
int lvl = 0)
const { std::cout <<
printStr(nt, lvl); }
176 return {(*this)(0) * v, (*
this)(1) * v, (*
this)(2) * v};
180 std::vector<double>
dot(
const std::vector<double> &v)
const {
182 auto r = std::vector<double>(3,0.);
183 for (
size_t i=0; i<3; i++)
184 for (
size_t j=0; j<3; j++)
185 r[i] += (*
this)(i,j) * v[j];
198 m(0,1) = (*this)(1,0);
199 m(0,2) = (*this)(2,0);
201 m(1,0) = (*this)(0,1);
202 m(1,2) = (*this)(2,1);
204 m(2,0) = (*this)(0,2);
205 m(2,1) = (*this)(1,2);
216 return (*
this)(0,0) * ((*
this)(1,1) * (*
this)(2,2) - (*
this)(2,1) * (*
this)(1,2)) -
217 (*this)(0,1) * ((*
this)(1,0) * (*
this)(2,2) - (*
this)(2,0) * (*
this)(1,2)) +
218 (*this)(0,2) * ((*
this)(1,0) * (*
this)(2,1) - (*
this)(2,0) * (*
this)(1,1));
230 auto det_inv = 1. / this->
det();
233 ((*this)(1,1) * (*
this)(2,2) - (*
this)(2,1) * (*
this)(1,2));
235 ((*this)(0,1) * (*
this)(2,2) - (*
this)(2,1) * (*
this)(0,2));
237 ((*this)(0,1) * (*
this)(1,2) - (*
this)(1,1) * (*
this)(0,2));
240 ((*this)(1,0) * (*
this)(2,2) - (*
this)(2,0) * (*
this)(1,2));
242 ((*this)(0,0) * (*
this)(2,2) - (*
this)(2,0) * (*
this)(0,2));
244 ((*this)(0,0) * (*
this)(1,2) - (*
this)(1,0) * (*
this)(0,2));
247 ((*this)(1,0) * (*
this)(2,1) - (*
this)(2,0) * (*
this)(1,1));
249 ((*this)(0,0) * (*
this)(2,1) - (*
this)(2,0) * (*
this)(0,1));
251 ((*this)(0,0) * (*
this)(1,1) - (*
this)(1,0) * (*
this)(0,1));
331 d_data[3] = 0.5 * (m[1][2] + m[2][1]);
332 d_data[4] = 0.5 * (m[0][2] + m[2][0]);
333 d_data[5] = 0.5 * (m[0][1] + m[1][0]);
346 d_data[3] = 0.5 * (m(1,2) + m(2,1));
347 d_data[4] = 0.5 * (m(0,2) + m(2,0));
348 d_data[5] = 0.5 * (m(0,1) + m(1,0));
358 for (
size_t i=0; i<6; i++)
369 std::string
printStr(
int nt = 0,
int lvl = 0)
const {
371 std::string tabS =
"";
372 for (
int i = 0; i < nt; i++)
375 std::ostringstream oss;
376 for (
size_t i=0; i<3; i++)
377 oss << tabS <<
"[" << (*
this)(i, 0) <<
", " << (*
this)(i, 1) <<
", "
378 << (*
this)(i, 2) <<
"]" << std::endl;
390 void print(
int nt = 0,
int lvl = 0)
const { std::cout <<
printStr(nt, lvl); }
399 return {(*this)(i, 0), (*
this)(i, 1), (*
this)(i, 2)};
404 return {(*this)(i, 0), (*
this)(i, 1), (*
this)(i, 2)};
415 return d_data[i == j ? i : 6 - i - j];
420 return d_data[i == j ? i : 6 - i - j];
434 const float &
get(
size_t i)
const {
445 for (
size_t i=0; i<6; i++)
456 return {(*this)(0) * v, (*
this)(1) * v, (*
this)(2) * v};
460 std::vector<double>
dot(
const std::vector<double> &v)
const {
462 auto r = std::vector<double>(3,0.);
463 for (
size_t i=0; i<3; i++)
464 for (
size_t j=0; j<3; j++)
465 r[i] += (*
this)(i,j) * v[j];
485 return (*
this)(0,0) * ((*
this)(1,1) * (*
this)(2,2) - (*
this)(2,1) * (*
this)(1,2)) -
486 (*this)(0,1) * ((*
this)(1,0) * (*
this)(2,2) - (*
this)(2,0) * (*
this)(1,2)) +
487 (*this)(0,2) * ((*
this)(1,0) * (*
this)(2,1) - (*
this)(2,0) * (*
this)(1,1));
499 auto det_inv = 1. / this->
det();
502 ((*this)(1,1) * (*
this)(2,2) - (*
this)(2,1) * (*
this)(1,2));
504 ((*this)(0,1) * (*
this)(2,2) - (*
this)(2,1) * (*
this)(0,2));
506 ((*this)(0,1) * (*
this)(1,2) - (*
this)(1,1) * (*
this)(0,2));
509 ((*this)(1,0) * (*
this)(2,2) - (*
this)(2,0) * (*
this)(1,2));
511 ((*this)(0,0) * (*
this)(2,2) - (*
this)(2,0) * (*
this)(0,2));
513 ((*this)(0,0) * (*
this)(1,2) - (*
this)(1,0) * (*
this)(0,2));
516 ((*this)(1,0) * (*
this)(2,1) - (*
this)(2,0) * (*
this)(1,1));
518 ((*this)(0,0) * (*
this)(2,1) - (*
this)(2,0) * (*
this)(0,1));
520 ((*this)(0,0) * (*
this)(1,1) - (*
this)(1,0) * (*
this)(0,1));
532bool checkMatrix(
const std::vector<std::vector<double>> &m);
541std::vector<double>
dot(
const std::vector<std::vector<double>> &m,
const
542std::vector<double> &v);
550std::vector<std::vector<double>>
transpose(
const
551std::vector<std::vector<double>> &m);
559double det(
const std::vector<std::vector<double>> &m);
567std::vector<std::vector<double>>
568inv(
const std::vector<std::vector<double>> &m);
Collection of methods useful in simulation.
double det(const std::vector< std::vector< double > > &m)
Computes the determinant of matrix.
bool checkMatrix(const std::vector< std::vector< double > > &m)
Checks matrix.
std::vector< std::vector< double > > inv(const std::vector< std::vector< double > > &m)
Computes the determinant of matrix.
std::vector< double > dot(const std::vector< std::vector< double > > &m, const std::vector< double > &v)
Computes the dot product between matrix and vector.
std::vector< std::vector< double > > transpose(const std::vector< std::vector< double > > &m)
Computes the tranpose of matrix.
A structure to represent 3d matrices.
Matrix3 transpose() const
Computes the tranpose of matrix.
Matrix3(const Matrix3 &m)
Constructor.
float & operator()(size_t i, size_t j)
Returns element of matrix.
util::Point dot(const util::Point &v)
Computes the dot product between matrix and vector.
Point operator()(size_t i) const
Returns row of matrix.
const float & operator()(size_t i, size_t j) const
Returns element of matrix.
void print(int nt=0, int lvl=0) const
Prints the information.
Point operator()(size_t i)
Returns row of matrix.
Matrix3(const std::vector< std::vector< double > > &m)
Constructor.
std::string printStr(int nt=0, int lvl=0) const
Prints the information.
std::vector< double > dot(const std::vector< double > &v) const
Computes the dot product between matrix and vector.
double det() const
Computes the determinant of matrix.
Matrix3 inv() const
Computes the determinant of matrix.
Matrix3(const util::Point &diagonal)
Constructor.
Matrix3(const util::Point &a1, const util::Point &a2, const util::Point &a3)
Constructor.
A structure to represent 3d vectors.
double d_y
the y coordinate
double d_z
the z coordinate
double d_x
the x coordinate
A structure to represent 3d matrices.
const float & operator()(size_t i, size_t j) const
Returns element of matrix.
util::Point dot(const util::Point &v)
Computes the dot product of this matrix with another vector.
SymMatrix3(const std::vector< std::vector< double > > &m)
Constructor.
float & get(size_t i)
Returns row of matrix.
void print(int nt=0, int lvl=0) const
Prints the information about the object.
SymMatrix3(const util::Point &diagonal)
Constructor.
Point operator()(size_t i) const
Returns row of matrix.
const float & get(size_t i) const
Returns row of matrix.
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
SymMatrix3(const std::vector< double > &m)
Constructor.
double det() const
Computes the determinant of matrix.
void copy(double m[6]) const
Copy.
SymMatrix3(const SymMatrix3 &m)
Constructor.
std::vector< double > dot(const std::vector< double > &v) const
Computes the dot product of this matrix with another vector.
float & operator()(size_t i, size_t j)
Returns element of matrix.
SymMatrix3(const Matrix3 &m)
Constructor.
SymMatrix3 transpose() const
Computes the tranpose of matrix.
SymMatrix3 inv() const
Computes the determinant of matrix.
Point operator()(size_t i)
Returns row of matrix.