# How to generate a random point inside this region/discretize it?

Consider the following region:

theta[\[Eta]_] = 2*ArcTan[Exp[-\[Eta]]];
zConicalFrustum[z1_, z2_, \[Theta]_] :=
ConvexHullMesh[
Join @@ (Map[Append[#],
CirclePoints[# Tan[\[Theta]], 100]] & /@ {z1, z2})]
fout = zConicalFrustum[10, 18, theta[2.]];
fin = zConicalFrustum[10, 18, theta[5.]];
Dvol = RegionDifference[fout, fin];
Region[Style[Dvol, Opacity[0.1]], BoxRatios -> {1, 1, 1}, Boxed -> True, Axes -> True]


Its intersection with the plane

plane = Polygon[{{3/2, -3/2, 18}, {3/2, 3/2, 18}, {-3/2, 3/2, 18}, {-3/2, -3/2, 18}}];


is

regInt=RegionIntersection[Dvol, plane]


Next, I want either to discretize it or generate random points belonging to it. However, I fail both of these tasks:

DiscretizeRegion[regInt, MaxCellMeasure -> MaxCellMeasureVal]]


DiscretizeRegion was unable to discretize the region BooleanRegion

RandomPoint[regInt, 3*10^4]


Argument RegionMeshCrossingCount at position 1 should be a rank 1 tensor of machine-size integers

• You code does not evaluate, what is theta? Commented Feb 24, 2023 at 10:59
• @user21 : excuse me, I have added the missing definition. Commented Feb 24, 2023 at 11:18
• Both of the solid and the polygon have the same height 18, and the polygon only the part of the upper disk, so the intersection of the two objects only the original polygon remove the center small disk. Commented Feb 24, 2023 at 11:56
• Is there some more general problem that you need to solve? Given @cvgmt 's comment and your desired region is just a square with a circular hole in it, is there something else? Squares at differ heights and/or sizes and/or orientations in the Dvol region?
– JimB
Commented Feb 25, 2023 at 6:30

Here is a dirty way to do it:

Needs["NDSolveFEM"]
Needs["OpenCascadeLink"]

theta[\[Eta]_] = 2*ArcTan[Exp[-\[Eta]]];
zConicalFrustum[z1_, z2_, \[Theta]_] :=
ToBoundaryMesh[
"Coordinates" ->
Join @@ (Map[Append[#],
CirclePoints[# Tan[\[Theta]], 100]] & /@ {z1, z2})]
fout = zConicalFrustum[10, 18, theta[2.]];
fin = zConicalFrustum[10, 18, theta[5.]];
(*Dvol=RegionDifference[fout,fin];*)

`