0
$\begingroup$

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]

enter image description here

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

Could you please help me with either of these tasks?

$\endgroup$
4
  • $\begingroup$ You code does not evaluate, what is theta? $\endgroup$
    – user21
    Feb 24, 2023 at 10:59
  • $\begingroup$ @user21 : excuse me, I have added the missing definition. $\endgroup$ Feb 24, 2023 at 11:18
  • 2
    $\begingroup$ 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. $\endgroup$
    – cvgmt
    Feb 24, 2023 at 11:56
  • $\begingroup$ 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? $\endgroup$
    – JimB
    Feb 25, 2023 at 6:30

1 Answer 1

2
$\begingroup$

Here is a dirty way to do it:

Needs["NDSolve`FEM`"]
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];*)

s1 = OpenCascadeShape[fout];
s2 = OpenCascadeShape[fin];
s3 = OpenCascadeShapeDifference[s1, s2];
plane = Polygon[{{3/2, -3/2, 18}, {3/2, 3/2, 18}, {-3/2, 3/2, 
     18}, {-3/2, -3/2, 18}}];
s4 = OpenCascadeShape[plane];
s5 = OpenCascadeShapeIntersection[s3, s4];
bmesh = OpenCascadeShapeSurfaceMeshToBoundaryMesh[s5];

bmesh["Wireframe"]

enter image description here

A much, much better way to do this is to make a definition of the frustum that uses a region union of a Cone and a Cuboid to delimit the frustum. As an alternative you could use the two circles and loft the frustum.

$\endgroup$

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.