LibreCAD
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lc::maths::Equation Class Reference

#include <equation.h>

Public Member Functions

 Equation ()
 
Equationoperator= (const Equation qm)
 
 Equation (Eigen::Matrix3d &mat)
 
 Equation (double a, double b, double c, double d, double e, double f)
 creates a new quadratic Equation More...
 
 Equation (const std::vector< double > &vec)
 creates a new equation with values in vector More...
 
const std::vector< double > Coefficients () const
 Coefficients of the equation. More...
 
const Equation move (const geo::Coordinate &v) const
 move the quadratic equation by value V More...
 
const Equation rotate (double angle) const
 rotate the quadratic equation by value V More...
 
const Equation rotate (const geo::Coordinate &center, double angle) const
 rotate the quadratic equation by value V at specific center. More...
 
const Eigen::Matrix3d Matrix () const
 Matrix Returns matrix of equation. More...
 
const Equation flipXY () const
 flipXY Flips the matrix values More...
 

Static Public Member Functions

static Eigen::Matrix3d rotationMatrix (double angle)
 rotationMatrix Rotates the matrix by an angle More...
 
static Eigen::Matrix3d translateMatrix (const geo::Coordinate &v)
 translateMatrix Translates the matrix by some coordinate value More...
 

Private Attributes

Eigen::Matrix3d matrix_
 

Detailed Description

Definition at line 14 of file equation.h.

Constructor & Destructor Documentation

Equation::Equation ( )

Definition at line 10 of file equation.cpp.

10  : matrix_(Eigen::Matrix3d::Zero()) {
11 
12 }
Eigen::Matrix3d matrix_
Definition: equation.h:95
Equation::Equation ( Eigen::Matrix3d &  mat)

Definition at line 14 of file equation.cpp.

14  : matrix_(mat) {
15 
16 }
Eigen::Matrix3d matrix_
Definition: equation.h:95
Equation::Equation ( double  a,
double  b,
double  c,
double  d,
double  e,
double  f 
)

creates a new quadratic Equation

Parameters
aX^2 double value
bY^2 double value
cXY double value
dX double value
eY double value
fconstant double

Definition at line 23 of file equation.cpp.

24  :
25  matrix_((Eigen::Matrix3d() <<
26  a, b*.5, d*.5,
27  b*.5, c, e*.5,
28  d*.5, e*.5, f
29  ).finished()) {
30 }
Eigen::Matrix3d matrix_
Definition: equation.h:95
Equation::Equation ( const std::vector< double > &  vec)

creates a new equation with values in vector

Parameters
vecvector of quadratic equation

Definition at line 32 of file equation.cpp.

32  :
33  matrix_((Eigen::Matrix3d() <<
34  vec[0], vec[1]*.5, vec[3]*.5,
35  vec[1]*.5, vec[2], vec[4]*.5,
36  vec[3]*.5, vec[4]*.5, vec[5]
37  ).finished()) {
38 }
Eigen::Matrix3d matrix_
Definition: equation.h:95

Member Function Documentation

const std::vector< double > Equation::Coefficients ( ) const

Coefficients of the equation.

Returns
vector of coefficients.

Definition at line 40 of file equation.cpp.

40  {
41  std::vector<double> vec {{
42  matrix_(0,0), matrix_(0,1) + matrix_(1,0),
43  matrix_(1,1), matrix_(0,2) + matrix_(2,0),
44  matrix_(2,1) + matrix_(1,2), matrix_(2,2) }};
45  return vec;
46 }
Eigen::Matrix3d matrix_
Definition: equation.h:95
const Equation Equation::flipXY ( ) const

flipXY Flips the matrix values

Returns
equation vith flipped XY

Definition at line 88 of file equation.cpp.

88  {
89  Eigen::Matrix3d ret;
90 
91  /*
92  * swap a with c
93  * swap d with e
94  * no swaps for consant i.e f
95  */
96 
97  auto lin1 = (matrix_(2,0) + matrix_(0,2)) / 2;
98  auto lin2 = (matrix_(2,1) + matrix_(1,2)) / 2;
99 
100  ret << matrix_(1,1), matrix_(1,0), lin2,
101  matrix_(0,1), matrix_(0,0), lin1,
102  lin2 , lin1 , matrix_(2,2);
103 
104  return ret;
105 }
Eigen::Matrix3d matrix_
Definition: equation.h:95
const Eigen::Matrix3d Equation::Matrix ( ) const

Matrix Returns matrix of equation.

Returns
Matrix equation

Definition at line 76 of file equation.cpp.

76  {
77  return matrix_;
78 }
Eigen::Matrix3d matrix_
Definition: equation.h:95
const Equation Equation::move ( const geo::Coordinate v) const

move the quadratic equation by value V

Parameters
vthe coordinate value to move equation by.
Returns
moved equation.

Definition at line 48 of file equation.cpp.

49  {
50  Eigen::Matrix3d mat = translateMatrix(v).transpose() * matrix_ * translateMatrix(v);
51  return Equation(mat);
52 }
Eigen::Matrix3d matrix_
Definition: equation.h:95
static Eigen::Matrix3d translateMatrix(const geo::Coordinate &v)
translateMatrix Translates the matrix by some coordinate value
Definition: equation.cpp:80
Equation & Equation::operator= ( const Equation  qm)

Definition at line 18 of file equation.cpp.

18  {
19  matrix_ = qm.Matrix();
20  return *this;
21 }
const Eigen::Matrix3d Matrix() const
Matrix Returns matrix of equation.
Definition: equation.cpp:76
Eigen::Matrix3d matrix_
Definition: equation.h:95
const Equation Equation::rotate ( double  angle) const

rotate the quadratic equation by value V

Parameters
vthe angle value to rotate equation by.
Returns
rotated equation.

Definition at line 54 of file equation.cpp.

54  {
55  const auto & m = rotationMatrix(angle);
56  const auto & t = m.transpose();
57  Eigen::Matrix3d ret = t * matrix_ * m;
58  return Equation(ret);
59 }
Eigen::Matrix3d matrix_
Definition: equation.h:95
static Eigen::Matrix3d rotationMatrix(double angle)
rotationMatrix Rotates the matrix by an angle
Definition: equation.cpp:68
const Equation Equation::rotate ( const geo::Coordinate center,
double  angle 
) const

rotate the quadratic equation by value V at specific center.

Parameters
vthe angle value to rotate equation by.
Returns
rotated equation.

Definition at line 61 of file equation.cpp.

62  {
63  return move(geo::Coordinate(-center.x(), -center.y()))
64  .rotate(angle)
65  .move(center);
66 }
double x() const
Returns x of Coordinate.
Definition: geocoordinate.h:26
double y() const
Returns y of Coordinate.
Definition: geocoordinate.h:34
const Equation move(const geo::Coordinate &v) const
move the quadratic equation by value V
Definition: equation.cpp:48
const Equation rotate(double angle) const
rotate the quadratic equation by value V
Definition: equation.cpp:54
Eigen::Matrix3d Equation::rotationMatrix ( double  angle)
static

rotationMatrix Rotates the matrix by an angle

Parameters
angle
Returns
Matrix equation

Definition at line 68 of file equation.cpp.

68  {
69  Eigen::Matrix3d mat;
70  mat << std::cos(angle) , std::sin(angle) , 0,
71  -std::sin(angle) , std::cos(angle) , 0,
72  0 , 0 , 1;
73  return mat;
74 }
Eigen::Matrix3d Equation::translateMatrix ( const geo::Coordinate v)
static

translateMatrix Translates the matrix by some coordinate value

Parameters
voffset coordinate value
Returns
Matrix equation

Definition at line 80 of file equation.cpp.

80  {
81  Eigen::Matrix3d mat;
82  mat << 1 , 0 , -v.x(),
83  0 , 1 , -v.y(),
84  0 , 0 , 1;
85  return mat;
86 }
double x() const
Returns x of Coordinate.
Definition: geocoordinate.h:26
double y() const
Returns y of Coordinate.
Definition: geocoordinate.h:34

Member Data Documentation

Eigen::Matrix3d lc::maths::Equation::matrix_
private

Definition at line 95 of file equation.h.


The documentation for this class was generated from the following files: