Skip to main content
Show the centroid of the cone-plane intersection polygon surface too.
Source Link
flinty
  • 25.9k
  • 2
  • 22
  • 92

Mathematica's region / Boolean CSG stuff is sadly very buggy, even in some simple cases like this where you really wouldn't expect it. I'm hoping it improves in future versions. To work around this I discretize the mesh into polygons and intersect each polygon individually, building up a list of EmptyRegion[3] and lines. The empty regions are discarded.

mesh1 = DiscretizeRegion@pr1;
prims = MeshPrimitives[mesh1, 2];
intersections = DeleteCases[RegionIntersection[#, pr2] & /@ prims, EmptyRegion[_]];
curveregion = RegionUnion[intersections];
Graphics3D[{{Red, EdgeForm[None], mesh1}, Blue, pr2, Yellow, Thick, 
  intersections}, BoxRatios -> 1]

RegionMeasure[curveregion]
(* result: 19.3212 *)

ellipse cone plane intersection

Of course, this just gets you the curve around the edge of the cone. If you want the surface on the interior for things like area / integration etc., then you'll need to do construct a polygon from the intersection coordinates. I extract the coordinates from the line and perform a FindShortestTour because they need to be reordered as we wind around the curve. I do not display the plane due to z-fighting in the graphics.

interiorsurface = 
  Polygon[#[[Last[FindShortestTour[#]]]] &@intersections[[AllPolygon[#[[Last@FindShortestTour@#]]&@intersections[[All, 1, 1]]];
centroid = RegionCentroid[interiorsurface];
Graphics3D[{{Red, EdgeForm[None], mesh1}, Yellow, Thick, 
  intersections, interiorsurface, Green, PointSize[.02], 
  Point[centroid]}, BoxRatios -> 1]

RegionMeasure[interiorsurface]
(* result: 25.2026 *)

cone ellipse plane surface intersectioncone ellipse intersection with surface and centroid

Mathematica's region / Boolean CSG stuff is sadly very buggy, even in some simple cases like this where you really wouldn't expect it. I'm hoping it improves in future versions. To work around this I discretize the mesh into polygons and intersect each polygon individually, building up a list of EmptyRegion[3] and lines. The empty regions are discarded.

mesh1 = DiscretizeRegion@pr1;
prims = MeshPrimitives[mesh1, 2];
intersections = DeleteCases[RegionIntersection[#, pr2] & /@ prims, EmptyRegion[_]];
curveregion = RegionUnion[intersections];
Graphics3D[{{Red, EdgeForm[None], mesh1}, Blue, pr2, Yellow, Thick, 
  intersections}, BoxRatios -> 1]

RegionMeasure[curveregion]
(* result: 19.3212 *)

ellipse cone plane intersection

Of course, this just gets you the curve around the edge of the cone. If you want the surface on the interior for things like area / integration etc., then you'll need to do construct a polygon from the intersection coordinates. I extract the coordinates from the line and perform a FindShortestTour because they need to be reordered as we wind around the curve. I do not display the plane due to z-fighting in the graphics.

interiorsurface = 
  Polygon[#[[Last[FindShortestTour[#]]]] &@intersections[[All, 1, 1]]];
Graphics3D[{{Red, EdgeForm[None], mesh1}, Yellow, Thick, 
  interiorsurface}, BoxRatios -> 1]

RegionMeasure[interiorsurface]
(* result: 25.2026 *)

cone ellipse plane surface intersection

Mathematica's region / Boolean CSG stuff is sadly very buggy, even in some simple cases like this where you really wouldn't expect it. I'm hoping it improves in future versions. To work around this I discretize the mesh into polygons and intersect each polygon individually, building up a list of EmptyRegion[3] and lines. The empty regions are discarded.

mesh1 = DiscretizeRegion@pr1;
prims = MeshPrimitives[mesh1, 2];
intersections = DeleteCases[RegionIntersection[#, pr2] & /@ prims, EmptyRegion[_]];
curveregion = RegionUnion[intersections];
Graphics3D[{{Red, EdgeForm[None], mesh1}, Blue, pr2, Yellow, Thick, 
  intersections}, BoxRatios -> 1]

RegionMeasure[curveregion]
(* result: 19.3212 *)

ellipse cone plane intersection

Of course, this just gets you the curve around the edge of the cone. If you want the surface on the interior for things like area / integration etc., then you'll need to construct a polygon from the intersection coordinates. I extract the coordinates from the line and perform a FindShortestTour because they need to be reordered as we wind around the curve. I do not display the plane due to z-fighting in the graphics.

interiorsurface = Polygon[#[[Last@FindShortestTour@#]]&@intersections[[All,1,1]]];
centroid = RegionCentroid[interiorsurface];
Graphics3D[{{Red, EdgeForm[None], mesh1}, Yellow, Thick, 
  intersections, interiorsurface, Green, PointSize[.02], 
  Point[centroid]}, BoxRatios -> 1]

RegionMeasure[interiorsurface]
(* result: 25.2026 *)

cone ellipse intersection with surface and centroid

added 883 characters in body
Source Link
flinty
  • 25.9k
  • 2
  • 22
  • 92

Mathematica's region / Boolean CSG stuff is sadly very buggy, even in some simple cases like this where you really wouldn't expect it. I'm hoping it improves in future versions. To work around this I discretize the mesh into polygons and intersect each polygon individually, building up a list of EmptyRegion[3] and lines. The empty regions are discarded.

mesh1 = DiscretizeRegion@pr1;
prims = MeshPrimitives[mesh1, 2];
intersections = DeleteCases[RegionIntersection[#, pr2] & /@ prims, EmptyRegion[_]];
curveregion = RegionUnion[intersections];
Graphics3D[{{Red, EdgeForm[None], mesh1}, Blue, pr2, Yellow, Thick, 
  intersections}, BoxRatios -> 1]

RegionMeasure[curveregion]
(* result: 19.3212 *)

ellipse cone plane intersection

Of course, this just gets you the curve around the edge of the cone. If you want the surface on the interior for things like area / integration etc., then you'll need to do construct a polygon from the intersection coordinates. I extract the coordinates from the line and perform a FindShortestTour because they need to be reordered as we wind around the curve. I do not display the plane due to z-fighting in the graphics.

interiorsurface = 
  Polygon[#[[Last[FindShortestTour[#]]]] &@intersections[[All, 1, 1]]];
Graphics3D[{{Red, EdgeForm[None], mesh1}, Yellow, Thick, 
  interiorsurface}, BoxRatios -> 1]

RegionMeasure[interiorsurface]
(* result: 25.2026 *)

cone ellipse plane surface intersection

Mathematica's region / Boolean CSG stuff is sadly very buggy, even in some simple cases like this where you really wouldn't expect it. I'm hoping it improves in future versions. To work around this I discretize the mesh into polygons and intersect each polygon individually, building up a list of EmptyRegion[3] and lines. The empty regions are discarded.

mesh1 = DiscretizeRegion@pr1;
prims = MeshPrimitives[mesh1, 2];
intersections = DeleteCases[RegionIntersection[#, pr2] & /@ prims, EmptyRegion[_]];
Graphics3D[{{Red, EdgeForm[None], mesh1}, Blue, pr2, Yellow, Thick, 
  intersections}, BoxRatios -> 1]

ellipse cone plane intersection

Mathematica's region / Boolean CSG stuff is sadly very buggy, even in some simple cases like this where you really wouldn't expect it. I'm hoping it improves in future versions. To work around this I discretize the mesh into polygons and intersect each polygon individually, building up a list of EmptyRegion[3] and lines. The empty regions are discarded.

mesh1 = DiscretizeRegion@pr1;
prims = MeshPrimitives[mesh1, 2];
intersections = DeleteCases[RegionIntersection[#, pr2] & /@ prims, EmptyRegion[_]];
curveregion = RegionUnion[intersections];
Graphics3D[{{Red, EdgeForm[None], mesh1}, Blue, pr2, Yellow, Thick, 
  intersections}, BoxRatios -> 1]

RegionMeasure[curveregion]
(* result: 19.3212 *)

ellipse cone plane intersection

Of course, this just gets you the curve around the edge of the cone. If you want the surface on the interior for things like area / integration etc., then you'll need to do construct a polygon from the intersection coordinates. I extract the coordinates from the line and perform a FindShortestTour because they need to be reordered as we wind around the curve. I do not display the plane due to z-fighting in the graphics.

interiorsurface = 
  Polygon[#[[Last[FindShortestTour[#]]]] &@intersections[[All, 1, 1]]];
Graphics3D[{{Red, EdgeForm[None], mesh1}, Yellow, Thick, 
  interiorsurface}, BoxRatios -> 1]

RegionMeasure[interiorsurface]
(* result: 25.2026 *)

cone ellipse plane surface intersection

Source Link
flinty
  • 25.9k
  • 2
  • 22
  • 92

Mathematica's region / Boolean CSG stuff is sadly very buggy, even in some simple cases like this where you really wouldn't expect it. I'm hoping it improves in future versions. To work around this I discretize the mesh into polygons and intersect each polygon individually, building up a list of EmptyRegion[3] and lines. The empty regions are discarded.

mesh1 = DiscretizeRegion@pr1;
prims = MeshPrimitives[mesh1, 2];
intersections = DeleteCases[RegionIntersection[#, pr2] & /@ prims, EmptyRegion[_]];
Graphics3D[{{Red, EdgeForm[None], mesh1}, Blue, pr2, Yellow, Thick, 
  intersections}, BoxRatios -> 1]

ellipse cone plane intersection