15 double DeltaX = dc2.x() - dc1.x();
16 double DeltaY = dc2.y() - dc1.y();
17 double DistanceOfCenters = std::hypot(DeltaX, DeltaY);
18 if (DistanceOfCenters == 0.) {
19 std::cout <<
" TangentToCircles::tangentLines >>> ERROR same tube on input " << std::endl;
22 double Alpha0 = std::atan2(DeltaY, DeltaX);
25 if (dc1.r() == 0. && dc2.r() == 0.) {
26 lines.emplace_back(dc1.position(), Alpha0);
31 double RSum = dc1.r() + dc2.r();
33 double ratio = RSum / DistanceOfCenters;
36 double Alpha1 = std::asin(
ratio);
38 double line_phi = Alpha0 + Alpha1;
39 LocVec2D pos1(dc1.x() + dc1.r() *
std::sin(line_phi), dc1.y() - dc1.r() *
std::cos(line_phi));
40 lines.emplace_back(pos1, line_phi);
42 line_phi = Alpha0 - Alpha1;
43 LocVec2D pos2(dc1.x() - dc1.r() *
std::sin(line_phi), dc1.y() + dc1.r() *
std::cos(line_phi));
44 lines.emplace_back(pos2, line_phi);
47 if (dc1.r() == 0. || dc2.r() == 0.)
return lines;
50 double DeltaR = std::abs(dc2.r() - dc1.r());
55 double Alpha2 = asin(
ratio);
57 if (dc1.r() < dc2.r()) {
58 line_phi = Alpha0 + Alpha2;
59 LocVec2D pos3(dc1.x() - dc1.r() *
sin(line_phi), dc1.y() + dc1.r() *
cos(line_phi));
60 lines.emplace_back(pos3, line_phi);
62 line_phi = Alpha0 - Alpha2;
63 LocVec2D pos4(dc1.x() + dc1.r() *
std::sin(line_phi), dc1.y() - dc1.r() *
std::cos(line_phi));
64 lines.emplace_back(pos4, line_phi);
67 line_phi = Alpha0 + Alpha2;
68 LocVec2D pos3(dc1.x() + dc1.r() *
std::sin(line_phi), dc1.y() - dc1.r() *
std::cos(line_phi));
69 lines.emplace_back(pos3, line_phi);
71 line_phi = Alpha0 - Alpha2;
72 LocVec2D pos4(dc1.x() - dc1.r() *
std::sin(line_phi), dc1.y() + dc1.r() *
std::cos(line_phi));
73 lines.emplace_back(pos4, line_phi);