5

I have the following code which finds intersection of two curves using mesh functions:

y[x_] := x^2
z[x_] := 1
P1 = Plot[y[x], {x, 0, 2}];
P2 = Plot[z[x], {x, 0, 2}];
Test = Show[P1, P2]
Graphics`Mesh`FindIntersections[Test // DiscretizeGraphics, 
 Graphics`Mesh`AllPoints -> False]

This works well in all versions of Mathematica including Mathematica 13.3. But if I modify the code a little bit like this:

y[x_] := x^2
z[x_] := 1
P1 = Plot[y[x], {x, 0, 2}];
P2 = Graphics[{InfiniteLine[{{0, 1}, {2, 1}}]}];
Test = Show[P1, P2]
Graphics`Mesh`FindIntersections[Test // DiscretizeGraphics, 
 Graphics`Mesh`AllPoints -> False]

It works well on all Mathematica versions except Mathematica 13.3. Is this a bug in the latest version?

codebpr
  • 2,233
  • 1
  • 7
  • 26
  • 1
    It's not a bug if WRI wants to change the behavior of an undocumented function. You really should report it and see what they say. I don't know what Graphics`Mesh`AllPoints -> False is supposed to do, but the function does not return all point, right? – Goofy Jan 04 '24 at 07:25
  • 2
    Both code blocks evaluate in Mathematica v12.2! – Ulrich Neumann Jan 04 '24 at 07:44
  • 3
    suppress PlotHighlighting (new in version 13.3) using P1 = Plot[y[x], {x, 0, 2}, PlotHighlighting -> None]? – kglr Jan 04 '24 at 07:47

1 Answers1

6

This maybe works like before:

Block[{Annotation = # &},
 Graphics`Mesh`FindIntersections[Test // DiscretizeGraphics, 
  Graphics`Mesh`AllPoints -> False]
 ]

(* {{0.999811, 1.}} *)

Darned annotations.

My guess is that it's DiscretizeGraphics that behaves different, but prior behavior not given in OP.

Goofy
  • 2,767
  • 10
  • 12
  • Actually I use it on my Mathematica 13.3 because of this particular reason as mentioned in a previous question : https://mathematica.stackexchange.com/questions/289187/graphicsmeshfindintersections-not-working-in-mathematica-13-3 – codebpr Jan 04 '24 at 12:46
  • 1
    @codebpr Works there, too. See new answer. – Goofy Jan 04 '24 at 15:49