60 if (!g)
return ellipse;
61 if (g->
GetN() < 6)
return ellipse;
70 X0 = (xmax +
xmin) / 2.0;
71 Y0 = (ymax +
ymin) / 2.0;
79 for (i = 0; i <
N; i++) {
96 S3.
Invert(&tmp); S3 *= -1.0;
98 std::cout <<
"fit_ellipse : linear part of the scatter matrix is singular!" << std::endl;
106 for (i = 0; i < 3; i++) {
108 M[0][i] = M[2][i] / 2.0;
117 std::cout <<
"fit_ellipse : eigenvalues have nonzero imaginary parts!" << std::endl;
121 for (i = 0; i < 3; i++) {
122 tmp = 4.0 * evec[0][i] * evec[2][i] - evec[1][i] * evec[1][i];
123 if (tmp > 0.0)
break;
126 std::cout <<
"fit_ellipse : no min. pos. eigenvalue found!" << std::endl;
136 std::cout <<
"fit_ellipse : eigenvector for min. pos. eigenvalue is NULL!" << std::endl;
189 std::cout <<
"ConicToParametric : improper input vector length!" << std::endl;
206 Double_t Delta = A * F * F + C * D * D + J * G - 2.0 * B * D *
F;
210 if (!( (Delta != 0.0) && (J < 0.0) && (I != 0.0) && (Delta / I < 0.0) )) {
211 std::cout <<
"ConicToParametric : ellipse (real) specific constraints not met!" << std::endl;
215 x0 += (C * D - B *
F) / J;
216 y0 += (A * F - B * D) / J;
219 a =
std::sqrt(2.0 * Delta / J / (I + tmp));
220 b =
std::sqrt(2.0 * Delta / J / (I - tmp));
224 tmp = (A -
C) / 2.0 / B;
226 if (tmp < 0.0) { theta -= 45.0; }
else { theta += 45.0; }
227 if (A > C) theta += 90.0;
228 }
else if (A > C) theta = 90.0;
231 if (a < b) { tmp =
a; a =
b; b = tmp; theta -= 90.0; }
233 if (theta < -45.0) theta += 180.0;
234 if (theta > 135.0) theta -= 180.0;
274 for (i = 0; i <
n; i++) {
308 std::cout << std::endl;
309 std::cout <<
"x0 = " << ellipse[0] << std::endl;
310 std::cout <<
"y0 = " << ellipse[1] << std::endl;
311 std::cout <<
"a = " << ellipse[2] << std::endl;
312 std::cout <<
"b = " << ellipse[3] << std::endl;
313 std::cout <<
"theta = " << ellipse[4] << std::endl;
314 std::cout << std::endl;
321 if (c) { c->
Clear(); }
else { c =
new TCanvas(
"c",
"c"); }
326 ellipse[2], ellipse[3],
TVectorD ConicToParametric(const TVectorD &conic)
TVectorT< Element > & ResizeTo(Int_t lwb, Int_t upb)
Resize the vector to [lwb:upb] .
TVectorD fit_ellipse(TGraph *g)
constexpr Double_t TwoPi()
const TVectorD & GetEigenValuesIm() const
TMatrixTColumn_const< Double_t > TMatrixDColumn_const
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
virtual void SetGrid(Int_t valuex=1, Int_t valuey=1)
void Clear(Option_t *option="")
Remove all primitives from the canvas.
TMatrixT< Element > & Invert(Double_t *det=0)
Invert the matrix and calculate its determinant.
virtual void Draw(Option_t *option="")
Draw this ellipse with its current attributes.
virtual Double_t Rndm()
Machine independent random number generator.
Element Norm2Sqr() const
Compute the square of the 2-norm SUM{ v[i]^2 }.
R__EXTERN TRandom * gRandom
const TMatrixD & GetEigenVectors() const
void fitEllipseTGraphDLSF(TGraph *g=((TGraph *) 0))
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
TGraph * TestGraphDLSF(Bool_t randomize=kFALSE)
A Graph is a graphics object made of two arrays X and Y with npoints each.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
virtual void ComputeRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const
Compute the x/y range of the points in this graph.
virtual void Update()
Update canvas pad buffers.
constexpr Double_t PiOver2()
void Modified(Bool_t flag=1)
static constexpr double g