NeoPZ
TPZProjectEllipse.h
Go to the documentation of this file.
1 //
2 // TPZProjectEllipse.h
3 // PZ
4 //
5 // Created by Philippe Devloo on 11/4/13.
6 //
7 //
8 
9 #ifndef __PZ__TPZProjectEllipse__
10 #define __PZ__TPZProjectEllipse__
11 
12 #include <iostream>
13 
14 #include "pzvec.h"
15 #include "pzfmatrix.h"
16 
18 {
22  int fType;
25 
27  REAL fTol;
28 
29 public:
30 
32 
34  {
35  fType = project;
36  fPoints = Points;
37  int ncoef = 0;
38  switch (project) {
39  case EVerySimple2D:
40  ncoef = 2;
41  fcoefficients.resize(ncoef);
43  break;
44  case ESimple2D:
45  ncoef = 4;
46  fcoefficients.resize(4);
48  break;
49  default:
50  DebugStop();
51  break;
52  }
53  }
54 
55  TPZProjectEllipse(std::multimap<REAL, REAL> &Points)
56  {
57  fType = EVerySimple2D;
58  fcoefficients.resize(2);
59  fPoints.Resize(Points.size(), 2);
60  std::multimap<REAL, REAL>::iterator it;
61  int i=0;
62  for (it = Points.begin(); it != Points.end(); it++, i++) {
63  fPoints(i,0) = it->first;
64  fPoints(i,1) = it->second;
65  }
67  }
68 
69 
71  {
72  coef = fcoefficients;
73  }
74 
75  void PrintingAsSimpleEquation(TPZVec<REAL> &Center,TPZVec<REAL> &Ratios,std::ostream &out);
76 
78 
79 private:
80 
82  // Least Squares Method to compute a ellipse nearest for a points in vector
83  // The obtained ellipse has the axes parallels to rectangular axes
84  // Format (x-x0)^2/a^2 + (y-y0)^2/b^2 = 1.
86  // Least Squares Method to compute a ellipse nearest for a points in vector
87  // The obtained ellipse has the axes parallels to rectangular axes
88  // Format (x)^2/a^2 + (y)^2/b^2 = 1.
90 
91  // Least Squares Method to compute a ellipse nearest for a points in vector
92  // The ellipse is a conic with second order equation as
93  // y^2 = A*x^2 + B*xy + C*x + D*y + E -> 2D case
94  // z^2 = A*x^2 + B*xy + C*y^2 + D*yz + E*xz + F*x + G*y + H*z + I -> 3D case
95  // Then their axes could be rotated and translated
96  bool AdjustingWithEllipse();
97 
98  // Diagonalize a quadratic form making avoid the quadratic term xy
99  bool DiagonalizingQuadraticForm(int dim,TPZFMatrix<REAL> &Coeffs,TPZFMatrix<REAL> &NewCoeffs);
100 
101  // To print as zero all the values almost zero
103  void AlmostZeroToZero(TPZVec<REAL> &mat);
104 
105  //REAL Tol = 1.e-4;
106 
107 
109 
116 
117 
119  void PrintAxes(TPZFMatrix<REAL> &P,std::ostream &out);
120 
121  // bool DiagonalizingQuadraticForm(TPZVec<REAL> &NewCoeffs,std::ostream &out);
122 
123 
124 };
125 
126 #endif /* defined(__PZ__TPZProjectEllipse__) */
virtual void resize(const int64_t newsize)
Definition: pzvec.h:213
Templated vector implementation.
void AlmostZeroToZero(TPZFMatrix< REAL > &mat)
void PrintingAsSimpleEquation(TPZVec< REAL > &Center, TPZVec< REAL > &Ratios, std::ostream &out)
int fType
Projection type.
void PrintAxes(TPZFMatrix< REAL > &P, std::ostream &out)
Contains TPZMatrixclass which implements full matrix (using column major representation).
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
TPZProjectEllipse(std::multimap< REAL, REAL > &Points)
bool DiagonalizingQuadraticForm(int dim, TPZFMatrix< REAL > &Coeffs, TPZFMatrix< REAL > &NewCoeffs)
TPZManVector< REAL, 6 > fcoefficients
coefficients determined by the least squares problem
TPZFMatrix< REAL > fPoints
Points which determine the projection.
bool StandardFormatForSimpleEllipse(TPZVec< REAL > &Center, TPZVec< REAL > &Ratios)
TPZProjectEllipse(EType project, TPZFMatrix< REAL > &Points)
void Getcoefficients(TPZVec< REAL > &coef)
int Resize(const int64_t newRows, const int64_t wCols) override
Redimension a matrix, but maintain your elements.
Definition: pzfmatrix.cpp:1016
REAL fTol
Tolerance to project the coefficients to zero value.
bool LeastSquaresToGetSimpleEllipse()
bool LeastSquaresToGetVerySimpleEllipse()