Consider the following 2D regions:

DetectorSlice[xToDetCenter_, yToDetCenter_, dxdet_, dydet_, Rdet_, 
   experiment_] := 
  If[experiment == "Box", 
   Rectangle[{xToDetCenter - dxdet/2, 
     yToDetCenter - dydet/2}, {xToDetCenter + dxdet/2, 
     yToDetCenter + dydet/2}], 
   If[experiment == "Cylinder", 
    Disk[{xToDetCenter, yToDetCenter}, Rdet], 0]];

For Box, this is a rectangle parametrized by the coordinates of its center xToDetCenter, yToDetCenter and side lengths dxdet, dydet. For Cylinder, this is a disk. Could you please tell me how to find the largest distance from the point {0,0} to the given domain?

It is trivial by hands, but how to ask Mathematica to do this automatically?

My attempt is the following. For Box, I just use MeshCordinates and choose the maximal Norm of the coordinates. For Disk, I use MeshCoordinates@DiscretizeRegion@RegionBoundary, and then do the same. The same question about possible general 2D regions.

  • 1
    $\begingroup$ Not sure yet about the Rectangle geometry, but wouldn't the furthest point in the Disk geometry be the point that lies on the edge of the disk along the vector pointing from the origin to the center of the disk (but on the far side)? This distance would be calculated by Norm[{xToDetCenter, yToDetCenter}*(1 + Rdet)] $\endgroup$
    – ydd
    Commented Jun 1, 2023 at 20:24
  • $\begingroup$ @DavidTrimas : for these geometries, it may be simple, but how to treat possibly arbitrary regions? $\endgroup$ Commented Jun 1, 2023 at 20:27
  • 1
    $\begingroup$ You could try "NMaximize". E.g. for a Disk[{1,1},1/2]: NMaximize[ If[RegionMember[Disk[{1, 1}, 1/2], {x, y}], Norm[{x, y}], 0], {x, y}, Method -> "DifferentialEvolution"] $\endgroup$ Commented Jun 1, 2023 at 20:42
  • 1
    $\begingroup$ Disappointing (adapted from the docs): Subscript[\[ScriptCapitalR], 1] = ImplicitRegion[0 <= x^2 + y^2 <= \!\(\*SubsuperscriptBox[\(r\), \(2\), \(2\)]\), {x, y}]; Subscript[\[ScriptCapitalR], 2] = Annulus[]; RegionWithin[Subscript[\[ScriptCapitalR], 1], Subscript[\ \[ScriptCapitalR], 2]] -- should work for reasonably simple regions. :( $\endgroup$
    – Michael E2
    Commented Jun 1, 2023 at 20:48
  • 1
    $\begingroup$ farthestPoint[region_, point_ : {0, 0}] := ArgMax[{Norm[{x, y} - point], {x, y} \[Element] RegionBoundary[region]}, {x, y}]? $\endgroup$
    – kglr
    Commented Jun 1, 2023 at 21:04

1 Answer 1


Using RegionFarthestDistance: (newly introduced with v13.3 / using the cloud account)

For a point (Red) outside a polygon:


For a point (Blue) inside the polygon:




enter image description here

TODO: Sometimes, the RegionIntersection fails to find the single point of intersection (reason unknown). At times, it results in a degenerate circle with a infinitesimal arc.

The circles are centered at blue and red points.

So far, I haven't been able to extract the farthest point from the RegionFarthestDistance itself. The name implies that this function is not responsible for providing it (and perhaps there exists another mechanism to get that information). If the farthest distance is available, a reasonable assumption is that there was a point that was used in such a calculation.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.