4

I am trying to find an intersection as per here with

pts=ToExpression/@Import["https://raw.githubusercontent.com/martinq321/points/main/pts","List"];
Graphics3D[{
    InfinitePlane[{{.5,0,0},{.5,1,1},{.5,1,0}}],Polygon@pts},
    Boxed->False,ViewPoint -> {1,  0,-6}, ViewVertical -> {1, 0, 0}
]
r1=RegionUnion[ConvexHullMesh/@pts];r2=InfinitePlane[{{.5,0,0},{.5,1,1},{.5,1,0}}];
r3=DeleteCases[RegionIntersection[r2,#]&/@MeshPrimitives[r1,2],_EmptyRegion];
line=Line[(r3[[##]][[1]]&@@@(Most/@Position[r3,Line]))];
Show[r1, Graphics3D[line]]

MMA completes the task, but it takes a very long time. Can I speed things up?

martin
  • 8,678
  • 4
  • 23
  • 70

1 Answers1

7

We rewrite the plane equation which through three points a,b,c by its implicit form. ({x, y, z} - a) . Cross[b - a, c - a] and set it as the MeshFunctions.

{a, b, c} = {{.5, 0, 0}, {.5, 1, 1}, {.5, 1, 0}};
RegionPlot3D[DiscretizeGraphics[Polygon@pts], Mesh -> {{0}}, 
 MeshFunctions -> 
  Function[{x, y, z}, ({x, y, z} - a) . Cross[b - a, c - a]], 
 ViewPoint -> {1, 0, -6}, ViewVertical -> {1, 0, 0}, 
 MeshStyle -> Thick, Boxed -> False, ColorFunction -> Hue]

enter image description here

cvgmt
  • 72,231
  • 4
  • 75
  • 133