27 inline constexpr
double tiny() {
return 1.0e-5; }
35 tuple<double, double, double> Geom::CircumCircle(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3)
40 if (abs(y2 - y1) < tiny()) {
41 const double m2 = -(x3 - x2) / (y3 - y2);
42 const double mx2 = (x2 + x3) / 2.0;
43 const double my2 = (y2 + y3) / 2.0;
45 yc = m2 * (xc - mx2) + my2;
46 }
else if (abs(y3 - y2) < tiny()) {
47 const double m1 = -(x2 - x1) / (y2 - y1);
48 const double mx1 = (x1 + x2) / 2.0;
49 const double my1 = (y1 + y2) / 2.0;
51 yc = m1 * (xc - mx1) + my1;
53 const double m1 = -(x2 - x1) / (y2 - y1);
54 const double m2 = -(x3 - x2) / (y3 - y2);
55 const double mx1 = (x1 + x2) / 2.0;
56 const double mx2 = (x2 + x3) / 2.0;
57 const double my1 = (y1 + y2) / 2.0;
58 const double my2 = (y2 + y3) / 2.0;
59 xc = (m1 * mx1 - m2 * mx2 + my2 - my1) / (m1 - m2);
60 yc = m1 * (xc - mx1) + my1;
63 const double dx = x2 - xc;
64 const double dy = y2 - yc;
65 const double r = sqrt(dx * dx + dy * dy);
67 return make_tuple(xc, yc, r);
Namespace for the core simulator.
Math constants and functions header combo.