I have an enclosed 3D surface (a distorted sphere surface region, which is got by finding an enclosed contour of a 3D volumetric data, and apply RegionBoundary[BoundaryDiscretizeGraphics[ ]] to get the region of this surface), and I use the function "RegionCentroid" to find the geometric center of that region. I want to find the coordinates of points that is on the surface and is nearest/furthest from the center. I know I can use the function "RegionNearest" to find the nearest one, but how can I manage to find the furthest one? I think maybe I could select a huge amount of random points on the surface and find the one that is furthest but this will inevitable brings error. So I wonder if there is some more accurate approach? I appreciate it if someone could help me out!

  • $\begingroup$ For the type of region described, the centric will be inside rather than outside the region. $\endgroup$ Aug 8, 2020 at 16:28
  • $\begingroup$ Your title suggests the points you want are on the outside of the region, but the body of your question says "I want to find the coordinates of points that is on the surface". I assumed in my answer that you're asking for the points on the surface. Perhaps you could clarify? $\endgroup$
    – flinty
    Aug 8, 2020 at 17:36
  • $\begingroup$ Sorry for my being a bit unclear...My region here refer to the 2D surface in the 3D space without the space that it surrounds inside so the center point should be surrounded by the surface but not on the surface (thus not being in the region). $\endgroup$
    – Dennis
    Aug 8, 2020 at 19:43
  • $\begingroup$ Thanks for clarifying and improving subject header. $\endgroup$ Aug 9, 2020 at 14:45

1 Answer 1


The problem can be framed as a maximization:

(* generate some blob region and its boundary *)
pts = Join[RandomPoint[Sphere[], 100], RandomPoint[Sphere[{.4, .5, .6}, .8], 100]];
blob = RegionBoundary[ConvexHullMesh[pts]];

centroid = RegionCentroid[blob];
rdf = RegionDistance[blob];

{distmax,resultmax}=NMaximize[Norm[{x, y, z} - centroid], {x, y, z} ∈ blob];
{distmin,resultmin}=NMinimize[Norm[{x, y, z} - centroid], {x, y, z} ∈ blob];

Graphics3D[{Thick, Red, AbsolutePointSize[10], Point[centroid], 
  Line[{centroid, {x, y, z} /. resultmax}], Blue, 
  Line[{centroid, {x, y, z} /. resultmin}], White, Opacity[.2], blob},
  Boxed -> False]

blob max distance

  • $\begingroup$ Ummm... the question asks for the "a given point OUTSIDE that region." $\endgroup$ Aug 8, 2020 at 16:42
  • $\begingroup$ @DavidG.Stork the title does, but the body of the question says "I want to find the coordinates of points that is on the surface and is nearest/furthest from the center" $\endgroup$
    – flinty
    Aug 8, 2020 at 17:33
  • $\begingroup$ Then I urge you to fix your incorrect title as soon as possible. $\endgroup$ Aug 8, 2020 at 18:22
  • $\begingroup$ Sorry for the unclarity. the "region" here should be the surface itself but not the space it encloses. Please see my changed title, which I think should be more clear. $\endgroup$
    – Dennis
    Aug 8, 2020 at 19:50
  • $\begingroup$ I just tried this out with the region I got from the ListContourPlot3D and it worked perfectly. Thanks for the answer and it really teaches me a good way to deal with this type of problem! Thanks so much! $\endgroup$
    – Dennis
    Aug 8, 2020 at 20:03

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.