\begin{ccRefFunction}{intersection} \ccInclude{CGAL/intersections.h} \ccUnchecked{ \ccFunction{Object intersection(Type1 obj1, Type2 obj2);} {Two objects \ccStyle{obj1} and \ccStyle{obj2} intersect if there is a point \ccStyle{p} that is part of both \ccStyle{obj1} and \ccStyle{obj2}. The \ccHtmlNoLinksFrom{intersection} region of those two objects is defined as the set of all points \ccStyle{p} that are part of both \ccStyle{obj1} and \ccStyle{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 \ccHtmlNoLinksFrom{intersection} region is the complete segment. }} The possible value for types \ccStyle{Type1} and \ccStyle{Type2} and the possible return values wrapped in \ccc{Object} are the following: \begin{ccTexOnly} \begin{longtable}[c]{|l|l|l|} %\caption{All available intersection computations}\\ \multicolumn{3}{l}{\sl \ \ } \endfirsthead \multicolumn{3}{l}{\sl continued} \endhead \hline type A & type B & \parbox{4 cm}{\vspace{1 mm}{return type}} \\ \hline \ccStyle{Line_2} & \ccStyle{Line_2} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_2} \\ \ccStyle{Line_2} \vspace{1 mm}} \\ \hline \ccStyle{Segment_2} & \ccStyle{Line_2} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_2} \\ \ccStyle{Segment_2} \vspace{1 mm}} \\ \hline \ccStyle{Segment_2} & \ccStyle{Segment_2} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_2} \\ \ccStyle{Segment_2} \vspace{1 mm}} \\ \hline \ccStyle{Ray_2} & \ccStyle{Line_2} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_2} \\ \ccStyle{Ray_2} \vspace{1 mm}} \\ \hline \ccStyle{Ray_2} & \ccStyle{Segment_2} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_2} \\ \ccStyle{Segment_2} \vspace{1 mm}} \\ \hline \ccStyle{Ray_2} & \ccStyle{Ray_2} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_2} \\ \ccStyle{Segment_2} \\ \ccStyle{Ray_2} \vspace{1 mm}} \\ \hline \ccStyle{Triangle_2} & \ccStyle{Line_2} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_2} \\ \ccStyle{Segment_2} \vspace{1 mm}} \\ \hline \ccStyle{Triangle_2} & \ccStyle{Segment_2} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_2} \\ \ccStyle{Segment_2} \vspace{1 mm}} \\ \hline \ccStyle{Triangle_2} & \ccStyle{Ray_2} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_2} \\ \ccStyle{Segment_2} \vspace{1 mm}} \\ \hline \ccStyle{Triangle_2} & \ccStyle{Triangle_2} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_2} \\ \ccStyle{Segment_2} \\ \ccStyle{Triangle_2} \\ \ccStyle{std::vector} \vspace{1 mm}} \\ \hline \ccStyle{Iso_rectangle_2} & \ccStyle{Line_2} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_2} \\ \ccStyle{Segment_2} \vspace{1 mm}} \\ \hline \ccStyle{Iso_rectangle_2} & \ccStyle{Segment_2} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_2} \\ \ccStyle{Segment_2} \vspace{1 mm}} \\ \hline \ccStyle{Iso_rectangle_2} & \ccStyle{Ray_2} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_2} \\ \ccStyle{Segment_2} \vspace{1 mm}} \\ \hline \ccStyle{Iso_rectangle_2} & \ccStyle{Iso_rectangle_2} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Iso_rectangle_2} \vspace{1 mm}} \\ \hline {\ccStyle{Plane_3}} & {\ccStyle{Line_3}} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_3} \\ \ccStyle{Line_3} \vspace{1 mm}} \\ \hline {\ccStyle{Plane_3}} & {\ccStyle{Ray_3}} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_3} \\ \ccStyle{Ray_3} \vspace{1 mm}} \\ \hline {\ccStyle{Plane_3}} & {\ccStyle{Segment_3}} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_3} \\ \ccStyle{Segment_3} \vspace{1 mm}} \\ \hline {\ccStyle{Plane_3}} & {\ccStyle{Plane_3}} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Line_3} \\ \ccStyle{Plane_3} \vspace{1 mm}} \\ \hline \end{longtable} \end{ccTexOnly} \begin{ccHtmlOnly}
type A type B return type
Line_2 Line_2
Point_2
Line_2
Segment_2 Line_2
Point_2
Segment_2
Segment_2 Segment_2
Point_2
Segment_2
Ray_2 Line_2
Point_2
Ray_2
Ray_2 Segment_2
Point_2
Segment_2
Ray_2 Ray_2
Point_2
Segment_2
Ray_2
Triangle_2 Line_2
Point_2
Segment_2
Triangle_2 Segment_2
Point_2
Segment_2
Triangle_2 Ray_2
Point_2
Segment_2
Triangle_2 Triangle_2
Point_2
Segment_2
Triangle_2
std::vector<Point_2>
Iso_rectangle_2 Line_2
Point_2
Segment_2
Iso_rectangle_2 Segment_2
Point_2
Segment_2
Iso_rectangle_2 Ray_2
Point_2
Segment_2
Iso_rectangle_2 Iso_rectangle_2
Iso_rectangle_2
Plane_3 Line_3
Point_3
Line_3
Plane_3 Ray_3
Point_3
Ray_3
Plane_3 Segment_3
Point_3
Segment_3
Plane_3 Plane_3
Line_3
Plane_3
\end{ccHtmlOnly} There is also an intersection function between 3 planes. \ccFunction{Object intersection(const Plane_3& pl1, const Plane_3& pl2, const Plane_3& pl3);} {returns the intersection of 3 planes, which can be either a point, a line, a plane, or empty.} \ccExample The following example demonstrates the most common use of \ccc{intersection} routines. \begin{verbatim} #include void foo(CGAL::Segment_2 seg, CGAL::Line_2 line) { CGAL::Object result; CGAL::Point_2 ipoint; CGAL::Segment_2 iseg; result = CGAL::intersection(seg, line); if (CGAL::assign(ipoint, result)) { \end{verbatim}% \ccHtmlLinksOff% \begin{verbatim} // handle the point intersection case. \end{verbatim}% \ccHtmlLinksOn% \begin{verbatim} } else if (CGAL::assign(iseg, result)) { \end{verbatim}% \ccHtmlLinksOff% \begin{verbatim} // handle the segment intersection case. \end{verbatim}% \ccHtmlLinksOn% \begin{verbatim} } else { \end{verbatim}% \ccHtmlLinksOff% \begin{verbatim} // handle the no intersection case. } } \end{verbatim}% \ccHtmlLinksOn% \ccSeeAlso \ccRefIdfierPage{CGAL::assign} \\ \ccRefIdfierPage{CGAL::do_intersect} \\ \ccRefIdfierPage{CGAL::Object} \\ \end{ccRefFunction}