Main Page   Namespace List   Class Hierarchy   Compound List   File List   Header Files   Sources   Namespace Members   Compound Members   File Members  

curve.cpp File Reference

Contains the definition of the curve class. More...


Compounds

class  curve_distance2

Functions

void nearest_point ( const curve &cu, const vector2 &p, const double tol, const unsigned max_iter, double &t2, double &d22, unsigned &iter )
Find the point on a curve that is nearest to a given point. More...


Variables

const double pi


Detailed Description

Contains the definition of the curve class.

Author(s):
$Author: ben $
Version:
$Revision: 6.6 $
Date:
$Date: 2002/07/14 17:08:52 $

Definition in file curve.cpp.


Function Documentation

void nearest_point (const curve & cu, const vector2 & p, const double tol, const unsigned max_iter, double & t2, double & d22, unsigned & iter)

Find the point on a curve that is nearest to a given point.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Calculates the position on the curve (t on cu) which is closest to the given point (p). Also returns the square of the distance (d2) between the curve and that point. The calculation is done iteratively, so callers must provide iterations limits (tol and max_iter).

Parameters:
cu   the curve
p   the given point
tol   a dimensionless calculation tolerance
max_iter   the maximum number of iterations to perform
Return values:
t   the parameter indicating the position on the curve nearest to p
d2   the square of the distance from p to t
iter   the number of iterations performed

Preconditions:
 assert( 2 <= cu.param.size() );
 assert( 0.0 < tol );
 assert( 0 < max_iter );

Postconditions:
 assert( 0 <= t && t <= 1 );
 assert( iter <= max_iter );
 assert( 0 <= d2 );

Implementation:
This function finds the nearest point on the curve using a minimisation procedure. It uses an auxiliary function, curve_distance2, which gives the square of the distance between the given point (p) and a particular point on the curve, which is indicated by the argument, t, of the function. This argument is the parameter of the curve. The function uses the minimise::bracket() function to create a valid bracket of the minimum. Then it uses the minimise::Brent() function to minimise the function.

Definition at line 219 of file curve.cpp.


Variable Documentation

const double pi [static]

Definition at line 35 of file curve.cpp.


Generated at Sun Jul 14 20:38:04 2002 for Mapper by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999