Problem: Find the intersection of a cylinder and a plane
The intersection of a cylinder and a plane is the projection of the bottom (top, respectively) circle onto the plane - which is an ellipse. Following example uses the EllipticalCone class to visualize a circular cylinder. The projected ellipse (green) and the edge of the sliced cylinder are identical.
Solution using V#
- public static void CylinderPlaneIntersection()
- {
- // Create an elliptical cone (a circular cylinder, in this case)
- // height of the cylinder is 5
- Ellipse bottomEllipse = new Circle(
- // We don't want the covers here:
- cylinder.HasCover = false;
- // the slicing plane
- // calculate the projection of the (circular) bottom ellipse
- // onto the plane (this is the intersection of the cylinder and
- // the slicing plane!)
- Ellipse el = bottomEllipse.
- ProjectParallelOn(pl, bottomEllipse.NormalVector);
- // 50 triangles forming the surface of the cone:
- List<Triangle> cylinderSurface = cylinder.GetSurface(50);
- // A list containing the sliced surface
- // slice the elliptical cone
- for ( int i = 0; i < cylinderSurface.Count; i++ )
- {
- slicedCylinder.AddRange
- (cylinderSurface[i].Slice(pl, Triangle.SliceMethod.KeepBelow));
- }
- // Visualize-----------------------------------------------------------
- // Make a scene
- // A layer for the sliced elliptical cone:
- // A layer for the slicing plane:
- // A layer for the intersection ellipse
- // add all to the scene
- sc.Add(slicedCylinder, cylinerLayer);
- sc.Add(pl, planeLayer, 3);
- sc.Add(el, ellipseLayer);
- // output the scene as dxf
- sc.WriteDxf(@"c:\cylinder_plane_intersection.dxf");
- }


