3

Why am I getting some extra intersection points?enter image description here

 Manipulate[b = 2 r + 1;
 Show[p1 = 
   ContourPlot[{x^2 + (y - r)^2 == r^2, x/12 + y/b == 1}, {x, -20, 
     20}, {y, -20, 20}, Axes -> True, Frame -> False, 
    AspectRatio -> 1, PerformanceGoal -> "Goal"],
  Graphics[{PointSize[Large], Red, 
    Point@Graphics`Mesh`FindIntersections[p1]}]], {{r, 4, 
   "Radius"}, -10, 10, 0.01}]

Why is this not plotting the right

Obviously, this should not have intersection in the pic above.

kile
  • 1,671
  • 5
  • 10
  • 1
    Related: https://mathematica.stackexchange.com/questions/41496/graphicsmeshfindintersections-fails-to-detect-intersections -- IIRC: The operation of FindIntersections changes from time to time, and several users would not base important code on it. – Michael E2 Dec 06 '20 at 15:44

1 Answers1

4
Clear["Global`*"]

You can use Graphics`Mesh`FindIntersections[p1, Graphics`Mesh`AllPoints -> False] to eliminate extra points; however, it will also miss the tangent point. It is easy to just solve for the intersections.

Manipulate[
 Module[
  {sol, b, eqns},
  b = 2 r + 1;
  eqns = {x^2 + (y - r)^2 == r^2, x/12 + y/b == 1};
  sol = Solve[eqns, {x, y}, Reals] // Quiet;
  ContourPlot[Evaluate@eqns,
   {x, -20, 20}, {y, -20, 20},
   Axes -> True,
   Frame -> False,
   AspectRatio -> 1,
   PerformanceGoal -> "Goal",
   Epilog -> {PointSize[Large], Red,
     If[Length@sol > 0, Point[{x, y} /. sol], Nothing]}]],
 {{r, 4, "Radius"}, -10, 10, 0.01, Appearance -> "Labeled"}]

corrected plot with the tangent as the single intersection

MarcoB
  • 67,153
  • 18
  • 91
  • 189
Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
  • Coordinate {{ConditionalExpression[$CellContextb^(-1) (12 $CellContextb - 12 (4 (144 + $CellContextb^2)^(-1) (36 $CellContextb + $CellContextb^2) - 8 2^Rational[1, 2] (-(144 + $CellContextb^2)^(-2) ((-9) $CellContextb^3 + $CellContextb^4))^Rational[1, 2])), should be a pair of numbers, or a Scaled or Offset form. – kile Mar 12 '20 at 10:18
  • The line is not moving with the slider – kile Mar 12 '20 at 10:19
  • @kile - restructured the Module. Try it now. – Bob Hanlon Mar 12 '20 at 12:57