\begin{ccRefFunction}{intersection} \ccInclude{CGAL/intersections_d.h} \ccFunction{Object intersection(Type1 f1, Type2 f2);} {returns the intersection result of $f1$ and $f2$ by means of the polymorphic wrapper type \ccc{Object}. The returned object can be tested for the intersection result and assigned by means of the \ccc{object_cast} function. \ccPrecond{The objects are of the same dimension.}} 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 Type1 & Type2 & \parbox{4 cm}{\vspace{1 mm}{Return Type}} \\ \hline \ccStyle{Line_d} & \ccStyle{Line_d} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_d}, \ccStyle{Line_d} \vspace{1 mm}} \\ \hline \ccStyle{Segment_d} & \ccStyle{Line_d} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_d}, \ccStyle{Segment_d} \vspace{1 mm}} \\ \hline \ccStyle{Segment_d} & \ccStyle{Segment_d} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_d}, \ccStyle{Segment_d} \vspace{1 mm}} \\ \hline \ccStyle{Ray_d} & \ccStyle{Line_d} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_d}, \ccStyle{Ray_d} \vspace{1 mm}} \\ \hline \ccStyle{Ray_d} & \ccStyle{Segment_d} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_d}, \ccStyle{Segment_d} \vspace{1 mm}} \\ \hline \ccStyle{Ray_d} & \ccStyle{Ray_d} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_d}, \ccStyle{Segment_d}, \ccStyle{Ray_d} \vspace{1 mm}} \\ \hline \ccStyle{Hyperplane_d} & \ccStyle{Line_d} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_3}, \ccStyle{Line_3} \vspace{1 mm}} \\ \hline \ccStyle{Hyperplane_d} & \ccStyle{Ray_d} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_d}, \ccStyle{Ray_d} \vspace{1 mm}} \\ \hline \ccStyle{Hyperplane_d} & \ccStyle{Segment_d} & \parbox{4 cm}{\vspace{1 mm} \ccStyle{Point_d}, \ccStyle{Segment_d} \vspace{1 mm}} \\ \hline \end{longtable} \end{ccTexOnly} \begin{ccHtmlOnly}
Type1 Type2 Return Type
Line_d Line_d
Point_d
Line_d
Segment_d Line_d
Point_d
Segment_d
Segment_d Segment_d
Point_d
Segment_d
Ray_d Line_d
Point_d
Ray_d
Ray_d Segment_d
Point_d
Segment_d
Ray_d Ray_d
Point_d
Segment_d
Ray_d
Hyperplane_d Line_d
Point_d
Line_d
Hyperplane_d Ray_d
Point_d
Ray_d
Hyperplane_d Segment_d
Point_d
Segment_d
\end{ccHtmlOnly} \ccExample The following example demonstrates the most common use of \ccc{intersection} routines. \ccHtmlLinksOff% \begin{verbatim} #include template void foo(Segment_d seg, Line_d lin) { Object result = intersection(seg, lin); if (const Point_d *ipnt = object_cast >(&result) ) { // handle the point intersection case with *ipnt. } else if (const Segment_d *iseg = object_cast >(&result) ) { // handle the segment intersection case with *iseg. } else { // handle the no intersection case. } } \end{verbatim}% \ccHtmlLinksOn% \ccSeeAlso \ccc{do_intersect}, \ccc{Kernel::Intersect_d} \end{ccRefFunction}