perturbe renamed to perturb.

This commit is contained in:
Lutz Kettner 1997-06-26 16:38:44 +00:00
parent d59aa0abb4
commit f2cfff3589
2 changed files with 74 additions and 60 deletions

View File

@ -20,9 +20,10 @@
\ccChapterAuthor{Sven Sch\"onherr} \ccChapterAuthor{Sven Sch\"onherr}
A variety of geomeric object generators are provided in \cgal. They A variety of generators for random numbers and geometric objects is
are useful as synthetic test data sets, e.g.~for testing algorithms on provided in \cgal. They are useful as synthetic test data sets,
degenerate object sets and for performance analysis. e.g.~for testing algorithms on degenerate object sets and for
performance analysis.
The first section describes the random number source used for random The first section describes the random number source used for random
generators. The second section documents generators for point sets, generators. The second section documents generators for point sets,
@ -81,7 +82,7 @@ sets with multiple entries of identical items.
% +------------------------------------------------------------------------+ % +------------------------------------------------------------------------+
\newpage %\newpage
\section{2D Point Generators} \section{2D Point Generators}
\ccDefinition \ccDefinition
@ -133,7 +134,8 @@ Section~\ref{sectionCopyN}.
distributed in the open disc with radius $r$, distributed in the open disc with radius $r$,
i.e.~$|\ccc{*g}| < r$~. Two random numbers are needed from i.e.~$|\ccc{*g}| < r$~. Two random numbers are needed from
\ccc{rnd} for each point. \ccc{rnd} for each point.
\ccPrecond a function \ccc{CGAL_build_point()} for the point type \ccc{P}.} \ccPrecond a function \ccc{CGAL_build_point()} for the point type
\ccc{P} exists.}
\end{ccClassTemplate} \end{ccClassTemplate}
\ccHtmlNoClassFile \ccHtmlNoClassFile
@ -145,7 +147,8 @@ Section~\ref{sectionCopyN}.
distributed on the circle with radius $r$, distributed on the circle with radius $r$,
i.e.~$|\ccc{*g}| == r$~. A single random number is needed from i.e.~$|\ccc{*g}| == r$~. A single random number is needed from
\ccc{rnd} for each point. \ccc{rnd} for each point.
\ccPrecond a function \ccc{CGAL_build_point()} for the point type \ccc{P}.} \ccPrecond a function \ccc{CGAL_build_point()} for the point type
\ccc{P} exists.}
\end{ccClassTemplate} \end{ccClassTemplate}
\ccHtmlNoClassFile \ccHtmlNoClassFile
@ -155,10 +158,11 @@ Section~\ref{sectionCopyN}.
CGAL_random);}{% CGAL_random);}{%
$g$ is an input iterator creating points of type \ccc{P} uniformly $g$ is an input iterator creating points of type \ccc{P} uniformly
distributed in the half-open square with side length $a$, centered distributed in the half-open square with side length $a$, centered
around the origin, i.e.~$\forall p = \ccc{*g}: -\frac{a}{2} \le at the origin, i.e.~$\forall p = \ccc{*g}: -\frac{a}{2} \le
p.x() < \frac{a}{2}$ and $-\frac{a}{2} \le p.y() < \frac{a}{2}$~. p.x() < \frac{a}{2}$ and $-\frac{a}{2} \le p.y() < \frac{a}{2}$~.
Two random numbers are needed from \ccc{rnd} for each point. Two random numbers are needed from \ccc{rnd} for each point.
\ccPrecond a function \ccc{CGAL_build_point()} for the point type \ccc{P}.} \ccPrecond a function \ccc{CGAL_build_point()} for the point type
\ccc{P} exists.}
\end{ccClassTemplate} \end{ccClassTemplate}
\ccHtmlNoClassFile \ccHtmlNoClassFile
@ -168,11 +172,12 @@ Section~\ref{sectionCopyN}.
CGAL_random);}{% CGAL_random);}{%
$g$ is an input iterator creating points of type \ccc{P} uniformly $g$ is an input iterator creating points of type \ccc{P} uniformly
distributed on the boundary of the square with side length $a$, distributed on the boundary of the square with side length $a$,
centered around the origin, i.e.~$\forall p = \ccc{*g}:$ one centered at the origin, i.e.~$\forall p = \ccc{*g}:$ one
coordinate is either $\frac{a}{2}$ or $-\frac{a}{2}$ and for the coordinate is either $\frac{a}{2}$ or $-\frac{a}{2}$ and for the
other coordinate $c$ holds $-\frac{a}{2} \le c < \frac{a}{2}$~. other coordinate $c$ holds $-\frac{a}{2} \le c < \frac{a}{2}$~.
A single random number is needed from \ccc{rnd} for each point. A single random number is needed from \ccc{rnd} for each point.
\ccPrecond a function \ccc{CGAL_build_point()} for the point type \ccc{P}.} \ccPrecond a function \ccc{CGAL_build_point()} for the point type
\ccc{P} exists.}
\end{ccClassTemplate} \end{ccClassTemplate}
\ccHtmlNoClassFile \ccHtmlNoClassFile
@ -184,9 +189,10 @@ Section~\ref{sectionCopyN}.
distributed on the segment from $p$ to $q$ except $q$, distributed on the segment from $p$ to $q$ except $q$,
i.e.~$\ccc{*g} == (1-\lambda)\, p + \lambda q$ where $0 \le \lambda < 1$~. i.e.~$\ccc{*g} == (1-\lambda)\, p + \lambda q$ where $0 \le \lambda < 1$~.
A single random number is needed from \ccc{rnd} for each point. A single random number is needed from \ccc{rnd} for each point.
\ccPrecond a function \ccc{CGAL_build_point()} for the point type \ccc{P}. \ccPrecond a function \ccc{CGAL_build_point()} for the point type \ccc{P}
The expressions \ccc{CGAL_to_double(p.x())} and exists. The expressions \ccc{CGAL_to_double(p.x())} and
\ccc{CGAL_to_double(p.y())} must be legal and similar for $q$.} \ccc{CGAL_to_double(p.y())} must result in the respective
\ccc{double} representation of the coordinates and similar for $q$.}
\end{ccClassTemplate} \end{ccClassTemplate}
\ccHeading{Grid Points} \ccHeading{Grid Points}
@ -219,21 +225,21 @@ iterator.
Degenerate input sets like grid points can be randomly perturbed by a Degenerate input sets like grid points can be randomly perturbed by a
small amount to produce {\em quasi}-degenerate test sets. This small amount to produce {\em quasi}-degenerate test sets. This
challenges either numerical stability of algorithms using inexact challenges numerical stability of algorithms using inexact arithmetic and
arithmetic or exact predicates to compute the sign of expressions exact predicates to compute the sign of expressions slightly off from zero.
slightly off from zero.
\ccFunction{template <class ForwardIterator> \ccFunction{template <class ForwardIterator>
void CGAL_perturbe_points_2( ForwardIterator first, ForwardIterator last, void CGAL_perturb_points_2( ForwardIterator first, ForwardIterator last,
double xeps, double yeps = xeps, CGAL_Random& rnd = CGAL_random);} double xeps, double yeps = xeps, CGAL_Random& rnd = CGAL_random);}
{ perturbes the points in the range $[\ccc{first},\ccc{last})$ by { perturbs the points in the range $[\ccc{first},\ccc{last})$ by
replacing each point with a random point from the rectangle replacing each point with a random point from the rectangle
\ccc{xeps} $\times$ \ccc{yeps} centered around the original point. \ccc{xeps} $\times$ \ccc{yeps} centered at the original point.
Two random numbers are needed from \ccc{rnd} for each point. Two random numbers are needed from \ccc{rnd} for each point.
\ccPrecond a function \ccc{CGAL_build_point()} for the value type of \ccPrecond a function \ccc{CGAL_build_point()} for the value type of
the \ccc{ForwardIterator}. the \ccc{ForwardIterator} exists.
The expression \ccc{CGAL_to_double((*first).x())} and The expressions \ccc{CGAL_to_double((*first).x())} and
\ccc{CGAL_to_double((*first).y())} must be legal. \ccc{CGAL_to_double((*first).y())} must result in the respective
coordinate values.
} }
\ccHeading{Adding Degeneracies} \ccHeading{Adding Degeneracies}
@ -250,17 +256,18 @@ a point set.
OutputIterator CGAL_random_collinear_points_2( RandomAccessIterator first, OutputIterator CGAL_random_collinear_points_2( RandomAccessIterator first,
RandomAccessIterator last, RandomAccessIterator last,
size_t n, OutputIterator first2, CGAL_Random& rnd = CGAL_random);} size_t n, OutputIterator first2, CGAL_Random& rnd = CGAL_random);}
{ choose two random points from the range $[\ccc{first},\ccc{last})$, { randomly chooses two points from the range $[\ccc{first},\ccc{last})$,
create a random third point on the segment connecting this two creates a random third point on the segment connecting this two
points, and write it to \ccc{first2}. Repeat this $n$ times, thus points, and writes it to \ccc{first2}. Repeats this $n$ times, thus
writing $n$ points to \ccc{first2} that are collinear with points writing $n$ points to \ccc{first2} that are collinear with points
in the range $[\ccc{first},\ccc{last})$. in the range $[\ccc{first},\ccc{last})$.
Three random numbers are needed from \ccc{rnd} for each point. Three random numbers are needed from \ccc{rnd} for each point.
Returns the value of \ccc{first2} after inserting the $n$ points. Returns the value of \ccc{first2} after inserting the $n$ points.
\ccPrecond a function \ccc{CGAL_build_point()} for the value type of \ccPrecond a function \ccc{CGAL_build_point()} for the value type of
the \ccc{ForwardIterator}. the \ccc{ForwardIterator} exists.
The expression \ccc{CGAL_to_double((*first).x())} and The expressions \ccc{CGAL_to_double((*first).x())} and
\ccc{CGAL_to_double((*first).y())} must be legal. \ccc{CGAL_to_double((*first).y())} must result in the respective
coordinate values.
} }
\ccExample \ccExample
@ -308,7 +315,7 @@ Figure~\ref{figurePointGenerator}}{Figure <A HREF="#PointGenerators">
\end{ccHtmlOnly} \end{ccHtmlOnly}
The second example demostrates the point generators with integer The second example demonstrates the point generators with integer
points. Arithmetic with \ccc{double}'s is sufficient to produce points. Arithmetic with \ccc{double}'s is sufficient to produce
regular integer grids. See \ccTexHtml{% regular integer grids. See \ccTexHtml{%
Figure~\ref{figureIntegerPointGenerator}}{Figure Figure~\ref{figureIntegerPointGenerator}}{Figure
@ -380,7 +387,7 @@ $g$ satisfies the requirements of an input iterator. Each call to the
We want to generate a test set of 200 segments, where one endpoint is We want to generate a test set of 200 segments, where one endpoint is
chosen randomly from a horizontal segment of length 200, and the other chosen randomly from a horizontal segment of length 200, and the other
endpoint is chosen ramdomly from a circle of radius 250. See endpoint is chosen randomly from a circle of radius 250. See
\ccTexHtml{Figure~\ref{figureSegmentGenerator}}{Figure <A \ccTexHtml{Figure~\ref{figureSegmentGenerator}}{Figure <A
HREF="#SegmentGenerator"> <IMG SRC="cc_ref_up_arrow.gif" HREF="#SegmentGenerator"> <IMG SRC="cc_ref_up_arrow.gif"
ALT="reference arrow" WIDTH="10" HEIGHT="10"></A>} for the example ALT="reference arrow" WIDTH="10" HEIGHT="10"></A>} for the example

View File

@ -20,9 +20,10 @@
\ccChapterAuthor{Sven Sch\"onherr} \ccChapterAuthor{Sven Sch\"onherr}
A variety of geomeric object generators are provided in \cgal. They A variety of generators for random numbers and geometric objects is
are useful as synthetic test data sets, e.g.~for testing algorithms on provided in \cgal. They are useful as synthetic test data sets,
degenerate object sets and for performance analysis. e.g.~for testing algorithms on degenerate object sets and for
performance analysis.
The first section describes the random number source used for random The first section describes the random number source used for random
generators. The second section documents generators for point sets, generators. The second section documents generators for point sets,
@ -81,7 +82,7 @@ sets with multiple entries of identical items.
% +------------------------------------------------------------------------+ % +------------------------------------------------------------------------+
\newpage %\newpage
\section{2D Point Generators} \section{2D Point Generators}
\ccDefinition \ccDefinition
@ -133,7 +134,8 @@ Section~\ref{sectionCopyN}.
distributed in the open disc with radius $r$, distributed in the open disc with radius $r$,
i.e.~$|\ccc{*g}| < r$~. Two random numbers are needed from i.e.~$|\ccc{*g}| < r$~. Two random numbers are needed from
\ccc{rnd} for each point. \ccc{rnd} for each point.
\ccPrecond a function \ccc{CGAL_build_point()} for the point type \ccc{P}.} \ccPrecond a function \ccc{CGAL_build_point()} for the point type
\ccc{P} exists.}
\end{ccClassTemplate} \end{ccClassTemplate}
\ccHtmlNoClassFile \ccHtmlNoClassFile
@ -145,7 +147,8 @@ Section~\ref{sectionCopyN}.
distributed on the circle with radius $r$, distributed on the circle with radius $r$,
i.e.~$|\ccc{*g}| == r$~. A single random number is needed from i.e.~$|\ccc{*g}| == r$~. A single random number is needed from
\ccc{rnd} for each point. \ccc{rnd} for each point.
\ccPrecond a function \ccc{CGAL_build_point()} for the point type \ccc{P}.} \ccPrecond a function \ccc{CGAL_build_point()} for the point type
\ccc{P} exists.}
\end{ccClassTemplate} \end{ccClassTemplate}
\ccHtmlNoClassFile \ccHtmlNoClassFile
@ -155,10 +158,11 @@ Section~\ref{sectionCopyN}.
CGAL_random);}{% CGAL_random);}{%
$g$ is an input iterator creating points of type \ccc{P} uniformly $g$ is an input iterator creating points of type \ccc{P} uniformly
distributed in the half-open square with side length $a$, centered distributed in the half-open square with side length $a$, centered
around the origin, i.e.~$\forall p = \ccc{*g}: -\frac{a}{2} \le at the origin, i.e.~$\forall p = \ccc{*g}: -\frac{a}{2} \le
p.x() < \frac{a}{2}$ and $-\frac{a}{2} \le p.y() < \frac{a}{2}$~. p.x() < \frac{a}{2}$ and $-\frac{a}{2} \le p.y() < \frac{a}{2}$~.
Two random numbers are needed from \ccc{rnd} for each point. Two random numbers are needed from \ccc{rnd} for each point.
\ccPrecond a function \ccc{CGAL_build_point()} for the point type \ccc{P}.} \ccPrecond a function \ccc{CGAL_build_point()} for the point type
\ccc{P} exists.}
\end{ccClassTemplate} \end{ccClassTemplate}
\ccHtmlNoClassFile \ccHtmlNoClassFile
@ -168,11 +172,12 @@ Section~\ref{sectionCopyN}.
CGAL_random);}{% CGAL_random);}{%
$g$ is an input iterator creating points of type \ccc{P} uniformly $g$ is an input iterator creating points of type \ccc{P} uniformly
distributed on the boundary of the square with side length $a$, distributed on the boundary of the square with side length $a$,
centered around the origin, i.e.~$\forall p = \ccc{*g}:$ one centered at the origin, i.e.~$\forall p = \ccc{*g}:$ one
coordinate is either $\frac{a}{2}$ or $-\frac{a}{2}$ and for the coordinate is either $\frac{a}{2}$ or $-\frac{a}{2}$ and for the
other coordinate $c$ holds $-\frac{a}{2} \le c < \frac{a}{2}$~. other coordinate $c$ holds $-\frac{a}{2} \le c < \frac{a}{2}$~.
A single random number is needed from \ccc{rnd} for each point. A single random number is needed from \ccc{rnd} for each point.
\ccPrecond a function \ccc{CGAL_build_point()} for the point type \ccc{P}.} \ccPrecond a function \ccc{CGAL_build_point()} for the point type
\ccc{P} exists.}
\end{ccClassTemplate} \end{ccClassTemplate}
\ccHtmlNoClassFile \ccHtmlNoClassFile
@ -184,9 +189,10 @@ Section~\ref{sectionCopyN}.
distributed on the segment from $p$ to $q$ except $q$, distributed on the segment from $p$ to $q$ except $q$,
i.e.~$\ccc{*g} == (1-\lambda)\, p + \lambda q$ where $0 \le \lambda < 1$~. i.e.~$\ccc{*g} == (1-\lambda)\, p + \lambda q$ where $0 \le \lambda < 1$~.
A single random number is needed from \ccc{rnd} for each point. A single random number is needed from \ccc{rnd} for each point.
\ccPrecond a function \ccc{CGAL_build_point()} for the point type \ccc{P}. \ccPrecond a function \ccc{CGAL_build_point()} for the point type \ccc{P}
The expressions \ccc{CGAL_to_double(p.x())} and exists. The expressions \ccc{CGAL_to_double(p.x())} and
\ccc{CGAL_to_double(p.y())} must be legal and similar for $q$.} \ccc{CGAL_to_double(p.y())} must result in the respective
\ccc{double} representation of the coordinates and similar for $q$.}
\end{ccClassTemplate} \end{ccClassTemplate}
\ccHeading{Grid Points} \ccHeading{Grid Points}
@ -219,21 +225,21 @@ iterator.
Degenerate input sets like grid points can be randomly perturbed by a Degenerate input sets like grid points can be randomly perturbed by a
small amount to produce {\em quasi}-degenerate test sets. This small amount to produce {\em quasi}-degenerate test sets. This
challenges either numerical stability of algorithms using inexact challenges numerical stability of algorithms using inexact arithmetic and
arithmetic or exact predicates to compute the sign of expressions exact predicates to compute the sign of expressions slightly off from zero.
slightly off from zero.
\ccFunction{template <class ForwardIterator> \ccFunction{template <class ForwardIterator>
void CGAL_perturbe_points_2( ForwardIterator first, ForwardIterator last, void CGAL_perturb_points_2( ForwardIterator first, ForwardIterator last,
double xeps, double yeps = xeps, CGAL_Random& rnd = CGAL_random);} double xeps, double yeps = xeps, CGAL_Random& rnd = CGAL_random);}
{ perturbes the points in the range $[\ccc{first},\ccc{last})$ by { perturbs the points in the range $[\ccc{first},\ccc{last})$ by
replacing each point with a random point from the rectangle replacing each point with a random point from the rectangle
\ccc{xeps} $\times$ \ccc{yeps} centered around the original point. \ccc{xeps} $\times$ \ccc{yeps} centered at the original point.
Two random numbers are needed from \ccc{rnd} for each point. Two random numbers are needed from \ccc{rnd} for each point.
\ccPrecond a function \ccc{CGAL_build_point()} for the value type of \ccPrecond a function \ccc{CGAL_build_point()} for the value type of
the \ccc{ForwardIterator}. the \ccc{ForwardIterator} exists.
The expression \ccc{CGAL_to_double((*first).x())} and The expressions \ccc{CGAL_to_double((*first).x())} and
\ccc{CGAL_to_double((*first).y())} must be legal. \ccc{CGAL_to_double((*first).y())} must result in the respective
coordinate values.
} }
\ccHeading{Adding Degeneracies} \ccHeading{Adding Degeneracies}
@ -250,17 +256,18 @@ a point set.
OutputIterator CGAL_random_collinear_points_2( RandomAccessIterator first, OutputIterator CGAL_random_collinear_points_2( RandomAccessIterator first,
RandomAccessIterator last, RandomAccessIterator last,
size_t n, OutputIterator first2, CGAL_Random& rnd = CGAL_random);} size_t n, OutputIterator first2, CGAL_Random& rnd = CGAL_random);}
{ choose two random points from the range $[\ccc{first},\ccc{last})$, { randomly chooses two points from the range $[\ccc{first},\ccc{last})$,
create a random third point on the segment connecting this two creates a random third point on the segment connecting this two
points, and write it to \ccc{first2}. Repeat this $n$ times, thus points, and writes it to \ccc{first2}. Repeats this $n$ times, thus
writing $n$ points to \ccc{first2} that are collinear with points writing $n$ points to \ccc{first2} that are collinear with points
in the range $[\ccc{first},\ccc{last})$. in the range $[\ccc{first},\ccc{last})$.
Three random numbers are needed from \ccc{rnd} for each point. Three random numbers are needed from \ccc{rnd} for each point.
Returns the value of \ccc{first2} after inserting the $n$ points. Returns the value of \ccc{first2} after inserting the $n$ points.
\ccPrecond a function \ccc{CGAL_build_point()} for the value type of \ccPrecond a function \ccc{CGAL_build_point()} for the value type of
the \ccc{ForwardIterator}. the \ccc{ForwardIterator} exists.
The expression \ccc{CGAL_to_double((*first).x())} and The expressions \ccc{CGAL_to_double((*first).x())} and
\ccc{CGAL_to_double((*first).y())} must be legal. \ccc{CGAL_to_double((*first).y())} must result in the respective
coordinate values.
} }
\ccExample \ccExample
@ -308,7 +315,7 @@ Figure~\ref{figurePointGenerator}}{Figure <A HREF="#PointGenerators">
\end{ccHtmlOnly} \end{ccHtmlOnly}
The second example demostrates the point generators with integer The second example demonstrates the point generators with integer
points. Arithmetic with \ccc{double}'s is sufficient to produce points. Arithmetic with \ccc{double}'s is sufficient to produce
regular integer grids. See \ccTexHtml{% regular integer grids. See \ccTexHtml{%
Figure~\ref{figureIntegerPointGenerator}}{Figure Figure~\ref{figureIntegerPointGenerator}}{Figure
@ -380,7 +387,7 @@ $g$ satisfies the requirements of an input iterator. Each call to the
We want to generate a test set of 200 segments, where one endpoint is We want to generate a test set of 200 segments, where one endpoint is
chosen randomly from a horizontal segment of length 200, and the other chosen randomly from a horizontal segment of length 200, and the other
endpoint is chosen ramdomly from a circle of radius 250. See endpoint is chosen randomly from a circle of radius 250. See
\ccTexHtml{Figure~\ref{figureSegmentGenerator}}{Figure <A \ccTexHtml{Figure~\ref{figureSegmentGenerator}}{Figure <A
HREF="#SegmentGenerator"> <IMG SRC="cc_ref_up_arrow.gif" HREF="#SegmentGenerator"> <IMG SRC="cc_ref_up_arrow.gif"
ALT="reference arrow" WIDTH="10" HEIGHT="10"></A>} for the example ALT="reference arrow" WIDTH="10" HEIGHT="10"></A>} for the example