# Recreating a ContourPlot3D using points

Let's define a three-dimensional surface

Clear["Global*"];
Φcl = (-G*Mcl)/Sqrt[x^2 + y^2 + z^2 + a^2];
Φeff = Φcl + 1/2*(κ2 - 4*ω^2)*x^2 + 1/2*v2*z^2;

G = 1; Mcl = 2.2; a = 0.182;
κ2 = 1.8; ω = 1; v2 = 7.6;

E0 = -3.2;


and create the corresponding contour plot

rm = 1;
P0 = ContourPlot3D[Φeff == E0, {x, -rm, rm}, {y, -rm, rm}, {z, -rm, rm},
Mesh -> None]


Now I want the following: Define $N$ $(x,y,z)$ points, let's say $N = 10000$, equally placed on this 3D surface. In other words, I want to recreate this surface using $N$ points to cover the surface fully. Of course, the inside of this surface will be hollow again.

I am using version 9.0 of Mathematica.

Any suggestions?

• What do you mean by equally placed? The distance between the points have to be equal or what? Apr 30 '16 at 9:03
• @RunnyKine I mean that there must be so many points $(N)$ so that there no holes in the outer shell. The interior should not be visible. Apr 30 '16 at 9:07

Well, you can use DiscretizeGraphics and RandomPoint to achieve what you want:

P0 = ContourPlot3D[Φeff == E0, {x, -rm, rm}, {y, -rm, rm}, {z, -rm, rm},
Mesh -> None, Lighting -> None];


Note the Lighting -> None option, this is to circumvent a bug in DiscretizeGraphics that the good people at Wolfram refuse to fix.

gg = DiscretizeGraphics[P0];
pts = RandomPoint[gg, 30000]; (* increase the number of points if you like *)


• Well, I'm using v9 and DiscretizeGraphics as well as RandomPoint are not recognized. Apr 30 '16 at 9:16
• @Vaggelis_Z. How was I supposed to know your version of Mathematica? Apr 30 '16 at 9:17
• I'm really sorry. I will edit my post, including the version. Apr 30 '16 at 9:18
Clear["Global*"];
Φcl = (-G*Mcl)/Sqrt[x^2 + y^2 + z^2 + a^2];
Φeff = Φcl + 1/2*(κ2 - 4*ω^2)*x^2 + 1/2*v2*z^2;

G = 1; Mcl = 2.2; a = 0.182;
κ2 = 1.8; ω = 1; v2 = 7.6;

E0 = -3.2;

rm = 1;
P0 = ContourPlot3D[Φeff == E0, {x, -rm, rm}, {y, -rm, rm}, {z, -rm, rm},
Mesh -> None]


Now extract the points from the surface

pts = First@Cases[P0, GraphicsComplex[points_, ___] :> points, Infinity]
Length[pts]


26684

Graphics3D[{Opacity[0.1], Point[pts]}]


You can use Interpolation to generate a function for the surface as well using the data as a whole or segmentwise.