LibreCAD
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lcmath.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include <iostream>
5 #include <complex>
6 #include <float.h>
7 #include <vector>
8 namespace lc {
9  class Math {
10  public:
19  static bool isAngleBetween(double a,
20  double start, double end,
21  bool CCW);
22 
28  static double correctAngle(double a);
29 
37  static double getAngleDifferenceShort(double a1, double a2, bool CCW) ;
38 
46  static double getAngleDifference(double a1, double a2, bool CCW) ;
47 
53  static std::vector<double> quadraticSolver(const std::vector<double>& ce);
54 
55  static std::vector<double> cubicSolver(const std::vector<double>& ce);
62  static std::vector<double> quarticSolver(const std::vector<double>& ce);
68  static std::vector<double> sexticSolver(const std::vector<double>& ce);
69  static std::vector<double> quarticSolverFull(const std::vector<double>& ce);
70 
72  /* solve the following quadratic simultaneous equations,
73  * ma000 x^2 + ma011 y^2 - 1 =0
74  * ma100 x^2 + 2 ma101 xy + ma111 y^2 + mb10 x + mb11 y +mc1 =0
75  *
76  *@m, a vector of size 8 contains coefficients in the strict order of:
77  ma000 ma011 ma100 ma101 ma111 mb10 mb11 mc1
78  *@return a std::vector<lc::geo::Coordinate> contains real roots (x,y)
79  */
80  static std::vector<lc::geo::Coordinate> simultaneousQuadraticSolver(const std::vector<double>& m);
81 
83  /* solve the following quadratic simultaneous equations,
84  * ma000 x^2 + ma001 xy + ma011 y^2 + mb00 x + mb01 y + mc0 =0
85  * ma100 x^2 + ma101 xy + ma111 y^2 + mb10 x + mb11 y + mc1 =0
86  *
87  *@m, a vector of size 2 each contains a vector of size 6 coefficients in the strict order of:
88  ma000 ma001 ma011 mb00 mb01 mc0
89  ma100 ma101 ma111 mb10 mb11 mc1
90  *@return a std::vector<lc::geo::Coordinate> contains real roots (x,y)
91  */
92  static bool simultaneousQuadraticVerify(const std::vector<std::vector<double> >& m, const geo::Coordinate& v);
98  static std::vector<lc::geo::Coordinate> simultaneousQuadraticSolverFull(const std::vector<std::vector<double> >& m);
99  static std::vector<lc::geo::Coordinate> simultaneousQuadraticSolverMixed(const std::vector<std::vector<double> >& m);
100  };
101 }
102 
103 #
static double getAngleDifferenceShort(double a1, double a2, bool CCW)
getAngleDifference, Angle difference between 2 angles
Definition: lcmath.cpp:41
static std::vector< double > quadraticSolver(const std::vector< double > &ce)
quadraticSolver, Quadratic equations solver
Definition: lcmath.cpp:77
static std::vector< double > cubicSolver(const std::vector< double > &ce)
Definition: lcmath.cpp:102
static std::vector< lc::geo::Coordinate > simultaneousQuadraticSolverMixed(const std::vector< std::vector< double > > &m)
Definition: lcmath.cpp:414
static std::vector< lc::geo::Coordinate > simultaneousQuadraticSolver(const std::vector< double > &m)
Definition: lcmath.cpp:245
static std::vector< double > sexticSolver(const std::vector< double > &ce)
Definition: lcmath.cpp:151
static bool simultaneousQuadraticVerify(const std::vector< std::vector< double > > &m, const geo::Coordinate &v)
Definition: lcmath.cpp:484
Definition: cadentity.h:12
Definition: lcmath.h:9
static std::vector< double > quarticSolverFull(const std::vector< double > &ce)
Definition: lcmath.cpp:183
static double getAngleDifference(double a1, double a2, bool CCW)
getAngleDifference, Angle difference between 2 angles
Definition: lcmath.cpp:54
static std::vector< lc::geo::Coordinate > simultaneousQuadraticSolverFull(const std::vector< std::vector< double > > &m)
simultaneousQuadraticSolverFull
Definition: lcmath.cpp:283
static double correctAngle(double a)
correctAngle, Corrects angle to be in -PI to PI
Definition: lcmath.cpp:33
static bool isAngleBetween(double a, double start, double end, bool CCW)
isAngleBetween, checks if angle is between
Definition: lcmath.cpp:21
static std::vector< double > quarticSolver(const std::vector< double > &ce)
Definition: lcmath.cpp:127