diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..9fd0f59a2cc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Packages/Distance_2/web/lis diff --git a/Packages/Distance_2/description.txt b/Packages/Distance_2/description.txt new file mode 100644 index 00000000000..8a55d40139e --- /dev/null +++ b/Packages/Distance_2/description.txt @@ -0,0 +1 @@ +Squared distance computations for simple 2D objects. diff --git a/Packages/Distance_2/doc_tex/Distance_2/main.tex b/Packages/Distance_2/doc_tex/Distance_2/main.tex new file mode 100644 index 00000000000..dee5f6c6de3 --- /dev/null +++ b/Packages/Distance_2/doc_tex/Distance_2/main.tex @@ -0,0 +1,72 @@ + +\cleardoublepage +\chapter{Squared Distances} + +There is a family of functions called \ccStyle{CGAL_squared_distance} that +compute the square of the Euclidean distance between two geometric objects. + +The squared distance between two two-dimensional points \ccStyle{p1} and +\ccStyle{p2} is defined as $d_{x}^{2} + d_{y}^{2}$, where $d_{x}$ +\ccTexHtml{$\equiv$}{==} +\ccStyle{p2.x()-p1.x()} and $d_{y}$\ccTexHtml{$\equiv$}{==} \ccStyle{p2.y()-p1.y()}. + +For arbitrary two-dimensional geometric objects \ccStyle{obj1} and +\ccStyle{obj2} the squared distance is defined as the minimal +\ccStyle{CGAL_squared_distance(p1, p2)}, where \ccStyle{p1} is a point of +\ccStyle{obj1} and \ccStyle{p2} is a point of \ccStyle{obj2}. +Note that for objects like triangles and polygons that have an inside (a +bounded region), this inside is part of the object. +So, the squared distance from a point inside a triangle to that triangle is +zero, not the squared distance to the closest edge of the triangle. + +The general format of the functions is: + +\ccUnchecked{ +\ccGlobalFunctionTemplate{R} +{R::FT CGAL_squared_distance(Type1 obj1, Type2 obj2);} +} + +\noindent +where the types \ccStyle{Type1} and \ccStyle{Type2} can be any of the +following: +\begin{itemize} +\item \ccStyle{CGAL_Point_2} +\item \ccStyle{CGAL_Line_2} +\item \ccStyle{CGAL_Ray_2} +\item \ccStyle{CGAL_Segment_2} +\item \ccStyle{CGAL_Triangle_2} +%\item \ccStyle{CGAL_Iso_Rectangle_2} +%\item \ccStyle{CGAL_Polygon_2} +\end{itemize} + +Those routines are defined in the header file +\ccStyle{CGAL/squared_distance.h}. + +\subsection{Why the square?} + +There are routines that compute the square of the Euclidean distance, but no +routines that compute the distance itself. Why? + +First of all, the two values can be derived from each other quite easily (by +taking the square root or taking the square). So, supplying only the one and +not the other is only a minor inconvenience for the user. + +Second, often either value can be used. This is for example the case when +(squared) distances are compared. + +Third, the library wants to stimulate the use of the squared distance instead +of the distance. The squared distance can be computed in more cases and the +computation is cheaper. +We do this by not providing the perhaps more natural routine, + +The problem of a distance routine is that it needs the \ccStyle{sqrt} +operation. +This has two drawbacks. +\begin{itemize} +\item +The \ccStyle{sqrt} operation can be costly. Even if it is not very costly for +a specific number type and platform, avoiding it is always cheaper. +\item +There are number types on which no \ccStyle{sqrt} operation is defined, +especially integer types and rationals. +\end{itemize} diff --git a/Packages/Distance_2/doc_tex/kernel/Distance_2/main.tex b/Packages/Distance_2/doc_tex/kernel/Distance_2/main.tex new file mode 100644 index 00000000000..dee5f6c6de3 --- /dev/null +++ b/Packages/Distance_2/doc_tex/kernel/Distance_2/main.tex @@ -0,0 +1,72 @@ + +\cleardoublepage +\chapter{Squared Distances} + +There is a family of functions called \ccStyle{CGAL_squared_distance} that +compute the square of the Euclidean distance between two geometric objects. + +The squared distance between two two-dimensional points \ccStyle{p1} and +\ccStyle{p2} is defined as $d_{x}^{2} + d_{y}^{2}$, where $d_{x}$ +\ccTexHtml{$\equiv$}{==} +\ccStyle{p2.x()-p1.x()} and $d_{y}$\ccTexHtml{$\equiv$}{==} \ccStyle{p2.y()-p1.y()}. + +For arbitrary two-dimensional geometric objects \ccStyle{obj1} and +\ccStyle{obj2} the squared distance is defined as the minimal +\ccStyle{CGAL_squared_distance(p1, p2)}, where \ccStyle{p1} is a point of +\ccStyle{obj1} and \ccStyle{p2} is a point of \ccStyle{obj2}. +Note that for objects like triangles and polygons that have an inside (a +bounded region), this inside is part of the object. +So, the squared distance from a point inside a triangle to that triangle is +zero, not the squared distance to the closest edge of the triangle. + +The general format of the functions is: + +\ccUnchecked{ +\ccGlobalFunctionTemplate{R} +{R::FT CGAL_squared_distance(Type1 obj1, Type2 obj2);} +} + +\noindent +where the types \ccStyle{Type1} and \ccStyle{Type2} can be any of the +following: +\begin{itemize} +\item \ccStyle{CGAL_Point_2} +\item \ccStyle{CGAL_Line_2} +\item \ccStyle{CGAL_Ray_2} +\item \ccStyle{CGAL_Segment_2} +\item \ccStyle{CGAL_Triangle_2} +%\item \ccStyle{CGAL_Iso_Rectangle_2} +%\item \ccStyle{CGAL_Polygon_2} +\end{itemize} + +Those routines are defined in the header file +\ccStyle{CGAL/squared_distance.h}. + +\subsection{Why the square?} + +There are routines that compute the square of the Euclidean distance, but no +routines that compute the distance itself. Why? + +First of all, the two values can be derived from each other quite easily (by +taking the square root or taking the square). So, supplying only the one and +not the other is only a minor inconvenience for the user. + +Second, often either value can be used. This is for example the case when +(squared) distances are compared. + +Third, the library wants to stimulate the use of the squared distance instead +of the distance. The squared distance can be computed in more cases and the +computation is cheaper. +We do this by not providing the perhaps more natural routine, + +The problem of a distance routine is that it needs the \ccStyle{sqrt} +operation. +This has two drawbacks. +\begin{itemize} +\item +The \ccStyle{sqrt} operation can be costly. Even if it is not very costly for +a specific number type and platform, avoiding it is always cheaper. +\item +There are number types on which no \ccStyle{sqrt} operation is defined, +especially integer types and rationals. +\end{itemize} diff --git a/Packages/Distance_2/make_release b/Packages/Distance_2/make_release new file mode 100755 index 00000000000..7cea8b8e6b3 --- /dev/null +++ b/Packages/Distance_2/make_release @@ -0,0 +1,21 @@ +#!/bin/sh + +if [ ! -d include ] +then + mkdir include + mkdir include/CGAL +fi + + +cd web +if [ ! -d lis ] +then + mkdir lis +fi + +make xsrcs + +echo "Now adapt version and description.txt and run make_zip" + + + diff --git a/Packages/Distance_2/make_zip b/Packages/Distance_2/make_zip new file mode 100755 index 00000000000..0a5bb50623c --- /dev/null +++ b/Packages/Distance_2/make_zip @@ -0,0 +1,3 @@ +#!/bin/sh + +zip -r Distance_2.zip version description.txt include test doc_tex diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst21/ix.1 b/Packages/Distance_2/test/Distance_2/DATA/tst21/ix.1 new file mode 100644 index 00000000000..c24f9d01111 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst21/ix.1 @@ -0,0 +1,2 @@ +1 1 +4 0 -3 -1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/i.1 b/Packages/Distance_2/test/Distance_2/DATA/tst22/i.1 new file mode 100644 index 00000000000..f2b423101b0 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/i.1 @@ -0,0 +1,2 @@ +1 0 0 1 +0.5 0.5 2 0 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/i.2 b/Packages/Distance_2/test/Distance_2/DATA/tst22/i.2 new file mode 100644 index 00000000000..599d7aeebc5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/i.2 @@ -0,0 +1,2 @@ +1 0 0 1 +0.6 0.6 2 0 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/i.3 b/Packages/Distance_2/test/Distance_2/DATA/tst22/i.3 new file mode 100644 index 00000000000..e24895a5ac8 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/i.3 @@ -0,0 +1,2 @@ +-1 -1.3 0 1 +1 0.5 7 -3 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/i.4 b/Packages/Distance_2/test/Distance_2/DATA/tst22/i.4 new file mode 100644 index 00000000000..f4d8e850853 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/i.4 @@ -0,0 +1,2 @@ +0 0 3 -1 +-0.5 2 4 3 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.1 b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.1 new file mode 100644 index 00000000000..bd57ba16fc1 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.1 @@ -0,0 +1,2 @@ +-8 -7 11 6 +23 -27 -17 16 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.10 b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.10 new file mode 100644 index 00000000000..1ff6b0c687a --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.10 @@ -0,0 +1,2 @@ +5 0 0 0 +1 1 2 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.11 b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.11 new file mode 100644 index 00000000000..a1e9a48303b --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.11 @@ -0,0 +1,2 @@ +0 0 5 0 +6 1 8 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.12 b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.12 new file mode 100644 index 00000000000..7b433c61976 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.12 @@ -0,0 +1,2 @@ +0 0 0 -3 +1 4 1 7 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.13 b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.13 new file mode 100644 index 00000000000..d8bc22f9b9b --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.13 @@ -0,0 +1,2 @@ +0 0 0 0 +8 1 6 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.14 b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.14 new file mode 100644 index 00000000000..3a0c4a684ed --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.14 @@ -0,0 +1,2 @@ +0 0 5 0 +8 1 6 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.15 b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.15 new file mode 100644 index 00000000000..b2fe52e097b --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.15 @@ -0,0 +1,2 @@ +0 0 5 0 +8 0 12 0 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.16 b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.16 new file mode 100644 index 00000000000..356661b0d13 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.16 @@ -0,0 +1,2 @@ +0 0 5 0 +8 1 12 1.1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.2 b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.2 new file mode 100644 index 00000000000..f81bf5c6105 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.2 @@ -0,0 +1,2 @@ +0 0 1 0 +2 1 2 -1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.3 b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.3 new file mode 100644 index 00000000000..a70877939fe --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.3 @@ -0,0 +1,2 @@ +4 0 -3 -1 +1 1 2 11 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.4 b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.4 new file mode 100644 index 00000000000..abbdb39b6a3 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.4 @@ -0,0 +1,2 @@ +3 4 7 7 +7 0 6 5 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.5 b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.5 new file mode 100644 index 00000000000..1ebd58ba355 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.5 @@ -0,0 +1,2 @@ +-1 1 3 4 +7 0 6 5 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.6 b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.6 new file mode 100644 index 00000000000..3a1dc7fd470 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.6 @@ -0,0 +1,2 @@ +0 0 5 0 +1 1 6 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.7 b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.7 new file mode 100644 index 00000000000..280ba40491b --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.7 @@ -0,0 +1,2 @@ +0 0 5 0 +1 1 2 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.8 b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.8 new file mode 100644 index 00000000000..ce420595853 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.8 @@ -0,0 +1,2 @@ +5 0 8 0 +1 1 2 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.9 b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.9 new file mode 100644 index 00000000000..1ff6b0c687a --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst22/ix.9 @@ -0,0 +1,2 @@ +5 0 0 0 +1 1 2 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst23/i.1 b/Packages/Distance_2/test/Distance_2/DATA/tst23/i.1 new file mode 100644 index 00000000000..74f709f5d09 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst23/i.1 @@ -0,0 +1,2 @@ +0 0 +3 1 2.5 0.9 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.1 b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.1 new file mode 100644 index 00000000000..79492c2a203 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.1 @@ -0,0 +1,2 @@ +1 1 +2 1 10 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.2 b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.2 new file mode 100644 index 00000000000..05aea585d77 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.2 @@ -0,0 +1,2 @@ +1 1 +2 1 -10 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.3 b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.3 new file mode 100644 index 00000000000..b0caf0a4d55 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.3 @@ -0,0 +1,2 @@ +1 1 +-2 1 -10 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.4 b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.4 new file mode 100644 index 00000000000..cdec1a4253d --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.4 @@ -0,0 +1,2 @@ +1 1 +-2 1 10 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.5 b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.5 new file mode 100644 index 00000000000..e8eb214ac59 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.5 @@ -0,0 +1,2 @@ +0 0 +2 1 10 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.6 b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.6 new file mode 100644 index 00000000000..12c4aea9820 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.6 @@ -0,0 +1,2 @@ +0 0 +2 1 -10 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.7 b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.7 new file mode 100644 index 00000000000..2a7f3243faa --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.7 @@ -0,0 +1,2 @@ +0 0 +-2 1 -10 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.8 b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.8 new file mode 100644 index 00000000000..fde1a253a43 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.8 @@ -0,0 +1,2 @@ +0 0 +-2 1 10 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.9 b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.9 new file mode 100644 index 00000000000..5441f460da9 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst23/ix.9 @@ -0,0 +1,2 @@ +0 0 +3 1 10 3 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/i.1 b/Packages/Distance_2/test/Distance_2/DATA/tst24/i.1 new file mode 100644 index 00000000000..2d63525374b --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/i.1 @@ -0,0 +1,2 @@ +0 0 1 0 +0.9 0.9 2 2 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/i.2 b/Packages/Distance_2/test/Distance_2/DATA/tst24/i.2 new file mode 100644 index 00000000000..f73b5c88264 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/i.2 @@ -0,0 +1,2 @@ +1 0 2 0 +0.9 0.9 2 2 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/i.3 b/Packages/Distance_2/test/Distance_2/DATA/tst24/i.3 new file mode 100644 index 00000000000..63830be6f65 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/i.3 @@ -0,0 +1,2 @@ +0 0 1 0 +1.1 1.1 2 2 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/i.4 b/Packages/Distance_2/test/Distance_2/DATA/tst24/i.4 new file mode 100644 index 00000000000..737df9a836e --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/i.4 @@ -0,0 +1,2 @@ +1.1 1.1 2 2 +0 0 1 0 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/i.5 b/Packages/Distance_2/test/Distance_2/DATA/tst24/i.5 new file mode 100644 index 00000000000..f2b423101b0 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/i.5 @@ -0,0 +1,2 @@ +1 0 0 1 +0.5 0.5 2 0 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/i.6 b/Packages/Distance_2/test/Distance_2/DATA/tst24/i.6 new file mode 100644 index 00000000000..599d7aeebc5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/i.6 @@ -0,0 +1,2 @@ +1 0 0 1 +0.6 0.6 2 0 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/i.7 b/Packages/Distance_2/test/Distance_2/DATA/tst24/i.7 new file mode 100644 index 00000000000..e24895a5ac8 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/i.7 @@ -0,0 +1,2 @@ +-1 -1.3 0 1 +1 0.5 7 -3 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/i.8 b/Packages/Distance_2/test/Distance_2/DATA/tst24/i.8 new file mode 100644 index 00000000000..f4d8e850853 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/i.8 @@ -0,0 +1,2 @@ +0 0 3 -1 +-0.5 2 4 3 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.1 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.1 new file mode 100644 index 00000000000..4b513c8c8ce --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.1 @@ -0,0 +1,2 @@ +0 0 1 0 +-1 1 1 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.10 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.10 new file mode 100644 index 00000000000..abbdb39b6a3 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.10 @@ -0,0 +1,2 @@ +3 4 7 7 +7 0 6 5 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.11 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.11 new file mode 100644 index 00000000000..1ebd58ba355 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.11 @@ -0,0 +1,2 @@ +-1 1 3 4 +7 0 6 5 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.12 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.12 new file mode 100644 index 00000000000..3a1dc7fd470 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.12 @@ -0,0 +1,2 @@ +0 0 5 0 +1 1 6 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.13 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.13 new file mode 100644 index 00000000000..280ba40491b --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.13 @@ -0,0 +1,2 @@ +0 0 5 0 +1 1 2 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.14 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.14 new file mode 100644 index 00000000000..ce420595853 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.14 @@ -0,0 +1,2 @@ +5 0 8 0 +1 1 2 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.15 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.15 new file mode 100644 index 00000000000..1ff6b0c687a --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.15 @@ -0,0 +1,2 @@ +5 0 0 0 +1 1 2 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.16 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.16 new file mode 100644 index 00000000000..1ff6b0c687a --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.16 @@ -0,0 +1,2 @@ +5 0 0 0 +1 1 2 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.17 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.17 new file mode 100644 index 00000000000..a1e9a48303b --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.17 @@ -0,0 +1,2 @@ +0 0 5 0 +6 1 8 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.18 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.18 new file mode 100644 index 00000000000..7b433c61976 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.18 @@ -0,0 +1,2 @@ +0 0 0 -3 +1 4 1 7 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.19 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.19 new file mode 100644 index 00000000000..07a75936b47 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.19 @@ -0,0 +1,3 @@ +0 0 5 0 +8 1 6 1 + diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.2 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.2 new file mode 100644 index 00000000000..2546404233e --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.2 @@ -0,0 +1,2 @@ +0 0 1 0 +-1 1 -2 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.3 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.3 new file mode 100644 index 00000000000..7afbcf850dc --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.3 @@ -0,0 +1,2 @@ +0 0 1 0 +1 1 -2 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.4 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.4 new file mode 100644 index 00000000000..d663b9699fa --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.4 @@ -0,0 +1,2 @@ +0 0 1 0 +-1 -1 1 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.5 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.5 new file mode 100644 index 00000000000..a2e75bdd616 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.5 @@ -0,0 +1,2 @@ +-1 -1 1 1 +0 0 1 0 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.6 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.6 new file mode 100644 index 00000000000..3ce10029e63 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.6 @@ -0,0 +1,2 @@ +-1 -1 1 1 +-2 0 0 0 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.7 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.7 new file mode 100644 index 00000000000..bd57ba16fc1 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.7 @@ -0,0 +1,2 @@ +-8 -7 11 6 +23 -27 -17 16 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.8 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.8 new file mode 100644 index 00000000000..f81bf5c6105 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.8 @@ -0,0 +1,2 @@ +0 0 1 0 +2 1 2 -1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.9 b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.9 new file mode 100644 index 00000000000..a70877939fe --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst24/ix.9 @@ -0,0 +1,2 @@ +4 0 -3 -1 +1 1 2 11 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/i.1 b/Packages/Distance_2/test/Distance_2/DATA/tst25/i.1 new file mode 100644 index 00000000000..f2b423101b0 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/i.1 @@ -0,0 +1,2 @@ +1 0 0 1 +0.5 0.5 2 0 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/i.2 b/Packages/Distance_2/test/Distance_2/DATA/tst25/i.2 new file mode 100644 index 00000000000..599d7aeebc5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/i.2 @@ -0,0 +1,2 @@ +1 0 0 1 +0.6 0.6 2 0 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/i.3 b/Packages/Distance_2/test/Distance_2/DATA/tst25/i.3 new file mode 100644 index 00000000000..e24895a5ac8 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/i.3 @@ -0,0 +1,2 @@ +-1 -1.3 0 1 +1 0.5 7 -3 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/i.4 b/Packages/Distance_2/test/Distance_2/DATA/tst25/i.4 new file mode 100644 index 00000000000..f4d8e850853 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/i.4 @@ -0,0 +1,2 @@ +0 0 3 -1 +-0.5 2 4 3 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.1 b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.1 new file mode 100644 index 00000000000..bd57ba16fc1 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.1 @@ -0,0 +1,2 @@ +-8 -7 11 6 +23 -27 -17 16 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.10 b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.10 new file mode 100644 index 00000000000..1ff6b0c687a --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.10 @@ -0,0 +1,2 @@ +5 0 0 0 +1 1 2 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.11 b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.11 new file mode 100644 index 00000000000..a1e9a48303b --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.11 @@ -0,0 +1,2 @@ +0 0 5 0 +6 1 8 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.12 b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.12 new file mode 100644 index 00000000000..7b433c61976 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.12 @@ -0,0 +1,2 @@ +0 0 0 -3 +1 4 1 7 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.13 b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.13 new file mode 100644 index 00000000000..07a75936b47 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.13 @@ -0,0 +1,3 @@ +0 0 5 0 +8 1 6 1 + diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.15 b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.15 new file mode 100644 index 00000000000..b14c146d630 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.15 @@ -0,0 +1,2 @@ +8 0 12 0 +0 0 5 0 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.2 b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.2 new file mode 100644 index 00000000000..f81bf5c6105 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.2 @@ -0,0 +1,2 @@ +0 0 1 0 +2 1 2 -1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.3 b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.3 new file mode 100644 index 00000000000..a70877939fe --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.3 @@ -0,0 +1,2 @@ +4 0 -3 -1 +1 1 2 11 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.4 b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.4 new file mode 100644 index 00000000000..abbdb39b6a3 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.4 @@ -0,0 +1,2 @@ +3 4 7 7 +7 0 6 5 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.5 b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.5 new file mode 100644 index 00000000000..1ebd58ba355 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.5 @@ -0,0 +1,2 @@ +-1 1 3 4 +7 0 6 5 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.6 b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.6 new file mode 100644 index 00000000000..3a1dc7fd470 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.6 @@ -0,0 +1,2 @@ +0 0 5 0 +1 1 6 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.7 b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.7 new file mode 100644 index 00000000000..280ba40491b --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.7 @@ -0,0 +1,2 @@ +0 0 5 0 +1 1 2 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.8 b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.8 new file mode 100644 index 00000000000..ce420595853 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.8 @@ -0,0 +1,2 @@ +5 0 8 0 +1 1 2 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.9 b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.9 new file mode 100644 index 00000000000..1ff6b0c687a --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst25/ix.9 @@ -0,0 +1,2 @@ +5 0 0 0 +1 1 2 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/i.1 b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.1 new file mode 100644 index 00000000000..af940864f0f --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.1 @@ -0,0 +1,2 @@ +1 0 1.1 1 +0 0 0 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/i.10 b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.10 new file mode 100644 index 00000000000..bfdc63791dd --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.10 @@ -0,0 +1,2 @@ +1 0 0.9 1 +0 -10 0 -9 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/i.11 b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.11 new file mode 100644 index 00000000000..cebb9f4ebc4 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.11 @@ -0,0 +1,2 @@ +1 0 0.9 -1 +0 -10 0 -9 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/i.12 b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.12 new file mode 100644 index 00000000000..ce3eed4262b --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.12 @@ -0,0 +1,2 @@ +1 0 0.9 1 +0 9 0 10 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/i.13 b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.13 new file mode 100644 index 00000000000..b91ae52a1b7 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.13 @@ -0,0 +1,2 @@ +1 0 0.9 -1 +0 9 0 10 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/i.14 b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.14 new file mode 100644 index 00000000000..85fec54cae5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.14 @@ -0,0 +1,2 @@ +1 0 0.9 1 +0 10 0 9 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/i.2 b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.2 new file mode 100644 index 00000000000..ed02eef953e --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.2 @@ -0,0 +1,2 @@ +1 0 1.1 -1 +0 0 0 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/i.3 b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.3 new file mode 100644 index 00000000000..f248db20b88 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.3 @@ -0,0 +1,2 @@ +1 0 1.1 1 +0 -10 0 -9 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/i.4 b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.4 new file mode 100644 index 00000000000..bd632478b3a --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.4 @@ -0,0 +1,2 @@ +1 0 1.1 -1 +0 -10 0 -9 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/i.5 b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.5 new file mode 100644 index 00000000000..e69de29bb2d diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/i.6 b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.6 new file mode 100644 index 00000000000..012166dad1e --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.6 @@ -0,0 +1,2 @@ +1 0 1.1 -1 +0 9 0 10 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/i.7 b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.7 new file mode 100644 index 00000000000..c7e1c6d288d --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.7 @@ -0,0 +1,2 @@ +1 0 1.1 1 +0 10 0 9 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/i.8 b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.8 new file mode 100644 index 00000000000..53d5fd7eec6 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.8 @@ -0,0 +1,3 @@ + +1 0 0.9 1 +0 0 0 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/i.9 b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.9 new file mode 100644 index 00000000000..762d5ef487a --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/i.9 @@ -0,0 +1,2 @@ +1 0 0.9 -1 +0 0 0 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.1 b/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.1 new file mode 100644 index 00000000000..9057f56403c --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.1 @@ -0,0 +1,3 @@ + +1 0 1 1 +0 0 0 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.2 b/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.2 new file mode 100644 index 00000000000..df80c533f8f --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.2 @@ -0,0 +1,2 @@ +1 0 1 -1 +0 0 0 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.3 b/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.3 new file mode 100644 index 00000000000..bd52628db5f --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.3 @@ -0,0 +1,2 @@ +1 0 1 1 +0 -10 0 -9 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.4 b/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.4 new file mode 100644 index 00000000000..1bb77c02233 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.4 @@ -0,0 +1,2 @@ +1 0 1 -1 +0 -10 0 -9 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.5 b/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.5 new file mode 100644 index 00000000000..c06e839b3f8 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.5 @@ -0,0 +1,2 @@ +1 0 1 1 +0 9 0 10 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.6 b/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.6 new file mode 100644 index 00000000000..e73a4638c2c --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.6 @@ -0,0 +1,2 @@ +1 0 1 -1 +0 9 0 10 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.7 b/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.7 new file mode 100644 index 00000000000..bc90a3fbba0 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst26/ix.7 @@ -0,0 +1,2 @@ +1 0 1 1 +0 10 0 9 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst27/ix.1 b/Packages/Distance_2/test/Distance_2/DATA/tst27/ix.1 new file mode 100644 index 00000000000..c24f9d01111 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst27/ix.1 @@ -0,0 +1,2 @@ +1 1 +4 0 -3 -1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst28/ix.1 b/Packages/Distance_2/test/Distance_2/DATA/tst28/ix.1 new file mode 100644 index 00000000000..b2426bc7e90 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst28/ix.1 @@ -0,0 +1,2 @@ +0 0 1 0 +2 2 3 3 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst28/ix.2 b/Packages/Distance_2/test/Distance_2/DATA/tst28/ix.2 new file mode 100644 index 00000000000..bad3aa7760e --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst28/ix.2 @@ -0,0 +1,2 @@ +0 0 1 0 +2 2 3 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst28/ix.3 b/Packages/Distance_2/test/Distance_2/DATA/tst28/ix.3 new file mode 100644 index 00000000000..ebd7dac1a28 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst28/ix.3 @@ -0,0 +1,2 @@ +0 0 1 0 +2 2 3 -1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst28/ix.4 b/Packages/Distance_2/test/Distance_2/DATA/tst28/ix.4 new file mode 100644 index 00000000000..08209edacbc --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst28/ix.4 @@ -0,0 +1,2 @@ +0 0 1 0 +2 2 3 2 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst28/ix.5 b/Packages/Distance_2/test/Distance_2/DATA/tst28/ix.5 new file mode 100644 index 00000000000..605c6271c16 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst28/ix.5 @@ -0,0 +1,2 @@ +0 0 1 0 +2 2 -3 2 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst29/ix.1 b/Packages/Distance_2/test/Distance_2/DATA/tst29/ix.1 new file mode 100644 index 00000000000..b2426bc7e90 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst29/ix.1 @@ -0,0 +1,2 @@ +0 0 1 0 +2 2 3 3 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst29/ix.2 b/Packages/Distance_2/test/Distance_2/DATA/tst29/ix.2 new file mode 100644 index 00000000000..bad3aa7760e --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst29/ix.2 @@ -0,0 +1,2 @@ +0 0 1 0 +2 2 3 1 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst29/ix.3 b/Packages/Distance_2/test/Distance_2/DATA/tst29/ix.3 new file mode 100644 index 00000000000..08209edacbc --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst29/ix.3 @@ -0,0 +1,2 @@ +0 0 1 0 +2 2 3 2 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst29/ix.4 b/Packages/Distance_2/test/Distance_2/DATA/tst29/ix.4 new file mode 100644 index 00000000000..605c6271c16 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst29/ix.4 @@ -0,0 +1,2 @@ +0 0 1 0 +2 2 -3 2 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst30/ix.1 b/Packages/Distance_2/test/Distance_2/DATA/tst30/ix.1 new file mode 100644 index 00000000000..c6ad9a61215 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst30/ix.1 @@ -0,0 +1,2 @@ +10 0 +5 2 18 57 2 56 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst30/ix.2 b/Packages/Distance_2/test/Distance_2/DATA/tst30/ix.2 new file mode 100644 index 00000000000..132fcf503e7 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst30/ix.2 @@ -0,0 +1,2 @@ +5 101 +0 0 5 1 10 0 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst32/ix.1 b/Packages/Distance_2/test/Distance_2/DATA/tst32/ix.1 new file mode 100644 index 00000000000..d94b95d2f9d --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst32/ix.1 @@ -0,0 +1,2 @@ +1 3 0 11 +5 2 8 57 2 26 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst33/ix.1 b/Packages/Distance_2/test/Distance_2/DATA/tst33/ix.1 new file mode 100644 index 00000000000..c557e4cb8ec --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst33/ix.1 @@ -0,0 +1,2 @@ +60 0 6 0 +5 2 18 57 2 56 diff --git a/Packages/Distance_2/test/Distance_2/DATA/tst34/ix.1 b/Packages/Distance_2/test/Distance_2/DATA/tst34/ix.1 new file mode 100644 index 00000000000..0c64aa34796 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/DATA/tst34/ix.1 @@ -0,0 +1,2 @@ +7 1 100 15 103 7 +5 2 18 57 2 56 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst21/ix.1 b/Packages/Distance_2/test/Distance_2/RESULT/tst21/ix.1 new file mode 100644 index 00000000000..0cfbf08886f --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst21/ix.1 @@ -0,0 +1 @@ +2 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.1 b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.1 new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.1 @@ -0,0 +1 @@ +0 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.10 b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.10 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.10 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.11 b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.11 new file mode 100644 index 00000000000..0cfbf08886f --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.11 @@ -0,0 +1 @@ +2 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.12 b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.12 new file mode 100644 index 00000000000..98d9bcb75a6 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.12 @@ -0,0 +1 @@ +17 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.13 b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.13 new file mode 100644 index 00000000000..81b5c5d06cc --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.13 @@ -0,0 +1 @@ +37 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.14 b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.14 new file mode 100644 index 00000000000..0cfbf08886f --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.14 @@ -0,0 +1 @@ +2 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.15 b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.15 new file mode 100644 index 00000000000..ec635144f60 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.15 @@ -0,0 +1 @@ +9 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.16 b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.16 new file mode 100644 index 00000000000..f599e28b8ab --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.16 @@ -0,0 +1 @@ +10 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.2 b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.2 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.2 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.3 b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.3 new file mode 100644 index 00000000000..0cfbf08886f --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.3 @@ -0,0 +1 @@ +2 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.4 b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.4 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.4 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.5 b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.5 new file mode 100644 index 00000000000..b469438fd4e --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.5 @@ -0,0 +1 @@ +9.84615 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.6 b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.6 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.6 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.7 b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.7 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.7 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.8 b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.8 new file mode 100644 index 00000000000..f599e28b8ab --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.8 @@ -0,0 +1 @@ +10 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.9 b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.9 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst22/ix.9 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.1 b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.1 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.1 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.2 b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.2 new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.2 @@ -0,0 +1 @@ +0 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.3 b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.3 new file mode 100644 index 00000000000..ec635144f60 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.3 @@ -0,0 +1 @@ +9 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.4 b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.4 new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.4 @@ -0,0 +1 @@ +0 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.5 b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.5 new file mode 100644 index 00000000000..7ed6ff82de6 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.5 @@ -0,0 +1 @@ +5 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.6 b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.6 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.6 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.7 b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.7 new file mode 100644 index 00000000000..7ed6ff82de6 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.7 @@ -0,0 +1 @@ +5 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.8 b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.8 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.8 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.9 b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.9 new file mode 100644 index 00000000000..f599e28b8ab --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst23/ix.9 @@ -0,0 +1 @@ +10 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.1 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.1 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.1 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.10 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.10 new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.10 @@ -0,0 +1 @@ +0 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.11 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.11 new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.11 @@ -0,0 +1 @@ +0 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.12 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.12 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.12 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.13 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.13 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.13 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.14 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.14 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.14 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.15 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.15 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.15 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.16 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.16 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.16 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.17 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.17 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.17 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.18 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.18 new file mode 100644 index 00000000000..98d9bcb75a6 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.18 @@ -0,0 +1 @@ +17 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.19 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.19 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.19 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.2 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.2 new file mode 100644 index 00000000000..0cfbf08886f --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.2 @@ -0,0 +1 @@ +2 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.3 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.3 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.3 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.4 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.4 new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.4 @@ -0,0 +1 @@ +0 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.5 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.5 new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.5 @@ -0,0 +1 @@ +0 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.6 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.6 new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.6 @@ -0,0 +1 @@ +0 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.7 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.7 new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.7 @@ -0,0 +1 @@ +0 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.8 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.8 new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.8 @@ -0,0 +1 @@ +0 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.9 b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.9 new file mode 100644 index 00000000000..0cfbf08886f --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst24/ix.9 @@ -0,0 +1 @@ +2 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.1 b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.1 new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.1 @@ -0,0 +1 @@ +0 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.10 b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.10 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.10 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.11 b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.11 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.11 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.12 b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.12 new file mode 100644 index 00000000000..98d9bcb75a6 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.12 @@ -0,0 +1 @@ +17 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.13 b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.13 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.13 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.15 b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.15 new file mode 100644 index 00000000000..ec635144f60 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.15 @@ -0,0 +1 @@ +9 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.2 b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.2 new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.2 @@ -0,0 +1 @@ +0 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.3 b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.3 new file mode 100644 index 00000000000..0cfbf08886f --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.3 @@ -0,0 +1 @@ +2 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.4 b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.4 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.4 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.5 b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.5 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.5 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.6 b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.6 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.6 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.7 b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.7 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.7 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.8 b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.8 new file mode 100644 index 00000000000..f599e28b8ab --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.8 @@ -0,0 +1 @@ +10 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.9 b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.9 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst25/ix.9 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.1 b/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.1 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.1 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.2 b/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.2 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.2 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.3 b/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.3 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.3 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.4 b/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.4 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.4 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.5 b/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.5 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.5 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.6 b/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.6 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.6 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.7 b/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.7 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst26/ix.7 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst27/ix.1 b/Packages/Distance_2/test/Distance_2/RESULT/tst27/ix.1 new file mode 100644 index 00000000000..0cfbf08886f --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst27/ix.1 @@ -0,0 +1 @@ +2 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst28/ix.1 b/Packages/Distance_2/test/Distance_2/RESULT/tst28/ix.1 new file mode 100644 index 00000000000..b8626c4cff2 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst28/ix.1 @@ -0,0 +1 @@ +4 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst28/ix.2 b/Packages/Distance_2/test/Distance_2/RESULT/tst28/ix.2 new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst28/ix.2 @@ -0,0 +1 @@ +1 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst28/ix.3 b/Packages/Distance_2/test/Distance_2/RESULT/tst28/ix.3 new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst28/ix.3 @@ -0,0 +1 @@ +0 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst28/ix.4 b/Packages/Distance_2/test/Distance_2/RESULT/tst28/ix.4 new file mode 100644 index 00000000000..b8626c4cff2 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst28/ix.4 @@ -0,0 +1 @@ +4 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst28/ix.5 b/Packages/Distance_2/test/Distance_2/RESULT/tst28/ix.5 new file mode 100644 index 00000000000..b8626c4cff2 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst28/ix.5 @@ -0,0 +1 @@ +4 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst29/ix.1 b/Packages/Distance_2/test/Distance_2/RESULT/tst29/ix.1 new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst29/ix.1 @@ -0,0 +1 @@ +0 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst29/ix.2 b/Packages/Distance_2/test/Distance_2/RESULT/tst29/ix.2 new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst29/ix.2 @@ -0,0 +1 @@ +0 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst29/ix.3 b/Packages/Distance_2/test/Distance_2/RESULT/tst29/ix.3 new file mode 100644 index 00000000000..b8626c4cff2 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst29/ix.3 @@ -0,0 +1 @@ +4 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst29/ix.4 b/Packages/Distance_2/test/Distance_2/RESULT/tst29/ix.4 new file mode 100644 index 00000000000..b8626c4cff2 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst29/ix.4 @@ -0,0 +1 @@ +4 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst30/ix.1 b/Packages/Distance_2/test/Distance_2/RESULT/tst30/ix.1 new file mode 100644 index 00000000000..f04c001f3f7 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst30/ix.1 @@ -0,0 +1 @@ +29 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst30/ix.2 b/Packages/Distance_2/test/Distance_2/RESULT/tst30/ix.2 new file mode 100644 index 00000000000..5caff40c4a0 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst30/ix.2 @@ -0,0 +1 @@ +10000 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst32/ix.1 b/Packages/Distance_2/test/Distance_2/RESULT/tst32/ix.1 new file mode 100644 index 00000000000..092ae9534cd --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst32/ix.1 @@ -0,0 +1 @@ +14.7846 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst33/ix.1 b/Packages/Distance_2/test/Distance_2/RESULT/tst33/ix.1 new file mode 100644 index 00000000000..7ed6ff82de6 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst33/ix.1 @@ -0,0 +1 @@ +5 diff --git a/Packages/Distance_2/test/Distance_2/RESULT/tst34/ix.1 b/Packages/Distance_2/test/Distance_2/RESULT/tst34/ix.1 new file mode 100644 index 00000000000..7ed6ff82de6 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/RESULT/tst34/ix.1 @@ -0,0 +1 @@ +5 diff --git a/Packages/Distance_2/test/Distance_2/cgal_test b/Packages/Distance_2/test/Distance_2/cgal_test new file mode 100755 index 00000000000..2cfc4362966 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/cgal_test @@ -0,0 +1,114 @@ +#!/bin/sh +OUTPUTFILE=error.txt + +use_purify=0 + +one_run_make_result() +{ + goodresult=RESULT/${base}/`basename ${datafile}` + if "./${base}" < ${datafile} > ${goodresult} + then + succes=ja + else + succes=nee + fi + if [ ${succes} = ja ] + then + echo "${base} < ${datafile} succesful">> $OUTPUTFILE + else + echo "ERROR: ${base} < ${datafile} did not run well" >> $OUTPUTFILE + fi +} + +one_run() +{ + goodresult=RESULT/${base}/`basename ${datafile}` + if "./${base}" < ${datafile} > output + then + if [ -r ${goodresult} ] + then + if cmp -s output ${goodresult} + then + succes=ja + else + succes=nee + fi + else + succes=ja + fi + else + succes=nee + fi + if [ ${succes} = ja ] + then + echo "${base} < ${datafile} succesful">> $OUTPUTFILE + else + echo "ERROR: ${base} < ${datafile} did not run well" >> $OUTPUTFILE + fi +} + +make_and_execute() +{ + if [ -r ii_files/${base}.ii.$1 ] + then + mv ii_files/${base}.ii.$1 ii_files/${base}.ii + fi + EXTRA_FLAGS="-DTESTR=$1" + export EXTRA_FLAGS + if make ${base} # 2>/dev/null + then + echo "compilation of ${file} with TESTR=$1 succeeded" >> $OUTPUTFILE + if [ -r ii_files/${base}.ii ] + then + mv ii_files/${base}.ii ii_files/${base}.ii.$1 + fi + if [ ${use_purify} -eq 1 ] + then + purify -log-file="%v.$1.%p.plog" ${base} + mv ${base}.pure ${base} + fi + for datafile + in ${datafiles} + do + if [ -r ${datafile} ] + then + one_run + fi + done + else + echo "ERROR: compilation of ${file} with TESTR=$1 failed" >> $OUTPUTFILE + fi + rm -f ${base} ${base}.o +} + +#----------------------------------------------------------------# +# clear the output file # +#----------------------------------------------------------------# +/bin/rm -f $OUTPUTFILE +touch $OUTPUTFILE + +if [ $# -ne 0 ] +then + sourcefiles="$*" +else + sourcefiles="tst*.C" +fi + + +for file + in ${sourcefiles} +do + base=`basename ${file} .C` + datafiles="ls DATA/${base}/ix.*" + if [ "${datafiles}" ] + then + make_and_execute 1; + fi + if [ "${datafiles}" ] + then + make_and_execute 2; + fi +done + + + diff --git a/Packages/Distance_2/test/Distance_2/install_ii b/Packages/Distance_2/test/Distance_2/install_ii new file mode 100755 index 00000000000..96d9c321998 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/install_ii @@ -0,0 +1,9 @@ +#!/bin/sh + +iifile="ii_files/$1.ii" +keepfile="ii_files/$1.ii.$2" + +if [ -r ${keepfile} ] +then + cp ${keepfile} ${iifile} +fi diff --git a/Packages/Distance_2/test/Distance_2/keep_ii b/Packages/Distance_2/test/Distance_2/keep_ii new file mode 100755 index 00000000000..a82d764cc3b --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/keep_ii @@ -0,0 +1,9 @@ +#!/bin/sh + +iifile="ii_files/$1.ii" +keepfile="ii_files/$1.ii.$2" + +if [ -r ${iifile} ] +then + cp ${iifile} ${keepfile} +fi diff --git a/Packages/Distance_2/test/Distance_2/makefile b/Packages/Distance_2/test/Distance_2/makefile new file mode 100644 index 00000000000..f989bf1bc1b --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/makefile @@ -0,0 +1,43 @@ +# This is the makefile for compiling a CGAL application. + +#---------------------------------------------------------------------# +# include platform specific settings +#---------------------------------------------------------------------# +# Choose the right include file from the /make directory. + +#CGAL_MAKEFILE = /net/lib/CGAL/makefile_mips_IRIX-5.3_CC-4.0 +include $(CGAL_MAKEFILE) + +#---------------------------------------------------------------------# +# compiler flags +#---------------------------------------------------------------------# + +CXX = ${CGAL_CXX} + +CXXFLAGS = $(TESTSUITE_CXXFLAGS) $(CGAL_CXXFLAGS) \ + $(EXTRA_FLAGS) \ + -g + +#---------------------------------------------------------------------# +# linker flags +#---------------------------------------------------------------------# + +LDFLAGS = $(CGAL_LDFLAGS) + +#---------------------------------------------------------------------# +# target entries +#---------------------------------------------------------------------# + +clean: + /bin/rm -f tst?? tst??.o + +#---------------------------------------------------------------------# +# suffix rules +#---------------------------------------------------------------------# + +.C: + $(CXX) $(CXXFLAGS) $< $(LDFLAGS) -o $@ + +.C.o: + $(CXX) $(CXXFLAGS) -c $< + diff --git a/Packages/Distance_2/test/Distance_2/numrep1.h b/Packages/Distance_2/test/Distance_2/numrep1.h new file mode 100644 index 00000000000..3a9c1e7902e --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/numrep1.h @@ -0,0 +1,87 @@ +#if TESTR == 1 + +#include + +inline double to_nt(int d) +{ + return double(d); +} +#endif + +#if TESTR == 2 + +#include + +inline double to_nt(int d) +{ + return d; +} +#endif + + +#if TESTR == 3 + +#include +#include + +inline CGAL_TestfieldC to_nt(int d) +{ + unsigned char dummy1 = 'a'; + signed char dummy2 = 'a'; + return CGAL_TestfieldC(dummy1, dummy2, (double)d); +} + +#endif + + +#if TESTR == 4 + +#include +#include + +inline CGAL_TestrepH to_nt(int d) +{ + unsigned char dummy1 = 'a'; + signed char dummy2 = 'a'; + return CGAL_TestrepH(dummy1, dummy2, d); +} +#endif + +#if TESTR == 5 + +#include +#include + +#include +inline integer to_nt(int d) +{ + return integer(d); +} +#include +#endif + +struct randomint { + randomint() ; + int get() const { return sequence[cur]; } + int next() { cur = (cur+1)%11; return get();} +private: + int sequence[11]; + int cur; +}; + +inline randomint::randomint() +{ + cur = 0; + sequence[0] = 19; + sequence[1] = 5; + sequence[2] = 17; + sequence[3] = 13; + sequence[4] = 29; + sequence[5] = 2; + sequence[6] = 23; + sequence[7] = 31; + sequence[8] = 3; + sequence[9] = 37; + sequence[10] = 11; +} + diff --git a/Packages/Distance_2/test/Distance_2/numrep2.h b/Packages/Distance_2/test/Distance_2/numrep2.h new file mode 100644 index 00000000000..30c8b9c76aa --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/numrep2.h @@ -0,0 +1,26 @@ +#if TESTR == 1 + typedef double testnt; + typedef CGAL_Cartesian TestR; +#endif + +#if TESTR == 2 + typedef double testnt; + typedef CGAL_Homogeneous TestR; +#endif + +#if TESTR == 3 + typedef CGAL_TestfieldC testnt; + typedef CGAL_Cartesian TestR; +#endif + +#if TESTR == 4 + typedef CGAL_TestrepH testnt; + typedef CGAL_Homogeneous TestR; +#endif + +#if TESTR == 5 +#include + typedef integer testnt; +#include + typedef CGAL_Homogeneous TestR; +#endif diff --git a/Packages/Distance_2/test/Distance_2/tst20.C b/Packages/Distance_2/test/Distance_2/tst20.C new file mode 100644 index 00000000000..f903d5bff9b --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/tst20.C @@ -0,0 +1,27 @@ +#include "numrep1.h" +#include +#include + + +#include "numrep2.h" + +typedef CGAL_Point_2< TestR > point_t; + + + +int main() +{ + randomint ri; + int x1, x2, y1, y2, w1, w2; + TestR::FT d; + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + d = CGAL_squared_distance(tp1, tp2); + cout << CGAL_to_double(d) << '\n'; + return 0; +} diff --git a/Packages/Distance_2/test/Distance_2/tst21.C b/Packages/Distance_2/test/Distance_2/tst21.C new file mode 100644 index 00000000000..bcb233f6dd7 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/tst21.C @@ -0,0 +1,33 @@ +#include "numrep1.h" +#include +#include + + +#include "numrep2.h" + +typedef CGAL_Point_2< TestR > point_t; +typedef CGAL_Segment_2< TestR > segment_t; + + +int main() +{ + randomint ri; + int x1, x2, y1, y2, w1, w2; + TestR::FT d; + cin >> x1 >> y1; + if (!cin) + return 1; + w1 = ri.next(); + point_t pt(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp3(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp4(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + segment_t seg(tp3, tp4); + d = CGAL_squared_distance(pt, seg); + cout << CGAL_to_double(d) << '\n'; + return 0; +} diff --git a/Packages/Distance_2/test/Distance_2/tst22.C b/Packages/Distance_2/test/Distance_2/tst22.C new file mode 100644 index 00000000000..167b9ba5b68 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/tst22.C @@ -0,0 +1,38 @@ +#include "numrep1.h" +/* + * Squared distance between two segments. + */ +#include +#include +#include +#include + +#include "numrep2.h" + +typedef CGAL_Point_2< TestR > point_t; +typedef CGAL_Segment_2< TestR > segment_t; + + +int main() +{ + randomint ri; + int x1, x2, y1, y2, w1, w2; + TestR::FT d; + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + segment_t seg1(tp1, tp2); + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + point_t tp3(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp4(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + segment_t seg2(tp3, tp4); + d = CGAL_squared_distance(seg1, seg2); + cout << CGAL_to_double(d) << '\n'; + return 0; +} diff --git a/Packages/Distance_2/test/Distance_2/tst23.C b/Packages/Distance_2/test/Distance_2/tst23.C new file mode 100644 index 00000000000..0d9f4dd995e --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/tst23.C @@ -0,0 +1,34 @@ +#include "numrep1.h" +#include +#include +#include + + +#include "numrep2.h" + +typedef CGAL_Point_2< TestR > point_t; +typedef CGAL_Ray_2< TestR > ray_t; + + +int main() +{ + randomint ri; + int x1, x2, y1, y2, w1, w2; + TestR::FT d; + cin >> x1 >> y1; + if (!cin) + return 1; + w1 = ri.next(); + point_t pt(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + ray_t ray(tp1, tp2); + d = CGAL_squared_distance(pt, ray); + cout << CGAL_to_double(d) << '\n'; + return 0; +} diff --git a/Packages/Distance_2/test/Distance_2/tst24.C b/Packages/Distance_2/test/Distance_2/tst24.C new file mode 100644 index 00000000000..c97ebd550d8 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/tst24.C @@ -0,0 +1,39 @@ +#include "numrep1.h" +#include +#include +#include +#include +#include + +#include "numrep2.h" + +typedef CGAL_Point_2< TestR > point_t; +typedef CGAL_Ray_2< TestR > ray_t; + + + +int main() +{ + randomint ri; + int x1, x2, y1, y2, w1, w2; + TestR::FT d; + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + ray_t ray1(tp1, tp2); + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp3(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp4(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + ray_t ray2(tp3, tp4); + d = CGAL_squared_distance(ray1, ray2); + cout << CGAL_to_double(d) << '\n'; + return 0; +} diff --git a/Packages/Distance_2/test/Distance_2/tst25.C b/Packages/Distance_2/test/Distance_2/tst25.C new file mode 100644 index 00000000000..4d17caba0ae --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/tst25.C @@ -0,0 +1,39 @@ +#include "numrep1.h" +#include +#include +#include +#include +#include + +#include "numrep2.h" + +typedef CGAL_Point_2< TestR > point_t; +typedef CGAL_Ray_2< TestR > ray_t; +typedef CGAL_Segment_2< TestR > segment_t; + + +int main() +{ + randomint ri; + int x1, x2, y1, y2, w1, w2; + TestR::FT d; + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + ray_t ray1(tp1, tp2); + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp3(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp4(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + segment_t seg2(tp3, tp4); + d = CGAL_squared_distance(ray1, seg2); + cout << CGAL_to_double(d) << '\n'; + return 0; +} diff --git a/Packages/Distance_2/test/Distance_2/tst26.C b/Packages/Distance_2/test/Distance_2/tst26.C new file mode 100644 index 00000000000..13004b16cfe --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/tst26.C @@ -0,0 +1,40 @@ +#include "numrep1.h" + +#include +#include +#include +#include + + +#include "numrep2.h" + +typedef CGAL_Point_2< TestR > point_t; +typedef CGAL_Ray_2< TestR > ray_t; +typedef CGAL_Line_2< TestR > line_t; + + +int main() +{ + randomint ri; + int x1, x2, y1, y2, w1, w2; + TestR::FT d; + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + ray_t ray1(tp1, tp2); + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp3(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp4(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + line_t line2(tp3, tp4); + d = CGAL_squared_distance(ray1, line2); + cout << CGAL_to_double(d) << '\n'; + return 0; +} diff --git a/Packages/Distance_2/test/Distance_2/tst27.C b/Packages/Distance_2/test/Distance_2/tst27.C new file mode 100644 index 00000000000..216d8d41244 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/tst27.C @@ -0,0 +1,34 @@ +#include "numrep1.h" +#include +#include +#include + + +#include "numrep2.h" + +typedef CGAL_Point_2< TestR > point_t; +typedef CGAL_Line_2< TestR > line_t; + + +int main() +{ + randomint ri; + int x1, x2, y1, y2, w1, w2; + TestR::FT d; + cin >> x1 >> y1; + if (!cin) + return 1; + w1 = ri.next(); + point_t pt(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + line_t line(tp1, tp2); + d = CGAL_squared_distance(pt, line); + cout << CGAL_to_double(d) << '\n'; + return 0; +} diff --git a/Packages/Distance_2/test/Distance_2/tst28.C b/Packages/Distance_2/test/Distance_2/tst28.C new file mode 100644 index 00000000000..1a33aade724 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/tst28.C @@ -0,0 +1,39 @@ +#include "numrep1.h" +#include +#include +#include +#include +#include + +#include "numrep2.h" + +typedef CGAL_Point_2< TestR > point_t; +typedef CGAL_Line_2< TestR > line_t; +typedef CGAL_Segment_2< TestR > segment_t; + + +int main() +{ + randomint ri; + int x1, x2, y1, y2, w1, w2; + TestR::FT d; + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + line_t line1(tp1, tp2); + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp3(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp4(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + segment_t seg2(tp3, tp4); + d = CGAL_squared_distance(line1, seg2); + cout << CGAL_to_double(d) << '\n'; + return 0; +} diff --git a/Packages/Distance_2/test/Distance_2/tst29.C b/Packages/Distance_2/test/Distance_2/tst29.C new file mode 100644 index 00000000000..5409d91b7a1 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/tst29.C @@ -0,0 +1,39 @@ +#include "numrep1.h" +#include +#include +#include +#include +#include + +#include "numrep2.h" + +typedef CGAL_Point_2< TestR > point_t; +typedef CGAL_Line_2< TestR > line_t; + + + +int main() +{ + randomint ri; + int x1, x2, y1, y2, w1, w2; + TestR::FT d; + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + line_t line1(tp1, tp2); + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp3(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp4(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + line_t line2(tp3, tp4); + d = CGAL_squared_distance(line1, line2); + cout << CGAL_to_double(d) << '\n'; + return 0; +} diff --git a/Packages/Distance_2/test/Distance_2/tst30.C b/Packages/Distance_2/test/Distance_2/tst30.C new file mode 100644 index 00000000000..35b6920687d --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/tst30.C @@ -0,0 +1,36 @@ +#include "numrep1.h" +#include +#include +#include + + +#include "numrep2.h" + +typedef CGAL_Point_2< TestR > point_t; +typedef CGAL_Triangle_2< TestR > triangle_t; + + +int main() +{ + randomint ri; + int x1, x2, x3, y1, y2, y3, w1, w2, w3; + TestR::FT d; + cin >> x1 >> y1; + if (!cin) + return 1; + w1 = ri.next(); + point_t pt(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + w3 = ri.next(); + point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + point_t tp3(to_nt(w3*x3), to_nt(w3*y3), to_nt(w3)); + triangle_t tr(tp1, tp2, tp3); + d = CGAL_squared_distance(pt, tr); + cout << CGAL_to_double(d) << '\n'; + return 0; +} diff --git a/Packages/Distance_2/test/Distance_2/tst31.C b/Packages/Distance_2/test/Distance_2/tst31.C new file mode 100644 index 00000000000..c86e932b7bf --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/tst31.C @@ -0,0 +1,41 @@ +#include "numrep1.h" +#include +#include +#include +#include + + +#include "numrep2.h" + +typedef CGAL_Point_2< TestR > point_t; +typedef CGAL_Line_2< TestR > line_t; +typedef CGAL_Triangle_2< TestR > triangle_t; + + +int main() +{ + randomint ri; + int x1, x2, x3, y1, y2, y3, w1, w2, w3; + TestR::FT d; + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + line_t line(tp1, tp2); + cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + w3 = ri.next(); + point_t tp3(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp4(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + point_t tp5(to_nt(w3*x3), to_nt(w3*y3), to_nt(w3)); + triangle_t tr(tp3, tp4, tp5); + d = CGAL_squared_distance(line, tr); + cout << CGAL_to_double(d) << '\n'; + return 0; +} diff --git a/Packages/Distance_2/test/Distance_2/tst32.C b/Packages/Distance_2/test/Distance_2/tst32.C new file mode 100644 index 00000000000..7a1ccea05ce --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/tst32.C @@ -0,0 +1,41 @@ +#include "numrep1.h" +#include +#include +#include +#include + + +#include "numrep2.h" + +typedef CGAL_Point_2< TestR > point_t; +typedef CGAL_Ray_2< TestR > ray_t; +typedef CGAL_Triangle_2< TestR > triangle_t; + + +int main() +{ + randomint ri; + int x1, x2, x3, y1, y2, y3, w1, w2, w3; + TestR::FT d; + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + ray_t ray(tp1, tp2); + cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + w3 = ri.next(); + point_t tp3(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp4(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + point_t tp5(to_nt(w3*x3), to_nt(w3*y3), to_nt(w3)); + triangle_t tr(tp3, tp4, tp5); + d = CGAL_squared_distance(ray, tr); + cout << CGAL_to_double(d) << '\n'; + return 0; +} diff --git a/Packages/Distance_2/test/Distance_2/tst33.C b/Packages/Distance_2/test/Distance_2/tst33.C new file mode 100644 index 00000000000..60bd90ac455 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/tst33.C @@ -0,0 +1,41 @@ +#include "numrep1.h" +#include +#include +#include +#include + + +#include "numrep2.h" + +typedef CGAL_Point_2< TestR > point_t; +typedef CGAL_Segment_2< TestR > segment_t; +typedef CGAL_Triangle_2< TestR > triangle_t; + + +int main() +{ + randomint ri; + int x1, x2, x3, y1, y2, y3, w1, w2, w3; + TestR::FT d; + cin >> x1 >> y1 >> x2 >> y2; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + segment_t seg(tp1, tp2); + cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + w3 = ri.next(); + point_t tp3(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp4(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + point_t tp5(to_nt(w3*x3), to_nt(w3*y3), to_nt(w3)); + triangle_t tr(tp3, tp4, tp5); + d = CGAL_squared_distance(seg, tr); + cout << CGAL_to_double(d) << '\n'; + return 0; +} diff --git a/Packages/Distance_2/test/Distance_2/tst34.C b/Packages/Distance_2/test/Distance_2/tst34.C new file mode 100644 index 00000000000..329cb50a031 --- /dev/null +++ b/Packages/Distance_2/test/Distance_2/tst34.C @@ -0,0 +1,41 @@ +#include "numrep1.h" +#include +#include +#include + + +#include "numrep2.h" + +typedef CGAL_Point_2< TestR > point_t; +typedef CGAL_Triangle_2< TestR > triangle_t; + + +int main() +{ + randomint ri; + int x1, x2, x3, y1, y2, y3, w1, w2, w3; + TestR::FT d; + cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + w3 = ri.next(); + point_t tp1(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp2(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + point_t tp3(to_nt(w3*x3), to_nt(w3*y3), to_nt(w3)); + triangle_t tr1(tp1, tp2, tp3); + cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3; + if (!cin) + return 1; + w1 = ri.next(); + w2 = ri.next(); + w3 = ri.next(); + point_t tp4(to_nt(w1*x1), to_nt(w1*y1), to_nt(w1)); + point_t tp5(to_nt(w2*x2), to_nt(w2*y2), to_nt(w2)); + point_t tp6(to_nt(w3*x3), to_nt(w3*y3), to_nt(w3)); + triangle_t tr2(tp4, tp5, tp6); + d = CGAL_squared_distance(tr1, tr2); + cout << CGAL_to_double(d) << '\n'; + return 0; +} diff --git a/Packages/Distance_2/version b/Packages/Distance_2/version new file mode 100644 index 00000000000..001fa3efff4 --- /dev/null +++ b/Packages/Distance_2/version @@ -0,0 +1 @@ +1.5 (10 Mar 1998) diff --git a/Packages/Distance_2/web/.cvsignore b/Packages/Distance_2/web/.cvsignore new file mode 100644 index 00000000000..36d4e698dba --- /dev/null +++ b/Packages/Distance_2/web/.cvsignore @@ -0,0 +1 @@ +lis diff --git a/Packages/Distance_2/web/Makefile b/Packages/Distance_2/web/Makefile new file mode 100644 index 00000000000..e8f887231bf --- /dev/null +++ b/Packages/Distance_2/web/Makefile @@ -0,0 +1,9 @@ +PARENTDIR = /users/geert/CGAL/Geert/lib +include $(PARENTDIR)/make_defs + +xsrcs: sqdistance_2.xsrc + +srcs: sqdistance_2.src + +texs: sqdistance_2.tex + diff --git a/Packages/Distance_2/web/cgal_util.fwi b/Packages/Distance_2/web/cgal_util.fwi new file mode 100644 index 00000000000..62b6254d964 --- /dev/null +++ b/Packages/Distance_2/web/cgal_util.fwi @@ -0,0 +1,45 @@ +@$@@(@2@)@Z@M==@{@- +template +inline bool CGAL_do_intersect( + const CGAL_@1 &p1, + const CGAL_@2 &p2) +{ + typedef CGAL_@1_@2_pair pair_t; + pair_t pair(&p1, &p2); + return pair.intersection_type() != pair_t::NO; +}@- +@} + +@$@@(@4@)@Z@M==@{@- +@! parameter description with an example value +@! file : include/CGAL/Optimisation/Min_circle_2.h +@! source : web/Optimisation/Min_circle_2.aw +@! author(s) : Sven Schoenherr , Bernd Gaertner +@! coordinator : ETH Zurich +// ============================================================================ +// +// Copyright (c) 1998 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------------- +// +// release : $CGAL_Revision: $ +// release_date : $CGAL_Date: $ +// +// file : @1 +// source : @2 +// author(s) : @3 +// +// coordinator : @4 +// +// ============================================================================ +@} + +@$@@(@2@)@Z@M==@{@- +#ifndef CGAL_@2_H +#include +#endif +@} diff --git a/Packages/Distance_2/web/sqdistance_2.fw b/Packages/Distance_2/web/sqdistance_2.fw new file mode 100644 index 00000000000..f84c0e35450 --- /dev/null +++ b/Packages/Distance_2/web/sqdistance_2.fw @@ -0,0 +1,2209 @@ +@! $RCSfile$ +@! $Revision$ +@! $Date$ + +@! Author: Geert-Jan Giezeman (geert@cs.ruu.nl) + +@i cgal_util.fwi + +@A@ + +The routines in this chapter compute the square of the euclidean distance +between objects. + +By computing the square of the distance between two objects instead of the +distance itself, often the computation of a square root is avoided. +This is not only important for efficiency reasons. +There may be number types (especially when an exact representation is used) +where taking the square root is not possible. + +@B@ + +While computing square distances I need a number of routines that are not +supplied as basic facilities in CGAL, but that are pretty basic and not tied +to distance computations. Perhaps they should be added to more basic +components. + +@C@ + +In order to avoid division (which is important for homogeneous types), we +sometimes need to compute with different routines than the natural ones. +We prefix the natural name of such a routine with a @{w@} to indicate this. + +For example, the dot product of two vectors @{u@} and @{v@} is computed as +@{dot(u,v) == (ux.vx+uy.vy)/(uw.vw)@}. +The routine @{wdot@} is computed as follows: @{wdot(u,v) == ux.vx+uy.vy@}. +We use a short notation here where @{ux@} stands for @{u.hx()@}, @{uw@} stands +for @{u.hw()@} and so on. + +Often we only need the sign of a routine. Then multiplication by homogeneous +factors has no influence, as they are positive by definition. +Also, when we need to compare the dot product of two different vectors, we can +use multiplications instead of divisions. Instead of comparing @{dot(p,q)@} +with @{dot(u,v)@}, we can compare @{uw.vw.wdot(p,q)@} with +@{pw.qw.wdot(u,v)@}. The homogenising factors are brought to the other side of +the comparison operator which can be done, again, because they are positive. + +The homogeneous factors that are multiplied differ from case to case. This +makes those routines pretty low level and care should be taken when they are +used. + +In the case of cartesian coordinates, we know that the homogenising factors +are 1 by definition. This leads to ample possibilities for optimisation. +Therefore, most routines have a specialisation for the cartesian case that is +more efficient. + + +@D@ + +As we have seen in the example where dot products are compared, we sometimes +need to multiply by homogenising factors. Of course, the multiplication +operator can be used for this. Still, we provide a special function, @{wmult@} +for this. The reason to do that is that now we can define a specialisation for +cartesian types. In that case, the multiplication is a noop and can be +optimised away. + +There are versions of @{wmult@} taking a different number of parameters. This +depends on the number of factors that are to be multiplied. +Of the multiplying factors the first may an arbitrary number. +The other (1 or 2) factors must be homogenising factors. +This allows the optimisation in the cartesian case. + +The routines take a, quite unnatural, first parameter. +This is the mechanism that allows to decide between the cartesian or general +case. + +@O@<../include/CGAL/wmult.h@>==@{@- +@@(@- +include/CGAL/wmult.h@,@- +sqdistance_2.fw@,@- +Geert-Jan Giezeman@,@- +Saarbruecken@) + +#ifndef CGAL_WMULT_H +#define CGAL_WMULT_H + +#ifdef CGAL_HOMOGENEOUS_H +template +inline RT CGAL_wmult(CGAL_Homogeneous*, const RT &a, const RT & w) +{ + return a*w; +} + +template +inline RT CGAL_wmult(CGAL_Homogeneous*, + const RT &a, const RT & w1, const RT & w2) +{ + return a*w1*w2; +} + +template +inline RT CGAL_wmult(CGAL_Homogeneous*, const RT &a, + const RT & w1, const RT & w2, const RT & w3) +{ + return a*w1*w2*w3; +} + +template +inline RT CGAL_wmult(CGAL_Homogeneous*, const RT &a, + const RT & w1, const RT & w2, const RT & w3, const RT & w4) +{ + return a*w1*w2*w3*w4; +} +#endif // CGAL_HOMOGENEOUS_H + +#ifdef CGAL_CARTESIAN_H +template +inline RT CGAL_wmult(CGAL_Cartesian *, const RT &a, const RT & ) +{ + return a; +} + +template +inline RT CGAL_wmult(CGAL_Cartesian *, + const RT &a, const RT & , const RT & ) +{ + return a; +} + +template +inline RT CGAL_wmult(CGAL_Cartesian *, const RT &a, + const RT & , const RT & , const RT & ) +{ + return a; +} + +template +inline RT CGAL_wmult(CGAL_Cartesian *, const RT &a, + const RT & , const RT & , const RT & , const RT & ) +{ + return a; +} +#endif // CGAL_CARTESIAN_H + +#endif // CGAL_WMULT_H +@} + +@D@ + +A routine to test whether a vector is a null vector. +This code does not belong here. +@$@<2D squared distance general utilities@>+=@{ +template +bool CGAL_is_null(const CGAL_Vector_2 &v) +{ + typedef typename R::RT RT; + return v.hx()==RT(0) && v.hy()==RT(0); +} +@} + +@D@ + +The dot product is useful for projecting a point on a line, and for deciding +whether an angle is acute, straight or obtuse. +Apart from the @{wdot@} routine there are also routines that use @{wdot@} to +decide on the acuteness of an angle. + +Of all the routines there are different flavours, taking points and +vectors as arguments respectively. The points @{p,q@} and @{r@} stand +for the vectors @{p-q@} and @{r-q@}. The homogenising factors that are used +for multiplication are different though. +For vectors @{u@} and @{v@} we have @{wdot(u,v) == wu.wv.dot(u,v)@} +For points @{p,q@} and @{r@} we have @{wdot(p,q,r) == wp.wq.wq.wr.dot(p-q,r-q)@} +Note the double occurrence of the factor@{wq@} in the latter definition. + +@$@<2D squared distance general utilities@>+=@{ + +template +R_RT_return(R) +CGAL_wdot(const CGAL_Vector_2 &u, + const CGAL_Vector_2 &v) +{ + return (R_RT_return(R))(u.hx()*v.hx() + u.hy()*v.hy()); +} + +#ifdef CGAL_HOMOGENEOUS_H +template +RT CGAL_wdot(const CGAL_Point_2< CGAL_Homogeneous > &p, + const CGAL_Point_2 > &q, + const CGAL_Point_2 > &r) +{ + return (q.hw()*p.hx() - p.hw()*q.hx())*(q.hw()*r.hx() - r.hw()*q.hx()) + + (q.hw()*p.hy() - p.hw()*q.hy())*(q.hw()*r.hy() - r.hw()*q.hy()); +} +#endif // CGAL_HOMOGENEOUS_H + +#ifdef CGAL_CARTESIAN_H +template +FT CGAL_wdot(const CGAL_Point_2< CGAL_Cartesian > &p, + const CGAL_Point_2< CGAL_Cartesian > &q, + const CGAL_Point_2< CGAL_Cartesian > &r) +{ + return (p.hx() - q.hx())*(r.hx() - q.hx()) + + (p.hy() - q.hy())*(r.hy() - q.hy()); +} +#endif // CGAL_CARTESIAN_H +@} + + +@D@ + +The cross product of two vectors can be used for various purposes. +The sign tells whether the two vectors make a left or right turn or are +collinear (have the same or opposite direction). The absolute value gives the +area of the parallelogram spanned by the two vectors. This can also be used to +compute the (signed) distance from a point to a line. + +Like with the dot product, we have versions for two vectors and for three +points. + +We define @{wcross(u,v) == wu.wv.cross(u,v)@} and +@{wcross(p,q,r) == @}@{wp.wq.wr.cross(q-p,r-q)@}. +Different from the dot case, the factor @{wq@} occurs only once in the +definition of the wcross product for points. + + +@$@<2D squared distance general utilities@>+=@{ + + +template +R_RT_return(R) +CGAL_wcross(const CGAL_Vector_2 &u, + const CGAL_Vector_2 &v) +{ + return (R_RT_return(R))(u.hx()*v.hy() - u.hy()*v.hx()); +} + +#ifdef CGAL_HOMOGENEOUS_H +template +RT CGAL_wcross(const CGAL_Point_2< CGAL_Homogeneous > &p, + const CGAL_Point_2< CGAL_Homogeneous > &q, + const CGAL_Point_2< CGAL_Homogeneous > &r) +{ + return p.hx() * (q.hy()*r.hw() - q.hw()*r.hy() ) + + p.hy() * (q.hw()*r.hx() - q.hx()*r.hw() ) + + p.hw() * (q.hx()*r.hy() - q.hy()*r.hx() ); +} +#endif // CGAL_HOMOGENEOUS_H + +#ifdef CGAL_CARTESIAN_H +template +FT CGAL_wcross(const CGAL_Point_2< CGAL_Cartesian > &p, + const CGAL_Point_2< CGAL_Cartesian > &q, + const CGAL_Point_2< CGAL_Cartesian > &r) +{ + return (q.x()-p.x())*(r.y()-q.y()) - (q.y()-p.y())*(r.x()-q.x()); +} +#endif // CGAL_CARTESIAN_H +@} + +@C@ + +Often one needs to know whether an angle is sharp or obtuse or whether it is a +left turn or a right turn. An angle can be characterised by three points +@{p,q@} and @{r@} (the angle formed at @{q@} when going from @{p@} to @{r@} +via @{q@}), or by two vectors @{u@} and @{v@} (the angle formed when their +tails are placed in the origin). +Then we can use the routines @{wdot@} and @{wcross@} for this purpose. + +@D@ + +Here are routines to decide whether an angle is sharp, straight or obtuse. +There should also be an enum with three values (@{CGAL_ACUTE@}, +@{CGAL_STRAIGHT@},@{CGAL_OBTUSE@}) and a routine that returns such a value. + +@$@<2D squared distance general utilities@>+=@{ +template +inline bool CGAL_is_acute_angle(const CGAL_Vector_2 &u, + const CGAL_Vector_2 &v) +{ + typedef typename R::RT RT; + return RT(CGAL_wdot(u, v)) > RT(0) ; +} + +template +inline bool CGAL_is_straight_angle(const CGAL_Vector_2 &u, + const CGAL_Vector_2 &v) +{ + typedef typename R::RT RT; + return RT(CGAL_wdot(u, v)) == RT(0) ; +} + +template +inline bool CGAL_is_obtuse_angle(const CGAL_Vector_2 &u, + const CGAL_Vector_2 &v) +{ + typedef typename R::RT RT; + return RT(CGAL_wdot(u, v)) < RT(0) ; +} + +template +inline bool CGAL_is_acute_angle(const CGAL_Point_2 &p, + const CGAL_Point_2 &q, const CGAL_Point_2 &r) +{ + typedef typename R::RT RT; + return RT(CGAL_wdot(p, q, r)) > RT(0) ; +} + +template +inline bool CGAL_is_straight_angle(const CGAL_Point_2 &p, + const CGAL_Point_2 &q, const CGAL_Point_2 &r) +{ + typedef typename R::RT RT; + return RT(CGAL_wdot(p, q, r)) == RT(0) ; +} + +template +inline bool CGAL_is_obtuse_angle(const CGAL_Point_2 &p, + const CGAL_Point_2 &q, const CGAL_Point_2 &r) +{ + typedef typename R::RT RT; + return RT(CGAL_wdot(p, q, r)) < RT(0) ; +} +@} + + +@D@ + +The following routines decide whether the smallest angle between two vectors +(when their tails are in the same point) is clockwise or counterclockwise. +If both angles are equal (zero or pi), the vectors are collinear. + +If the angle is characterised by three points @{p@}, @{q@} and @{r@}, it is +more natural to think of making a left or right turn at @{q@} when going from +@{p@} to @{r@}. Those routines are implemented elsewhere, though. + +@$@<2D squared distance general utilities@>+=@{ +template +CGAL_Orientation CGAL_orientation(const CGAL_Vector_2 &u, + const CGAL_Vector_2 &v) +{ + typedef typename R::RT RT; + RT wcr = CGAL_wcross(u,v); + return (wcr > RT(0)) ? CGAL_COUNTERCLOCKWISE : + (wcr < RT(0)) ? CGAL_CLOCKWISE + : CGAL_COLLINEAR; +} + +template +inline bool CGAL_counterclockwise(const CGAL_Vector_2 &u, + const CGAL_Vector_2 &v) +{ + typedef typename R::RT RT; + return RT(CGAL_wcross(u,v)) > RT(0); +} + +template +inline bool CGAL_leftturn(const CGAL_Vector_2 &u, + const CGAL_Vector_2 &v) +{ + typedef typename R::RT RT; + return RT(CGAL_wcross(u,v)) > RT(0); +} + +template +inline bool CGAL_clockwise(const CGAL_Vector_2 &u, + const CGAL_Vector_2 &v) +{ + typedef typename R::RT RT; + return RT(CGAL_wcross(u,v)) < RT(0); +} + +template +inline bool CGAL_rightturn(const CGAL_Vector_2 &u, + const CGAL_Vector_2 &v) +{ + typedef typename R::RT RT; + return RT(CGAL_wcross(u,v)) < RT(0); +} + +template +inline bool CGAL_collinear(const CGAL_Vector_2 &u, + const CGAL_Vector_2 &v) +{ + typedef typename R::RT RT; + return RT(CGAL_wcross(u,v)) == RT(0); +} + +/* +the ordertype, rightturn, leftturn and collinear routines for points are +defined elsewhere. +*/ + +@} + +@B@ + +The squared distance between two points is computed by taking the dot product +of the difference vector. + +@$@<2D squared distance header declarations 1@>+=@{@- +template +inline R_FT_return(R) +CGAL_squared_distance( + const CGAL_Point_2 & pt1, + const CGAL_Point_2 & pt2) +{ + CGAL_Vector_2 vec(pt1-pt2); + return (R_FT_return(R))(vec*vec); +} + +@} + +@B@ + +@C@ + +@$@<2D squared distance header declarations 1@>+=@{@- + +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Point_2 &pt, + const CGAL_Line_2 &line); + +template +inline R_FT_return(R) +CGAL_squared_distance( + const CGAL_Line_2 & line, + const CGAL_Point_2 & pt) +{ + return CGAL_squared_distance(pt, line); +} +@} + +@C@ + +We compute a vector perpendicular to the line(@{normal@}). +The dot product of a vector from the point to an arbitrary point on the line +with the @{normal@} is the (signed) distance from the point to the line, +multiplied with the length of @{normal@}. Taking the square of this value and +dividing by the square of the length of the @{normal@} gives the square +distance between the line and the point. + + +@$@<2D squared distance outline definitions 1@>+=@{ +template +R_FT_return(R) +CGAL_squared_distance( + const CGAL_Point_2 &pt, + const CGAL_Line_2 &line) +{ + typedef typename R::RT RT; + typedef typename R::FT FT; + RT x = line.a(); + RT y = line.b(); + CGAL_Vector_2 normal(x, y); + CGAL_Vector_2 diff = pt - line.point(); + FT signdist = diff * normal; + return (R_FT_return(R))((signdist*signdist)/FT(x*x+y*y)); +} +@} + +@B@ + +@C@ + +@$@<2D squared distance header declarations 1@>+=@{@- +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Point_2 &pt, + const CGAL_Ray_2 &ray); + +template +inline R_FT_return(R) +CGAL_squared_distance( + const CGAL_Ray_2 & ray, + const CGAL_Point_2 & pt) +{ + return CGAL_squared_distance(pt, ray); +} +@} + +@C@ + +We test the angle between the direction vector of the ray and the vector from +the start point of the ray to the point @{pt@}. If this angle is acute, +a line perpendicular to the ray through @{pt@} passes through the ray, so we +the distance from the point to the ray is the same as the distance from the +point to the supporting line of the ray. Otherwise we compute the squared +distance from @{pt@} to the start point of the ray, as this is the closest +point. + +@$@<2D squared distance outline definitions 1@>+=@{ +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Point_2 &pt, + const CGAL_Ray_2 &ray) +{ + CGAL_Vector_2 diff = pt-ray.source(); + const CGAL_Vector_2 &dir = ray.direction().vector(); + if (!CGAL_is_acute_angle(dir,diff) ) + return (R_FT_return(R))(diff*diff); + return CGAL_squared_distance(pt, ray.supporting_line()); +} +@} + +@B@ + +@$@<2D squared distance header declarations 1@>+=@{ +template +extern void +CGAL_distance_index( + int &ind, + const CGAL_Point_2 &pt, + const CGAL_Ray_2 &ray); + +template +extern R_FT_return(R) +CGAL_squared_distance_indexed(const CGAL_Point_2 &pt, + const CGAL_Ray_2 &ray, int ind1, int ind2); +@} + +@C@ + +@$@<2D squared distance outline definitions 1@>+=@{ +template +extern void +CGAL_distance_index( + int &ind, + const CGAL_Point_2 &pt, + const CGAL_Ray_2 &ray) +{ + if (!CGAL_is_acute_angle(ray.direction().vector(),pt-ray.source())) { + ind = 0; + return; + } + ind = -1; +} + +template +R_FT_return(R) +CGAL_squared_distance_indexed(const CGAL_Point_2 &pt, + const CGAL_Ray_2 &ray, int ind) +{ + if (ind == 0) + return CGAL_squared_distance(pt, ray.source()); + return CGAL_squared_distance(pt, ray.supporting_line()); +} +@} + +@B@ + +@$@<2D squared distance header declarations 1@>+=@{@- + +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Point_2 &pt, + const CGAL_Segment_2 &seg); + + +template +inline R_FT_return(R) +CGAL_squared_distance( + const CGAL_Segment_2 & seg, + const CGAL_Point_2 & pt) +{ + return CGAL_squared_distance(pt, seg); +} + +@} + +@C@ + +To compute the distance of a point to a segment, first we divide the plane in +three parts. We draw two lines perpendicular to the segment, one through the +start point, the other through the end point of the segment. If the query +point lies between those two lines, we need to compute the distance of the +query point to the supporting line of the segment. Otherwise we need to +compute the distance from the point to either the endpoint or the startpoint. + +To decide which case applies, we compute the dot poduct of the vector from +segment start to segment end and the vector from segment start to the point. +If this product is negative, the distance from the point to the start of the +segment is taken. + +@$@<2D squared distance outline definitions 1@>+=@{ +template +R_FT_return(R) +CGAL_squared_distance( + const CGAL_Point_2 &pt, + const CGAL_Segment_2 &seg) +{ + typedef typename R::RT RT; + // assert that the segment is valid (non zero length). + CGAL_Vector_2 diff = pt-seg.source(); + CGAL_Vector_2 segvec = seg.target()-seg.source(); + RT d = CGAL_wdot(diff,segvec); + if (d <= (RT)0) + return (R_FT_return(R))(diff*diff); + RT e = CGAL_wdot(segvec,segvec); + if (CGAL_wmult((R*)0 ,d, segvec.hw()) > CGAL_wmult((R*)0, e, diff.hw())) + return CGAL_squared_distance(pt, seg.target()); + return CGAL_squared_distance(pt, seg.supporting_line()); +} +@} + +@B@ + +@$@<2D squared distance header declarations 1@>+=@{ +template +extern void +CGAL_distance_index( + int &ind, + const CGAL_Point_2 &pt, + const CGAL_Segment_2 &seg); + +template +extern R_FT_return(R) +CGAL_squared_distance_indexed(const CGAL_Point_2 &pt, + const CGAL_Segment_2 &seg, int ind1, int ind2); +@} + +@C@ + +@$@<2D squared distance outline definitions 1@>+=@{ +template +extern void +CGAL_distance_index( + int &ind, + const CGAL_Point_2 &pt, + const CGAL_Segment_2 &seg) +{ + if (!CGAL_is_acute_angle(seg.target(),seg.source(),pt)) { + ind = 0; + return; + } + if (!CGAL_is_acute_angle(seg.source(),seg.target(),pt)) { + ind = 1; + return; + } + ind = -1; +} + +template +R_FT_return(R) +CGAL_squared_distance_indexed(const CGAL_Point_2 &pt, + const CGAL_Segment_2 &seg, int ind) +{ + if (ind == 0) + return CGAL_squared_distance(pt, seg.source()); + if (ind == 1) + return CGAL_squared_distance(pt, seg.target()); + return CGAL_squared_distance(pt, seg.supporting_line()); +} +@} + +@B@ + +@C@ + +@$@<2D squared distance header declarations 1@>+=@{@- +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Segment_2 &, + const CGAL_Segment_2 &); + + +@} + +@C@ + +If two segments do not cross, the distance of the two segments can be found by +comparing the distance of the endpoints to the other segment. The minimum +of those four distances is the distance between the two segments. This is the +fact that is exploited in the implementation. + +@D@ + +To compute the squared distance of two segments, the following steps are +taken. + +First we check if one of the segments is degenerate (coinciding start and +end point). If so, we solve the problem for a point and a segment. + +Then we decide if the one segment crosses the supporting line of the other +segment. The boolean @{crossing1@} tells whether @{seg1@} crosses the +supporting line of @{seg2@}, and vice versa for @{crossing2@}. +To decide whether they cross, we look at the sign of the cross product. If an +endpoint lies on the supporting line, we consider this as crossing. The value +of the cross product is stored in a variable because it is needed later on. +This is also the reason why we do not use the ordertype routine to decide on +which side the points lie. That would mean double work. + +A special case arises if both segments lie on the same supporting line. +This is checked separately. + +@$@<2D segment segment squared distance main routine@>+=@{ +template +R_FT_return(R) +CGAL_squared_distance( + const CGAL_Segment_2 &seg1, + const CGAL_Segment_2 &seg2) +{ + typedef typename R::RT RT; + typedef typename R::FT FT; + bool crossing1, crossing2; + RT c1s, c1e, c2s, c2e; + if (seg1.source() == seg1.target()) + return CGAL_squared_distance(seg1.source(), seg2); + if (seg2.source() == seg2.target()) + return CGAL_squared_distance(seg2.source(), seg1); + c1s = CGAL_wcross(seg2.source(), seg2.target(), seg1.source()); + c1e = CGAL_wcross(seg2.source(), seg2.target(), seg1.target()); + c2s = CGAL_wcross(seg1.source(), seg1.target(), seg2.source()); + c2e = CGAL_wcross(seg1.source(), seg1.target(), seg2.target()); + if (c1s < RT(0)) { + crossing1 = (c1e >= RT(0)); + } else { + if (c1e <= RT(0)) { + if (c1s == RT(0) && c1e == RT(0)) + return CGAL_squared_distance_parallel(seg1, seg2); + crossing1 = true; + } else { + crossing1 = (c1s == RT(0)); + } + } + if (c2s < RT(0)) { + crossing2 = (c2e >= RT(0)); + } else { + if (c2e <= RT(0)) { + if (c2s == RT(0) && c2e == RT(0)) + return CGAL_squared_distance_parallel(seg1, seg2); + crossing2 = true; + } else { + crossing2 = (c2s == RT(0)); + } + } +@} + +Depending on the values of the crossing variables we now proceed. If both +segments cross the supporting line of the other segment, the segments +themselves must cross, so they have zero distance. + +If exactly one of the segments does not cross, the distance is the +distance of one of the endpoints of this (non crossing) segment to the +other (crossing) segment. Which endpoint? The one that is closest to the +supporting lines of the other segment. This latter property can easily be +computed with the value of the cross product that was computed earlier. +The function @{CGAL__distance_measure_sub@} makes this comparison (it +subtracts the two absolute values of the cross product, first corrected by +homogenising factors). + +Note that the computation of the endpoint closest to a line may be +susceptible to roundoff error. The result can be incorrect in that +case. This must still be solved, for instance by computing the squared +distance from both endpoints to the other segment and taking the minimum. + +@$@@Z==@{ +template +R_FT_return(R) +CGAL__squared_distance_of_endpoint_exact(RT start_dm, RT end_dm, + const CGAL_Point_2 &start, const CGAL_Point_2 &end, + const CGAL_Segment &seg) +{ + typedef typename R::RT RT; + RT dm; + dm = CGAL__distance_measure_sub(start_dm, end_dm, start, end); + if (dm < RT(0)) { + return CGAL_squared_distance(start, seg); + } else { + return CGAL_squared_distance(end, seg); + } +} + +template +R_FT_return(R) +CGAL__squared_distance_of_endpoint_inexact( + const CGAL_Point_2 &start, const CGAL_Point_2 &end, + const CGAL_Segment &seg) +{ + typedef typename R::RT RT; + RT d1, d2; + d1 = CGAL_squared_distance(start, seg); + d2 = CGAL_squared_distance(end, seg); + return (d1 < d2) ? (R_FT_return(R))(d1) : (R_FT_return(R))(d2); +} + +template +inline R_FT_return(R) +CGAL__squared_distance_of_endpoint(RT start_dm, RT end_dm, + const CGAL_Point_2 &start, const CGAL_Point_2 &end, + const CGAL_Segment &seg) +{ + if (numeric_limits::is_exact) + return CGAL__squared_distance_of_endpoint_exact( + start_dm, end_dm, start, end, seg); + else + return CGAL__squared_distance_of_endpoint_inexact(start, end, seg); +} +@} + +@$@<2D segment segment squared distance main routine@>+=@{ + if (crossing1) { + if (crossing2) + return (R_FT_return(R))((FT)0); + RT dm; + dm = CGAL__distance_measure_sub(c2s,c2e, seg2.source(), seg2.target()); + if (dm < RT(0)) { + return CGAL_squared_distance(seg2.source(), seg1); + } else { + if (dm > RT(0)) { + return CGAL_squared_distance(seg2.target(), seg1); + } else { + // parallel, should not happen (no crossing) + return CGAL_squared_distance_parallel(seg1, seg2); + } + } + } else { + if (crossing2) { + RT dm; + dm = + CGAL__distance_measure_sub(c1s, c1e,seg1.source(),seg1.target()); + if (dm < RT(0)) { + return CGAL_squared_distance(seg1.source(), seg2); + } else { + if (dm > RT(0)) { + return CGAL_squared_distance(seg1.target(), seg2); + } else { + // parallel, should not happen (no crossing) + return CGAL_squared_distance_parallel(seg1, seg2); + } + } + } else { +@} + +Finally, neither of the segments may cross. This may be because the two +segments are parallel, which we deal with as a separate case. +Otherwise we have to compare the distance of two endpoints to the other +segment and take the minimum. + +@$@<2D segment segment squared distance main routine@>+=@{ + FT min1, min2; + RT dm = CGAL__distance_measure_sub( + c1s, c1e, seg1.source(), seg1.target()); + if (dm == RT(0)) + return CGAL_squared_distance_parallel(seg1, seg2); + min1 = (dm < RT(0)) ? + CGAL_squared_distance(seg1.source(), seg2): + CGAL_squared_distance(seg1.target(), seg2); + dm = CGAL__distance_measure_sub( + c2s, c2e, seg2.source(), seg2.target()); + if (dm == RT(0)) // should not happen. + return CGAL_squared_distance_parallel(seg1, seg2); + min2 = (dm < RT(0)) ? + CGAL_squared_distance(seg2.source(), seg1): + CGAL_squared_distance(seg2.target(), seg1); + return (min1 < min2) + ? (R_FT_return(R))(min1) + : (R_FT_return(R))(min2); + } + } +} + +@} + +We need a small helper function to compare the distance from a point to the +intersection point of the supporting lines of the two segments. With the help +of the cross product (that is known), this can be computed cheaply. + +@$@<2D segment segment squared distance helper routine@>==@{ +template +RT CGAL__distance_measure_sub(RT startwcross, RT endwcross, +const CGAL_Point_2 &start, const CGAL_Point_2 &end +) +{ + return CGAL_abs(CGAL_wmult((R*)0, startwcross, end.hw())) - + CGAL_abs(CGAL_wmult((R*)0, endwcross, start.hw())); +} +@} + +We still need to deal with the case where both segments are parallel. The +segments may not be degenerate (this was tested before), but they may have +opposite directions. This is checked and stored in the boolean variable +@{same_direction@}. + +The distance between two parallel segments is either the +distance between two endpoints or the distance between an arbitrary point on +one segment to the supporting line of the other segment. In order to decide +which case applies, we can project the second segment perpendicularly on the +supporting line of the first segment. If the resulting segments overlap, the +second case apllies, otherwise the former case. The projections are just a way +of explaining, they are not actually done. The sign of the dot product is used +to make the necessary decisions. + +@$@<2D segment segment squared distance parallel case@>+=@{ + +template +R_FT_return(R) +CGAL_squared_distance_parallel( + const CGAL_Segment_2 &seg1, + const CGAL_Segment_2 &seg2) +{ + bool same_direction; + const CGAL_Vector_2 &dir1 = seg1.direction().vector(); + const CGAL_Vector_2 &dir2 = seg2.direction().vector(); + if (CGAL_abs(dir1.hx()) > CGAL_abs(dir1.hy())) { + same_direction = (CGAL_sign(dir1.hx()) == CGAL_sign(dir2.hx())); + } else { + same_direction = (CGAL_sign(dir1.hy()) == CGAL_sign(dir2.hy())); + } + if (same_direction) { + if (!CGAL_is_acute_angle(seg1.source(), seg1.target(), seg2.source())) + return CGAL_squared_distance(seg1.target(), seg2.source()); + if (!CGAL_is_acute_angle(seg1.target(), seg1.source(), seg2.target())) + return CGAL_squared_distance(seg1.source(), seg2.target()); + } else { + if (!CGAL_is_acute_angle(seg1.source(), seg1.target(), seg2.target())) + return CGAL_squared_distance(seg1.target(), seg2.target()); + if (!CGAL_is_acute_angle(seg1.target(), seg1.source(), seg2.source())) + return CGAL_squared_distance(seg1.source(), seg2.source()); + } + return CGAL_squared_distance(seg2.source(), seg1.supporting_line()); +} +@} + +@$@<2D squared distance outline definitions 1@>+=@{ +@<2D segment segment squared distance parallel case@> +@<2D segment segment squared distance helper routine@> +@<2D segment segment squared distance main routine@> +@} + +@B@ + +@C@ + +@$@<2D squared distance header declarations 1@>+=@{@- + +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Segment_2 &seg, + const CGAL_Ray_2 &ray); + + +template +inline R_FT_return(R) +CGAL_squared_distance( + const CGAL_Ray_2 & ray, + const CGAL_Segment_2 & seg) +{ + return CGAL_squared_distance(seg, ray); +} + +@} + +@C@ + +The computation of the squared distance between a segment and a ray goes along +the same lines as the computation of the square distance of two segments. +We give only short comments here. + +First we check if the segment is degenerate (coinciding start and +end point). If so, we solve the problem for a point and a ray. + +Then we decide if the one segment crosses the supporting line of the other +segment. The boolean @{crossing1@} tells whether the segment crosses the +supporting line of the ray, @{crossing2@} tells whether the ray crosses the +supporting line of the segment. + +For the ray we look at the direction and on which side its starting point +lies. + +@$@<2D ray segment squared distance computation@>+=@{ +template +R_FT_return(R) +CGAL_squared_distance( + const CGAL_Segment_2 &seg, + const CGAL_Ray_2 &ray) +{ + typedef typename R::RT RT; + typedef typename R::FT FT; + const CGAL_Vector_2 &raydir = ray.direction().vector(); + CGAL_Vector_2 startvec(seg.source()-ray.source()); + CGAL_Vector_2 endvec(seg.target()-ray.source()); + + + bool crossing1, crossing2; + RT c1s, c1e; + CGAL_Orientation ray_s_side; + if (seg.source() == seg.target()) + return CGAL_squared_distance(seg.source(), ray); + c1s = CGAL_wcross(raydir, startvec); + c1e = CGAL_wcross(raydir, endvec); + if (c1s < RT(0)) { + crossing1 = (c1e >= RT(0)); + } else { + if (c1e <= RT(0)) { + if (c1s == RT(0) && c1e == RT(0)) + return CGAL_squared_distance_parallel(seg, ray); + crossing1 = true; + } else { + crossing1 = (c1s == RT(0)); + } + } + ray_s_side = CGAL_orientation(seg.source(), seg.target(), ray.source()); + switch (ray_s_side) { + case CGAL_LEFTTURN: + crossing2 = CGAL_rightturn(seg.target()-seg.source(), raydir); + break; + case CGAL_RIGHTTURN: + crossing2 = CGAL_leftturn(seg.target()-seg.source(), raydir); + break; + case CGAL_COLLINEAR: + crossing2 = true; + break; + } +@} + +Depending on the values of the crossing variables we now proceed. If both +segments cross the supporting line of the other segment, the segments +themselves must cross, so they have zero distance. + +If exactly one of the segments does not cross, the distance is the +distance of one of the endpoints of this (non crossing) segment to the +other (crossing) segment. Which endpoint? The one that is closest to the +intersection point of the supporting lines of the two segments. This +latter property can easily be computed with the value of the cross product +that was computed earlier. The function @{CGAL__distance_measure_sub@} +makes this comparison (it subtracts the two absolute values of the cross +product, first corrected by homogenising factors). + + + +@$@<2D ray segment squared distance computation@>+=@{ + if (crossing1) { + if (crossing2) + return (R_FT_return(R))(FT(0)); + return CGAL_squared_distance(ray.source(), seg); + } else { + if (crossing2) { + RT dm; + dm = CGAL__distance_measure_sub(c1s, c1e, startvec, endvec); + if (dm < RT(0)) { + return CGAL_squared_distance(seg.source(), ray); + } else { + if (dm > RT(0)) { + return CGAL_squared_distance(seg.target(), ray); + } else { + // parallel, should not happen (no crossing) + return CGAL_squared_distance_parallel(seg, ray); + } + } + } else { +@} + +Finally, neither of the segments may cross. This may be because the two +segments are parallel, which we deal with as a separate case. +Otherwise we have to compare the distance of two endpoints to the other +segment and take the minimum. + +@$@<2D ray segment squared distance computation@>+=@{ + FT min1, min2; + RT dm; + dm = CGAL__distance_measure_sub(c1s, c1e, startvec, endvec); + if (dm == RT(0)) + return CGAL_squared_distance_parallel(seg, ray); + min1 = (dm < RT(0)) + ? CGAL_squared_distance(seg.source(), ray) + : CGAL_squared_distance(seg.target(), ray); + min2 = CGAL_squared_distance(ray.source(), seg); + return (min1 < min2) + ? (R_FT_return(R))(min1) + : (R_FT_return(R))(min2); + } + } +} +@} + +@$@<2D ray segment squared distance parallel case@>==@{ +template +R_FT_return(R) +CGAL_squared_distance_parallel( + const CGAL_Segment_2 &seg, + const CGAL_Ray_2 &ray) +{ + bool same_direction; + const CGAL_Vector_2 &dir1 = seg.direction().vector(); + const CGAL_Vector_2 &dir2 = ray.direction().vector(); + if (CGAL_abs(dir1.hx()) > CGAL_abs(dir1.hy())) { + same_direction = (CGAL_sign(dir1.hx()) == CGAL_sign(dir2.hx())); + } else { + same_direction = (CGAL_sign(dir1.hy()) == CGAL_sign(dir2.hy())); + } + if (same_direction) { + if (!CGAL_is_acute_angle(seg.source(), seg.target(), ray.source())) + return CGAL_squared_distance(seg.target(), ray.source()); + } else { + if (!CGAL_is_acute_angle(seg.target(), seg.source(), ray.source())) + return CGAL_squared_distance(seg.source(), ray.source()); + } + return CGAL_squared_distance(ray.source(), seg.supporting_line()); +} +@} + +@$@<2D ray segment squared distance helper routine@>==@{ +template +RT CGAL__distance_measure_sub(RT startwcross, RT endwcross, +const CGAL_Vector_2 &start, const CGAL_Vector_2 &end +) +{ + return CGAL_abs(CGAL_wmult((R*)0, startwcross, end.hw())) - + CGAL_abs(CGAL_wmult((R*)0, endwcross, start.hw())); +} +@} + + +@$@<2D squared distance outline definitions 1@>+=@{ +@<2D ray segment squared distance helper routine@> +@<2D ray segment squared distance parallel case@> +@<2D ray segment squared distance computation@> +@} + +@B@ + +@C@ + +@$@<2D squared distance header declarations 1@>+=@{@- + +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Segment_2 &seg, + const CGAL_Line_2 &line); + + +template +inline R_FT_return(R) +CGAL_squared_distance( + const CGAL_Line_2 & line, + const CGAL_Segment_2 & seg) +{ + return CGAL_squared_distance(seg, line); +} + +@} + +@C@ + +The computation of the squared distance between a segment and a line goes along +the same lines as the computation of the square distance of two segments. + +First we check if the segment is degenerate (coinciding start and +end point). If so, we solve the problem for a point and a line. + +Then we decide if the segment crosses the line. +The boolean @{crossing1@} tells whether the segment crosses the line. + +@$@<2D line segment squared distance computation@>+=@{ +template +R_FT_return(R) +CGAL_squared_distance( + const CGAL_Segment_2 &seg, + const CGAL_Line_2 &line) +{ + typedef typename R::RT RT; + typedef typename R::FT FT; + const CGAL_Vector_2 &linedir = line.direction().vector(); + const CGAL_Point_2 &linepoint = line.point(); + CGAL_Vector_2 startvec(seg.source()-linepoint); + CGAL_Vector_2 endvec(seg.target()-linepoint); + + bool crossing1; + RT c1s, c1e; + if (seg.source() == seg.target()) + return CGAL_squared_distance(seg.source(), line); + c1s = CGAL_wcross(linedir, startvec); + c1e = CGAL_wcross(linedir, endvec); + if (c1s < RT(0)) { + crossing1 = (c1e >= RT(0)); + } else { + if (c1e <= RT(0)) { + crossing1 = true; + } else { + crossing1 = (c1s == RT(0)); + } + } +@} + +If the segment crosses the line, they have zero distance. Otherwise, the +distance is the distance of one of the endpoints of the segment to the +line. Which endpoint? The one that is closest to the supporting line of +the other segment. This latter property can easily be computed with the +value of the cross product that was computed earlier. The function +@{CGAL__distance_measure_sub@} makes this comparison (it subtracts the two +absolute values of the cross product, first corrected by homogenising +factors). + + + +@$@<2D line segment squared distance computation@>+=@{ + if (crossing1) { + return (R_FT_return(R))((FT)0); + } else { + RT dm; + dm = CGAL__distance_measure_sub(c1s, c1e, startvec, endvec); + if (dm <= RT(0)) { + return CGAL__sqd_to_line(startvec, c1s, linedir); + } else { + return CGAL__sqd_to_line(endvec, c1e, linedir); + } + } +} +@} + +The following routine returns the square distance from a point to a line. +It is an optimised routine, that makes use of the intermediate results that +are available. It is based on the observation that given @{diff@}, the +difference vector between the point and a point on the line, and @{dir@}, the +(not necessarily normalized) direction vector of the line, the squared +distance can be computed as: @{cross(dir,diff)^2 / dot(dir,dir)@}. +We can write this in terms of wcross and wdot operations and multiplications +with hw factors. The hw factors of @{dir@} cancel. + + +@$@<2D line segment squared distance helper routine@>==@{ +template +R_FT_return(R) +CGAL__sqd_to_line(const CGAL_Vector_2 &diff, + const RT & wcross, const CGAL_Vector_2 &dir ) +{ + typedef typename R::FT FT; + RT numerator = wcross*wcross; + RT denominator = CGAL_wmult((R*)0, RT(CGAL_wdot(dir,dir)), + diff.hw(), diff.hw()); + FT result = R::make_FT(numerator, denominator); + return (R_FT_return(R))(result); +} +@} + + +@$@<2D squared distance outline definitions 1@>+=@{ +@<2D line segment squared distance helper routine@> +@<2D line segment squared distance computation@> +@} + +@B@ + +@$@<2D squared distance header declarations 1@>+=@{@- + +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Ray_2 &ray1, + const CGAL_Ray_2 &ray2); + +@} + +@C@ + + + +The computation of the squared distance two rays goes along the same lines as +the computation of the square distance between a segment and a ray. + +First we decide if the one ray crosses the supporting line of the other ray. +The boolean @{crossing1@} tells whether @{ray1@} crosses the supporting line +of the @{ray2@}, @{crossing2@} tells whether @{ray2@} crosses the +supporting line of @{ray1@}. +We look at the direction of the ray and on which side its starting point lies. + +@$@<2D ray ray squared distance computation@>+=@{ +template +R_FT_return(R) +CGAL_squared_distance( + const CGAL_Ray_2 &ray1, + const CGAL_Ray_2 &ray2) +{ + typedef typename R::FT FT; + const CGAL_Vector_2 &ray1dir = ray1.direction().vector(); + const CGAL_Vector_2 &ray2dir = ray2.direction().vector(); + CGAL_Vector_2 diffvec(ray2.source()-ray1.source()); + + bool crossing1, crossing2; + CGAL_Orientation dirorder; + dirorder = CGAL_orientation(ray1dir, ray2dir); + switch (dirorder) { + case CGAL_COUNTERCLOCKWISE: + crossing1 = !CGAL_clockwise(diffvec, ray2dir); + crossing2 = !CGAL_counterclockwise(ray1dir, diffvec); + break; + case CGAL_CLOCKWISE: + crossing1 = !CGAL_counterclockwise(diffvec, ray2dir); + crossing2 = !CGAL_clockwise(ray1dir, diffvec); + break; + case CGAL_COLLINEAR: + return CGAL_ray_ray_squared_distance_parallel(ray1dir,ray2dir,diffvec); + } +@} + +Depending on the values of the crossing variables we now proceed. If both +rays cross the supporting line of the other ray, the rays +themselves must cross, so they have zero distance. + +If exactly one of the rays does not cross, the distance is the distance of +the startpoint of this (non crossing) ray to the other (crossing) +ray. + + + +@$@<2D ray ray squared distance computation@>+=@{ + if (crossing1) { + if (crossing2) + return (R_FT_return(R))((FT)0); + return CGAL_squared_distance(ray2.source(), ray1); + } else { + if (crossing2) { + return CGAL_squared_distance(ray1.source(), ray2); + } else { +@} + +Finally, neither of the rays may cross. This may be because the two +rays are parallel, which we deal with as a separate case. +Otherwise we have to compare the distance of two endpoints to the other +ray and take the minimum. + +@$@<2D ray ray squared distance computation@>+=@{ + FT min1, min2; + min1 = CGAL_squared_distance(ray1.source(), ray2); + min2 = CGAL_squared_distance(ray2.source(), ray1); + return (min1 < min2) + ? (R_FT_return(R))(min1) + : (R_FT_return(R))(min2); + } + } +} +@} + +The following routine computes the squared distance between two rays if they +are parallel. The parameters are the directions of the rays and the vector +from the start point of the first ray to the start point of the second. + +The distance is the distance between the two start points if there is no +line perpendicular to the rays that passes through both rays. Otherwise we can +take the distance between the starting point of the one ray to the supporting +line of the other. + + +@$@<2D ray ray squared distance parallel case@>==@{ +template +R_FT_return(R) +CGAL_ray_ray_squared_distance_parallel( + const CGAL_Vector_2 &ray1dir, + const CGAL_Vector_2 &ray2dir, + const CGAL_Vector_2 &from1to2) +{ + typedef typename R::RT RT; + typedef typename R::FT FT; + if (!CGAL_is_acute_angle(ray1dir, from1to2)) { + bool same_direction; + if (CGAL_abs(ray1dir.hx()) > CGAL_abs(ray1dir.hy())) { + same_direction = + (CGAL_sign(ray1dir.hx()) == CGAL_sign(ray2dir.hx())); + } else { + same_direction = + (CGAL_sign(ray1dir.hy()) == CGAL_sign(ray2dir.hy())); + } + if (!same_direction) + return (R_FT_return(R))(from1to2*from1to2); + } + RT wcr, w; + wcr = CGAL_wcross(ray1dir, from1to2); + w = from1to2.hw(); + return (R_FT_return(R))(FT(wcr*wcr) + / FT(CGAL_wmult((R*)0, RT(CGAL_wdot(ray1dir, ray1dir)), w, w))); +} +@} + +@$@<2D squared distance outline definitions 1@>+=@{ +@<2D ray ray squared distance parallel case@> +@<2D ray ray squared distance computation@> +@} + +@B@ + +@$@<2D squared distance header declarations 1@>+=@{@- + +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Line_2 &line, + const CGAL_Ray_2 &ray); + + +template +inline R_FT_return(R) +CGAL_squared_distance( + const CGAL_Ray_2 & ray, + const CGAL_Line_2 & line) +{ + return CGAL_squared_distance(line, ray); +} + +@} + +@C@ + +First we decide if the ray and the line intersect. +The normal to the line is taken. +If the start point of the ray lies on the normal side of the line and the +direction of the ray has a component in the opposite direction of the normal +(or the other way around), the line and ray intersect and 0 is returned. + +Otherwise the squared distance from the start point to the line is reported. +Because we have intermediate results for this computation, we do not call +that routine but compute it using primitive operations. + +It would be nice to have a routine to get the normal vector of a line (or of a +direction). + + +@$@<2D squared distance outline definitions 1@>+=@{ +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Line_2 &line, + const CGAL_Ray_2 &ray) +{ + typedef typename R::FT FT; + CGAL_Vector_2 normalvec(line.a(), line.b()); + CGAL_Vector_2 diff = ray.source()-line.point(); + FT sign_dist = diff*normalvec; + if (sign_dist < FT(0)) { + if (CGAL_is_acute_angle(normalvec, ray.direction().vector()) ) + return (R_FT_return(R))((FT)0); + } else { + if (CGAL_is_obtuse_angle(normalvec, ray.direction().vector()) ) + return (R_FT_return(R))((FT)0); + } + return (R_FT_return(R))((sign_dist*sign_dist)/(normalvec*normalvec)); +} +@} + +@B@ + +@$@<2D squared distance header declarations 1@>+=@{@- + +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Line_2 &line1, + const CGAL_Line_2 &line2); + +@} + +@C@ + +The distance between two lines is zero unless the two lines are paralel. In +that case we can take the distance of an arbitrary point on the one line to +the other line. + +@$@<2D squared distance outline definitions 1@>+=@{ +template +bool +CGAL__are_parallel( + const CGAL_Line_2 &line1, + const CGAL_Line_2 &line2) +{ + return line1.a()*line2.b() == line2.a()*line1.b(); +} + +template +R_FT_return(R) +CGAL_squared_distance( + const CGAL_Line_2 &line1, + const CGAL_Line_2 &line2) +{ + typedef typename R::FT FT; + if (CGAL__are_parallel(line1,line2)) + return CGAL_squared_distance(line1.point(), line2); + else + return (R_FT_return(R))((FT)0); +} +@} + +@B@ + +The @{distance_index@} function computes to which feature of the +triangle the point is closest. +If the point lies inside the triangle, both indices are set to -1. +If the point is closest to the interior of a triangle edge, the indices +are set to the indices of the vertices of that edge, such that the point +lies to the right of the line through vertex(ind1) and vertex(ind2). +Otherwise, the point is closest to a vertex of the triangle. Then ind2 is +set to -1 and vertex(ind1) is the closest vertex. + +@$@<2D squared distance header declarations 2@>+=@{ +template +extern void +CGAL_distance_index( + int &ind1, + int &ind2, + const CGAL_Point_2 &pt, + const CGAL_Triangle_2 &triangle); +@} + +@$@<2D squared distance header declarations 2@>+=@{ +template +extern R_FT_return(R) +CGAL_squared_distance_indexed(const CGAL_Point_2 &pt, + const CGAL_Triangle_2 &triangle, int ind1, int ind2); +@} + +@C@ + +The implementation discerns between a whole lot of cases. +The outermost if then else clause discerns between a positive oriented +triangle (vertices in counterclockwise order) and a negative oriented. +The code in the else part is identical, except that the role of vertex 1 and 2 +of the triangle are swapped. + +A point can either lie inside the triangle, be closest to the interior of an +edge or closest to a vertex. +It lies inside the triangle iff it lies not to the right of any supporting +line of the triangle edges (for a positive oriented triangle). +It is closest to an edge if it lies to the right of the edge and if both the +angle edge.source, edge.target, point and edge.target, edge.source, point are +sharp. +Otherwise the point lies closest to a vertex. + +@$@<2D squared distance outline definitions 2@>+=@{ +template +extern void +CGAL_distance_index( + int &ind1, + int &ind2, + const CGAL_Point_2 &pt, + const CGAL_Triangle_2 &triangle) +{ + const CGAL_Point_2 &vt0 = triangle.vertex(0); + const CGAL_Point_2 &vt1 = triangle.vertex(1); + const CGAL_Point_2 &vt2 = triangle.vertex(2); + if (CGAL_leftturn(vt0, vt1, vt2)) { + if (CGAL_rightturn(vt0, vt1, pt)) { + if (!CGAL_is_acute_angle(vt0, vt1, pt)) { + if (CGAL_rightturn(vt1, vt2, pt)) { + if (!CGAL_is_acute_angle(vt1, vt2, pt)) { + ind1 = 2; ind2 = -1; + return; + } + if (!CGAL_is_acute_angle(vt2, vt1, pt)) { + ind1 = 1; ind2 = -1; + return; + } + ind1 = 1; ind2 = 2; + return; + } + ind1 = 1; ind2 = -1; + return; + } + if (!CGAL_is_acute_angle(vt1, vt0, pt)) { + if (CGAL_rightturn(vt2, vt0, pt)) { + if (!CGAL_is_acute_angle(vt0, vt2, pt)) { + ind1 = 2; ind2 = -1; + return; + } + if (!CGAL_is_acute_angle(vt2, vt0, pt)) { + ind1 = 0; ind2 = -1; + return; + } + ind1 = 2; ind2 = 0; + return; + } + ind1 = 0; ind2 = -1; + return; + } + ind1 = 0; ind2 = 1; + return; + } else { + if (CGAL_rightturn(vt1, vt2, pt)) { + if (!CGAL_is_acute_angle(vt1, vt2, pt)) { + if (CGAL_rightturn(vt2, vt0, pt)) { + if (!CGAL_is_acute_angle(vt0, vt2, pt)) { + ind1 = 2; ind2 = -1; + return; + } + if (!CGAL_is_acute_angle(vt2, vt0, pt)) { + ind1 = 0; ind2 = -1; + return; + } + ind1 = 2; ind2 = 0; + return; + } + ind1 = 0; ind2 = -1; + return; + } + if (!CGAL_is_acute_angle(vt2, vt1, pt)) { + ind1 = 1; ind2 = -1; + return; + } + ind1 = 1; ind2 = 2; + return; + } else { + if (CGAL_rightturn(vt2, vt0, pt)) { + if (!CGAL_is_acute_angle(vt2, vt0, pt)) { + ind1 = 0; ind2 = -1; + return; + } + if (!CGAL_is_acute_angle(vt0, vt2, pt)) { + ind1 = 2; ind2 = -1; + return; + } + ind1 = 2; ind2 = 0; + return; + } else { + ind1 = -1; ind2 = -1; // point inside or on boundary. + return; + } + } + } + } else { + if (CGAL_rightturn(vt0, vt2, pt)) { + if (!CGAL_is_acute_angle(vt0, vt2, pt)) { + if (CGAL_rightturn(vt2, vt1, pt)) { + if (!CGAL_is_acute_angle(vt2, vt1, pt)) { + ind1 = 1; ind2 = -1; + return; + } + if (!CGAL_is_acute_angle(vt1, vt2, pt)) { + ind1 = 2; ind2 = -1; + return; + } + ind1 = 2; ind2 = 1; + return; + } + ind1 = 2; ind2 = -1; + return; + } + if (!CGAL_is_acute_angle(vt2, vt0, pt)) { + if (CGAL_rightturn(vt1, vt0, pt)) { + if (!CGAL_is_acute_angle(vt0, vt1, pt)) { + ind1 = 1; ind2 = -1; + return; + } + if (!CGAL_is_acute_angle(vt1, vt0, pt)) { + ind1 = 0; ind2 = -1; + return; + } + ind1 = 1; ind2 = 0; + return; + } + ind1 = 0; ind2 = -1; + return; + } + ind1 = 0; ind2 = 2; + return; + } else { + if (CGAL_rightturn(vt2, vt1, pt)) { + if (!CGAL_is_acute_angle(vt2, vt1, pt)) { + if (CGAL_rightturn(vt1, vt0, pt)) { + if (!CGAL_is_acute_angle(vt0, vt1, pt)) { + ind1 = 1; ind2 = -1; + return; + } + if (!CGAL_is_acute_angle(vt1, vt0, pt)) { + ind1 = 0; ind2 = -1; + return; + } + ind1 = 1; ind2 = 0; + return; + } + ind1 = 0; ind2 = -1; + return; + } + if (!CGAL_is_acute_angle(vt1, vt2, pt)) { + ind1 = 2; ind2 = -1; + return; + } + ind1 = 2; ind2 = 1; + return; + } else { + if (CGAL_rightturn(vt1, vt0, pt)) { + if (!CGAL_is_acute_angle(vt1, vt0, pt)) { + ind1 = 0; ind2 = -1; + return; + } + if (!CGAL_is_acute_angle(vt0, vt1, pt)) { + ind1 = 1; ind2 = -1; + return; + } + ind1 = 1; ind2 = 0; + return; + } else { + ind1 = -1; ind2 = -1; // point inside or on boundary. + return; + } + } + } + } +} +@} + +@$@<2D squared distance outline definitions 2@>+=@{ +template +extern R_FT_return(R) +CGAL_squared_distance_indexed(const CGAL_Point_2 &pt, + const CGAL_Triangle_2 &triangle, int ind1, int ind2) +{ + typedef typename R::FT FT; + if (ind1 == -1) + return (R_FT_return(R))(FT(0)); + if (ind2 == -1) + return CGAL_squared_distance(pt, triangle.vertex(ind1)); + return CGAL_squared_distance(pt, + CGAL_Line_2(triangle.vertex(ind1), triangle.vertex(ind2))); +} +@} + + +@B@ + +@$@<2D squared distance header declarations 2@>+=@{@- +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Point_2 &pt, + const CGAL_Triangle_2 &triangle); + + +template +inline R_FT_return(R) +CGAL_squared_distance( + const CGAL_Triangle_2 & triangle, + const CGAL_Point_2 & pt) +{ + return CGAL_squared_distance(pt, triangle); +} + +@} + +@C@ + + +@$@<2D squared distance outline definitions 2@>+=@{ +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Point_2 &pt, + const CGAL_Triangle_2 &triangle) +{ + int ind1,ind2; + CGAL_distance_index(ind1, ind2, pt, triangle); + return CGAL_squared_distance_indexed(pt, triangle, ind1, ind2); +} +@} + +@B@ + +@$@<2D squared distance header declarations 2@>+=@{@- +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Line_2 &line, + const CGAL_Triangle_2 &triangle); + + +template +inline R_FT_return(R) +CGAL_squared_distance( + const CGAL_Triangle_2 & triangle, + const CGAL_Line_2 & line) +{ + return CGAL_squared_distance(line, triangle); +} + +@} + +@C@ + + +@$@<2D squared distance outline definitions 2@>+=@{ +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Line_2 &line, + const CGAL_Triangle_2 &triangle) +{ + typedef typename R::FT FT; + CGAL_Oriented_side side0; + side0 = line.oriented_side(triangle.vertex(0)); + if (line.oriented_side(triangle.vertex(1)) != side0) + return (R_FT_return(R))(FT(0)); + if (line.oriented_side(triangle.vertex(2)) != side0) + return (R_FT_return(R))(FT(0)); + FT mindist, dist; + int i; + mindist = CGAL_squared_distance(triangle.vertex(0),line); + for (i=1; i<3; i++) { + dist = CGAL_squared_distance(triangle.vertex(i),line); + if (dist < mindist) + mindist = dist; + } + return (R_FT_return(R))(mindist); +} +@} + +@B@ + +@$@<2D squared distance header declarations 2@>+=@{@- +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Ray_2 &ray, + const CGAL_Triangle_2 &triangle); + + +template +inline R_FT_return(R) +CGAL_squared_distance( + const CGAL_Triangle_2 & triangle, + const CGAL_Ray_2 & ray) +{ + return CGAL_squared_distance(ray, triangle); +} + +@} + +@C@ + + +@$@<2D squared distance outline definitions 2@>+=@{ +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Ray_2 &ray, + const CGAL_Triangle_2 &triangle) +{ + typedef typename R::FT FT; + int i, ind_tr1, ind_tr2, ind_ray = 0, ind1; + FT mindist, dist; + CGAL_distance_index(ind_tr1, ind_tr2, ray.source(), triangle); + mindist = + CGAL_squared_distance_indexed(ray.source(), triangle, ind_tr1,ind_tr2); + for (i=0; i<3; i++) { + const CGAL_Point_2& pt = triangle.vertex(i); + CGAL_distance_index(ind1, pt, ray); + dist = CGAL_squared_distance_indexed(pt, ray, ind1); + if (dist < mindist) { + ind_ray = ind1; + ind_tr1 = i; ind_tr2 = -1; + mindist = dist; + } + } + // now check if all vertices are on the right side of the separating line. + // In case of vertex-vertex smallest distance this is the case. + if (ind_tr2 == -1 && ind_ray != -1) + return (R_FT_return(R))(mindist); + if (ind_tr2 != -1) { +// Check if all the segment vertices lie at the same side of +// the triangle segment. + const CGAL_Point_2 &vt1 = triangle.vertex(ind_tr1); + const CGAL_Point_2 &vt2 = triangle.vertex(ind_tr2); + if (CGAL_clockwise(ray.direction().vector(), vt2-vt1)) { + mindist = FT(0); + } + } else { +// Check if all the triangle vertices lie at the same side of the segment. + const CGAL_Line_2 &sl = ray.supporting_line(); + CGAL_Oriented_side or = sl.oriented_side(triangle.vertex(0)); + for (i=1; i<3; i++) { + if (sl.oriented_side(triangle.vertex(i)) != or) { + mindist = FT(0); + break; + } + } + } + return (R_FT_return(R))(mindist); +} +@} + +@B@ + +@$@<2D squared distance header declarations 2@>+=@{@- +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Segment_2 &seg, + const CGAL_Triangle_2 &triangle); + + +template +inline R_FT_return(R) +CGAL_squared_distance( + const CGAL_Triangle_2 & triangle, + const CGAL_Segment_2 & seg) +{ + return CGAL_squared_distance(seg, triangle); +} + +@} + +@C@ + + +@$@<2D squared distance outline definitions 2@>+=@{ +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Segment_2 &seg, + const CGAL_Triangle_2 &triangle) +{ + typedef typename R::FT FT; + int i, ind_tr1 = 0, ind_tr2 = -1, ind_seg = 0, ind1, ind2; + FT mindist, dist; + mindist = CGAL_squared_distance(seg.source(), triangle.vertex(0)); + for (i=0; i<2; i++) { + const CGAL_Point_2 &pt = seg.vertex(i); + CGAL_distance_index(ind1, ind2, pt, triangle); + dist = CGAL_squared_distance_indexed(pt, triangle, ind1, ind2); + if (dist < mindist) { + ind_seg = i; + ind_tr1 = ind1; ind_tr2 = ind2; + mindist = dist; + } + } + for (i=0; i<3; i++) { + const CGAL_Point_2& pt = triangle.vertex(i); + CGAL_distance_index(ind1, pt, seg); + dist = CGAL_squared_distance_indexed(pt, seg, ind1); + if (dist < mindist) { + ind_seg = ind1; + ind_tr1 = i; ind_tr2 = -1; + mindist = dist; + } + } + // now check if all vertices are on the right side of the separating line. + // In case of vertex-vertex smallest distance this is the case. + if (ind_tr2 == -1 && ind_seg != -1) + return (R_FT_return(R))(mindist); + + if (ind_tr2 != -1) { +// Check if all the segment vertices lie at the same side of +// the triangle segment. + const CGAL_Point_2 &vt1 = triangle.vertex(ind_tr1); + const CGAL_Point_2 &vt2 = triangle.vertex(ind_tr2); + CGAL_Orientation or = CGAL_orientation(vt1, vt2, seg.source()); + if (CGAL_orientation(vt1, vt2, seg.target()) != or) { + mindist = FT(0); + } + } else { +// Check if all the triangle vertices lie at the same side of the segment. + const CGAL_Point_2 &vt1 = seg.source(); + const CGAL_Point_2 &vt2 = seg.target(); + CGAL_Orientation or = CGAL_orientation(vt1, vt2, triangle.vertex(0)); + for (i=1; i<3; i++) { + if (CGAL_orientation(vt1, vt2, triangle.vertex(i)) != or) { + mindist = FT(0); + break; + } + } + } + return (R_FT_return(R))(mindist); +} +@} + +@B@ + +@$@<2D squared distance header declarations 2@>+=@{@- +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Triangle_2 &triangle1, + const CGAL_Triangle_2 &triangle2); +@} + +@C@ + + +@$@<2D squared distance outline definitions 2@>+=@{ +template +extern R_FT_return(R) +CGAL_squared_distance( + const CGAL_Triangle_2 &triangle1, + const CGAL_Triangle_2 &triangle2) +{ + typedef typename R::FT FT; + int i, ind1_1 = 0,ind1_2 = -1, ind2_1 = 0, ind2_2 = -1, ind1, ind2; + FT mindist, dist; + mindist = + CGAL_squared_distance(triangle1.vertex(0), triangle2.vertex(0)); + for (i=0; i<3; i++) { + const CGAL_Point_2& pt = triangle1.vertex(i); + CGAL_distance_index(ind1, ind2, pt, triangle2); + dist = CGAL_squared_distance_indexed(pt, triangle2, ind1, ind2); + if (dist < mindist) { + ind1_1 = i; ind1_2 = -1; + ind2_1 = ind1; ind2_2 = ind2; + mindist = dist; + } + } + for (i=0; i<3; i++) { + const CGAL_Point_2& pt = triangle2.vertex(i); + CGAL_distance_index(ind1, ind2, pt, triangle1); + dist = CGAL_squared_distance_indexed(pt, triangle1, ind1, ind2); + if (dist < mindist) { + ind1_1 = ind1; ind1_2 = ind2; + ind2_1 = i; ind2_2 = -1; + mindist = dist; + } + } + // now check if all vertices are on the right side of the separating line. + if (ind1_2 == -1 && ind2_2 == -1) + return (R_FT_return(R))(mindist); + // In case of point-segment closest distance, there is still the possibility + // of overlapping triangles. + // Check if all the vertices lie at the same side of the segment. + if (ind1_2 != -1) { + const CGAL_Point_2 &vt1 = triangle1.vertex(ind1_1); + const CGAL_Point_2 &vt2 = triangle1.vertex(ind1_2); + CGAL_Orientation or = CGAL_orientation(vt1, vt2, triangle2.vertex(0)); + for (i=1; i<3; i++) { + if (CGAL_orientation(vt1, vt2, triangle2.vertex(i)) != or) { + mindist = FT(0); + break; + } + } + } else { + const CGAL_Point_2 &vt1 = triangle2.vertex(ind2_1); + const CGAL_Point_2 &vt2 = triangle2.vertex(ind2_2); + CGAL_Orientation or = CGAL_orientation(vt1, vt2, triangle1.vertex(0)); + for (i=1; i<3; i++) { + if (CGAL_orientation(vt1, vt2, triangle1.vertex(i)) != or) { + mindist = FT(0); + break; + } + } + } + return (R_FT_return(R))(mindist); +} +@} + +@B@ +@O@<../include/CGAL/squared_distance_utils.h@>==@{@- +@@(@- +include/CGAL/squared_distance_utils.h@,@- +sqdistance_2.fw@,@- +Geert-Jan Giezeman@,@- +Saarbruecken@) + +#ifndef CGAL_SQUARED_DISTANCE_UTILS_H +#define CGAL_SQUARED_DISTANCE_UTILS_H + +@<2D squared distance general utilities@> + +#endif // CGAL_SQUARED_DISTANCE_UTILS_H +@} + +@O@<../include/CGAL/squared_distance_2_1.h@>==@{@- +@@(@- +include/CGAL/squared_distance_2_1.h@,@- +sqdistance_2.fw@,@- +Geert-Jan Giezeman@,@- +Saarbruecken@) + +#ifndef CGAL_SQUARED_DISTANCE_2_1_H +#define CGAL_SQUARED_DISTANCE_2_1_H + +#ifndef CGAL_USER_CLASSES_H +#include +#endif // CGAL_USER_CLASSES_H + + +@<2D squared distance header declarations 1@> + + +#ifdef CGAL_CFG_NO_AUTOMATIC_TEMPLATE_INCLUSION +#include +#endif + + +#endif +@} + + +@O@<../include/CGAL/squared_distance_2_1.C@>==@{@- +@@(@- +include/CGAL/squared_distance_2_1.C@,@- +sqdistance_2.fw@,@- +Geert-Jan Giezeman@,@- +Saarbruecken@) + +#ifndef CGAL_UTILS_H +#include +#endif // CGAL_UTILS_H +#ifndef CGAL_POINT_2_H +#include +#endif // CGAL_POINT_2_H +#ifndef CGAL_SEGMENT_2_H +#include +#endif // CGAL_SEGMENT_2_H +#ifndef CGAL_LINE_2_H +#include +#endif // CGAL_LINE_2_H +#ifndef CGAL_RAY_2_H +#include +#endif // CGAL_RAY_2_H +#ifndef CGAL_ENUM_H +#include +#endif // CGAL_ENUM_H +#ifndef CGAL_WMULT_H +#include +#endif // CGAL_WMULT_H +#ifndef CGAL_SQUARED_DISTANCE_UTILS_H +#include +#endif // CGAL_SQUARED_DISTANCE_UTILS_H +@<2D squared distance outline definitions 1@> +@} + +@O@<../include/CGAL/squared_distance_2_2.h@>==@{@- +@@(@- +include/CGAL/squared_distance_2_2.h@,@- +sqdistance_2.fw@,@- +Geert-Jan Giezeman@,@- +Saarbruecken@) + +#ifndef CGAL_SQUARED_DISTANCE_2_2_H +#define CGAL_SQUARED_DISTANCE_2_2_H + +#ifndef CGAL_USER_CLASSES_H +#include +#endif // CGAL_USER_CLASSES_H + + +@<2D squared distance header declarations 2@> + + +#ifdef CGAL_CFG_NO_AUTOMATIC_TEMPLATE_INCLUSION +#include +#endif + + +#endif +@} + +@O@<../include/CGAL/squared_distance_2_2.C@>==@{@- +@@(@- +include/CGAL/squared_distance_2_2.C@,@- +sqdistance_2.fw@,@- +Geert-Jan Giezeman@,@- +Saarbruecken@) + +#ifndef CGAL_UTILS_H +#include +#endif // CGAL_UTILS_H +#ifndef CGAL_POINT_2_H +#include +#endif // CGAL_POINT_2_H +#ifndef CGAL_SEGMENT_2_H +#include +#endif // CGAL_SEGMENT_2_H +#ifndef CGAL_LINE_2_H +#include +#endif // CGAL_LINE_2_H +#ifndef CGAL_RAY_2_H +#include +#endif // CGAL_RAY_2_H +#ifndef CGAL_TRIANGLE_2_H +#include +#endif // CGAL_TRIANGLE_2_H +#ifndef CGAL_ENUM_H +#include +#endif // CGAL_ENUM_H +#ifndef CGAL_WMULT_H +#include +#endif // CGAL_WMULT_H +#ifndef CGAL_SQUARED_DISTANCE_UTILS_H +#include +#endif // CGAL_SQUARED_DISTANCE_UTILS_H +#ifndef CGAL_SQUARED_DISTANCE_2_1_H +#include +#endif // CGAL_SQUARED_DISTANCE_2_1_H +@<2D squared distance outline definitions 2@> +@} + + +@O@<../include/CGAL/squared_distance_2.h@>==@{@- +@@(@- +include/CGAL/squared_distance_2.h@,@- +sqdistance_2.fw@,@- +Geert-Jan Giezeman@,@- +Saarbruecken@) + +#ifndef CGAL_SQUARED_DISTANCE_2_H +#define CGAL_SQUARED_DISTANCE_2_H + +#ifndef CGAL_SQUARED_DISTANCE_2_1_H +#include +#endif // CGAL_SQUARED_DISTANCE_2_1_H +#ifndef CGAL_SQUARED_DISTANCE_2_2_H +#include +#endif // CGAL_SQUARED_DISTANCE_2_2_H + +#endif +@} + + diff --git a/Packages/Distance_2/web/stdmacros.fwi b/Packages/Distance_2/web/stdmacros.fwi new file mode 100644 index 00000000000..58255b9cb8a --- /dev/null +++ b/Packages/Distance_2/web/stdmacros.fwi @@ -0,0 +1,8 @@ +@p typesetter = tex +@p no_doc_header +@p #line_offset = 0 +@p #line_depth = 1 +@$@==@{#line @<#line@> "@<#file@>"@} + +@p automatic_line_directive_macro = "line" +