Examples

Problem: Find the intersection points of a coplanar circle and triangle

Use the intersect2d - methods to intersect the perimeters of planar objects beeing coplanar to each other. In contrast, use the intersect3d methods to find the intersection of planar objects beeing non-coplanar to each other.

Solution using V#

  1.    public static void CoplanarCircleTriangleIntersection()
  2.     {
  3.         // Create a triangle
  4.         Point p1 = new Point(-1, 0, -1);
  5.         Point p2 = new Point(1, 0, 1);
  6.         Point p3 = new Point(0, 1, 0);
  7.         Triangle t = new Triangle(p1, p2, p3);
  8.  
  9.         // Create a circle
  10.         Circle c = new Circle(new Point(0, 0, 0), 1, new Vector3d(-1, 0, 1));
  11.  
  12.         // Compute the intersection
  13.         PointSet intersectionPoints = t.Intersect2d(c);
  14.  
  15.         // Visualize: ----------------------------------------------------------
  16.         // Make a scene
  17.         Scene sc = new Scene();
  18.  
  19.         // Set the point display style
  20.         sc.PointDisplayMode = 2;
  21.         sc.PointSize = 0.05;
  22.  
  23.         // Make some layers
  24.         Scene.Layer cLayer = new Scene.Layer("Circle", 1);
  25.         Scene.Layer tLayer = new Scene.Layer("Triangle", 2);
  26.         Scene.Layer pLayer = new Scene.Layer("Intersection_points", 3);
  27.  
  28.         // Add all to the scene
  29.         sc.Add(c, cLayer);
  30.         sc.Add(t, tLayer);
  31.         sc.Add(intersectionPoints, pLayer);
  32.  
  33.         // output the scene as dxf
  34.         sc.WriteDxf(@"c:\triangle_circle_coplanar.dxf");
  35.     }

Output

Fig. 1: A circle coplanar to a triangle and the intersection points of their perimeters.

<<back