5
$\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$
    – physicien
    Jun 27, 2021 at 14:44
  • $\begingroup$ Then I used Shapr3D on iPad.... $\endgroup$
    – partida
    Aug 13, 2021 at 8:18

1 Answer 1

4
$\begingroup$
  • For Version 13, 14,we can do such intersection all in OpenCascade package, need not use RepairMesh etc.
  • In the original code, there is blank in the text " π".
r = RegionProduct[#, Line[{{0.}, {10.}}]] &@
   ImageMesh@ColorNegate@ImageResize[Rasterize[" π"], 100];

ball = Ball[{0, 0, 0}, 15];
Needs["OpenCascadeLink`"];
Needs["NDSolve`FEM`"];
bm0 = ToBoundaryMesh[r];
shape0 = 
  OpenCascadeShapeTransformation[OpenCascadeShape@bm0, 
   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$

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.