FACT++  1.0
bool Ring::CalcCenter ( Led  i,
Led  j,
Led  k 
)

Definition at line 16 of file Ring.cc.

References fMag, fR, fX, fY, Led::GetMag(), Led::GetX(), and Led::GetY().

Referenced by MCaos::CalcCenters(), and GetMag().

17 {
18  double h1 = i.GetY() - j.GetY();
19 
20  if (h1==0)
21  {
22  std::swap(j, k);
23  h1 = i.GetY() - j.GetY();
24  if (h1==0)
25  {
26  cout << "Ring::CalcCenter: h1==0" <<endl;
27  return false;
28  }
29  }
30 
31  double h2 = j.GetY() - k.GetY();
32 
33  if (h2==0)
34  {
35  std::swap(i, j);
36  h2 = j.GetY() - k.GetY();
37  if (h2==0)
38  {
39  cout << "Ring::CalcCenter: h2==0" << endl;
40  return false;
41  }
42  }
43 
44  const double w1 = i.GetX() - j.GetX();
45  const double w2 = j.GetX() - k.GetX();
46 
47  const double m1 = -w1/h1;
48  const double m2 = -w2/h2;
49 
50  if (m2 - m1==0)
51  {
52  cout << "Ring::CalcCenter: All three points in a row! (m2-m1==0)" << endl;
53  return false;
54  }
55 
56  fX = ((m2*(j.GetX() + k.GetX()) + i.GetY() - k.GetY() -m1*(i.GetX() + j.GetX()))/(m2-m1)/2);
57  fY = ((m2*(i.GetY() + j.GetY()) + m1*m2*(k.GetX() - i.GetX())-m1*(j.GetY() + k.GetY()))/(m2-m1)/2);
58 
59  fR = hypot(fX - i.GetX(), fY - i.GetY());
60 
61  fMag = (i.GetMag() + j.GetMag() + k.GetMag())/3;
62 
63  return true;
64 }
double GetMag() const
Definition: Led.h:44
double GetY() const
Definition: Led.h:42
double fMag
Definition: Ring.h:18
double fR
Definition: Ring.h:15
double fX
Definition: Ring.h:13
double GetX() const
Definition: Led.h:41
double fY
Definition: Ring.h:14

+ Here is the call graph for this function:

+ Here is the caller graph for this function: