|
CGAL 4.4 - 2D and 3D Linear Geometry Kernel
|
Functions | |
| template<typename Kernel > | |
| cpp11::result_of < Kernel::Intersect_23(Type1, Type2)>::type | CGAL::intersection (Type1< Kernel > obj1, Type2< Kernel > obj2) |
Two objects obj1 and obj2 intersect if there is a point p that is part of both obj1 and obj2. More... | |
| template<typename Kernel > | |
| boost::optional < boost::variant< Point_3, Line_3, Plane_3 > > | CGAL::intersection (const Plane_3< Kernel > &pl1, const Plane_3< Kernel > &pl2, const Plane_3< Kernel > &pl3) |
| returns the intersection of 3 planes, which can be a point, a line, a plane, or empty. More... | |
| cpp11::result_of<Kernel::Intersect_23(Type1, Type2)>::type CGAL::intersection | ( | Type1< Kernel > | obj1, |
| Type2< Kernel > | obj2 | ||
| ) |
Two objects obj1 and obj2 intersect if there is a point p that is part of both obj1 and obj2.
The intersection region of those two objects is defined as the set of all points p that are part of both obj1 and obj2. Note that for objects like triangles and polygons that enclose a bounded region, this region is considered part of the object. If a segment lies completely inside a triangle, then those two objects intersect and the intersection region is the complete segment.
Here, Intersect_23 means either Intersect_2 or Intersect_3, depending on the arguments.
The following tables give the possible values for Type1 and Type2.
2D intersections
The return type can be obtained through cpp11::result_of<Kernel::Intersect_2(A, B)>::type. It is equivalent to boost::optional< boost::variant< T... > >, the last column in the table providing the template parameter pack.
| Type1 | Type2 | Return Type: T... |
|---|---|---|
| Iso_rectangle_2 | Iso_rectangle_2 | |
| Iso_rectangle_2 | Line_2 | Point_2, or Segment_2 |
| Iso_rectangle_2 | Ray_2 | Point_2, or Segment_2 |
| Iso_rectangle_2 | Segment_2 | Point_2, or Segment_2 |
| Iso_rectangle_2 | Triangle_2 | Point_2, or Segment_2, or Triangle_2, or std::vector<Point_2> |
| Line_2 | Line_2 | Point_2, or Line_2 |
| Line_2 | Ray_2 | Point_2, or Ray_2 |
| Line_2 | Segment_2 | Point_2, or Segment_2 |
| Line_2 | Triangle_2 | Point_2, or Segment_2 |
| Ray_2 | Ray_2 | Point_2, or Segment_2, or Ray_2 |
| Ray_2 | Segment_2 | Point_2, or Segment_2 |
| Ray_2 | Triangle_2 | Point_2, or Segment_2 |
| Segment_2 | Segment_2 | Point_2, or Segment_2 |
| Segment_2 | Triangle_2 | Point_2, or Segment_2 |
| Triangle_2 | Triangle_2 | Point_2, or Segment_2, or Triangle_2, or std::vector<Point_2> |
3D intersections
The return type can be obtained through cpp11::result_of<Kernel::Intersect_3(A, B)>::type. It is equivalent to boost::optional< boost::variant< T... > >, the last column in the table providing the template parameter pack.
| Type1 | Type2 | Return Type: T... |
|---|---|---|
| Line_3 | Line_3 | Point_3, or Line_3 |
| Line_3 | Plane_3 | Point_3, or Line_3 |
| Line_3 | Ray_3 | Point_3, or Ray_3 |
| Line_3 | Segment_3 | Point_3, or Segment_3 |
| Line_3 | Triangle_3 | Point_3, or Segment_3 |
| Plane_3 | Plane_3 | Line_3, or Plane_3 |
| Plane_3 | Ray_3 | Point_3, or Ray_3 |
| Plane_3 | Segment_3 | Point_3, or Segment_3 |
| Plane_3 | Sphere_3 | Point_3, or Circle_3 |
| Plane_3 | Triangle_3 | Point_3, or Segment_3, or Triangle_3 |
| Ray_3 | Ray_3 | Point_3, or Ray_3, or Segment_3 |
| Ray_3 | Segment_3 | Point_3, or Segment_3 |
| Ray_3 | Triangle_3 p | Point_3, or Segment_3 |
| Segment_3 | Segment_3 | Point_3, or Segment_3 |
| Segment_3 | Triangle_3 | Point_3, or Segment_3 |
| Sphere_3 | Sphere_3 | Point_3, or Circle_3, or Sphere_3 |
| Triangle_3 | Triangle_3 | Point_3, or Segment_3, or Triangle_3, or std::vector < Point_3 > |
Example
The following example demonstrates the most common use of intersection routines with the 2D and 3D Linear Kernel.
Another example showing the use of the intersection function as a plain function call and with Dispatch_output_iterator combined with a standard library algorithm.
File Kernel_23/intersections.cpp