6
$\begingroup$

This is an example to make Pi in 3D dimension

Thanks @xzczd for providing the fast version. Link Smoothing the Region?

r = RegionProduct[#, Line[{{0.}, {10.}}]] &@
        ImageMesh@ColorNegate@ImageResize[Rasterize[" \[Pi]"], 100];
r2 = TransformedRegion[r, TranslationTransform[-RegionCentroid@r]];
r3 = RegionUnion@
        Table[TransformedRegion[RepairMesh@r2, 
        RotationTransform[i, {0, 1, 0}]], {i, -Pi/6, Pi/6, Pi/75}];
cy = DiscretizeRegion@Ball[{0, 0, 0}, 15];
RegionIntersection[r3, cy]

enter image description here

The visualization failed, but RegionEmbeddingDimension shows the dimensions are same.

RegionIntersection says: RegionIntersection is defined only for regions with the same RegionEmbeddingDimension:

{RegionDimension /@ {r3, cy}, RegionEmbeddingDimension /@ {r3, cy}}
(* Yes, Different dimension {{2, 3}, {3, 3}} *)

Also failed by repairing the mesh

cyrepair = RepairMesh@cy;
RegionIntersection[r3, cyrepair]
(* Not worked *)
{RegionDimension /@ {r3, cyrepair}, RegionEmbeddingDimension /@ {r3, cyrepair}}
(* {{2, 2}, {3, 3}} *)

However, the code works if all dimension of regions are same.

{RegionDimension /@ {r2, cy}, RegionEmbeddingDimension /@ {r2, cy}}
RegionIntersection[r2, cy]
(* {{3, 3}, {3, 3}} *)

enter image description here

$\endgroup$
2
  • $\begingroup$ Did you manage to solve this? I currently have the same problem and cannot find a solution $\endgroup$ Commented Jun 27, 2021 at 14:44
  • $\begingroup$ Then I used Shapr3D on iPad.... $\endgroup$ Commented Aug 13, 2021 at 8:18

1 Answer 1

7
$\begingroup$
  • For Version 14.2.1 or later, we can do such intersection all in OpenCascade package, need not use RepairMesh etc.
  • In the original code, there is blank in the text " π".
Clear["Global`*"];
$Version 
(* "14.2.1 for Mac OS X ARM (64-bit) (March 16, 2025)" *)
Needs["OpenCascadeLink`"];
Needs["NDSolve`FEM`"];
ball = Ball[{0, 0, 0}, 15];
reg = Polygon@
   MeshCoordinates@
    BoundaryDiscretizeRegion@
     ImageMesh@ColorNegate@ImageResize[Rasterize[" π"], 100];
shape0 = 
  OpenCascadeShapeLinearSweep[
   OpenCascadeShape@reg, {{0, 0, 0}, {0, 0, 10}}];
(* for other version, uncomment this *)
(*  shape0 = 
  OpenCascadeShape[
   ToBoundaryMesh[RegionProduct[reg, Line[{{0.}, {10}}]]]];  *)
r = OpenCascadeShapeSurfaceMeshToBoundaryMesh[shape0] // 
   BoundaryMeshRegion;
bm0 = OpenCascadeShapeSurfaceMeshToBoundaryMesh[shape0];
shape0 = 
  OpenCascadeShapeTransformation[shape0, 
   TranslationTransform[-RegionCentroid@r]];
shape1 = 
  OpenCascadeShapeUnion@
   Table[OpenCascadeShapeTransformation[shape0, 
     RotationTransform[i, {0, 1, 0}]], {i, -Pi/6, Pi/6, Pi/75}];
shape2 = OpenCascadeShape[ball];
shape12 = OpenCascadeShapeIntersection[shape1, shape2];
mesh1 = OpenCascadeShapeSurfaceMeshToBoundaryMesh@shape1;
mesh12 = OpenCascadeShapeSurfaceMeshToBoundaryMesh@shape12;
  • The Blue-Cyan region is the intersection of the ball(Yellow) and the rotation region of π ( Magenta ).
{mesh1["Wireframe"[
    "MeshElementStyle" -> 
     Directive[Opacity[.1], FaceForm[Magenta], EdgeForm[]], 
    Lighting -> "ThreePoint"]], 
  mesh12["Wireframe"[
    "MeshElementStyle" -> Directive[FaceForm[Blue], EdgeForm[Cyan]], 
    Lighting -> "ThreePoint"]], 
  Graphics3D[{Opacity[.1], Yellow, ball}]} // Show

enter image description here

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.