curve class.
More...
Compounds | |||
![]() | ![]() | class | curve |
Functions | |||
![]() | ![]() | void | nearest_point ( const curve &cu, const vector2 &p, const double tol, const unsigned max_iter, double &t, double &d2, unsigned &iter ) |
![]() | ![]() | Find the point on a curve that is nearest to a given point. More... | |
curve class.
Definition in file curve.h.
| 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).
| cu | the curve |
| p | the given point |
| tol | a dimensionless calculation tolerance |
| max_iter | the maximum number of iterations to perform |
| 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
|
assert( 2 <= cu.param.size() ); assert( 0.0 < tol ); assert( 0 < max_iter );
assert( 0 <= t && t <= 1 ); assert( iter <= max_iter ); assert( 0 <= d2 );
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.
1.0.0 written by Dimitri van Heesch,
© 1997-1999