Helper class for finding the nearest point to a given reference point. More...
#include <Nearest_point.hpp>
Public Member Functions | |
Nearest_point (Mat< n_dim > ref, double max_distance=huge) | |
Initializes an empty point. | |
Nearest_point (Mat< n_dim > ref, Mat< n_dim > pnt) | |
Creates a Nearest_point with a specified candidate point and computes the correct distance. | |
template<int m_dim> | |
Nearest_point (const Nearest_point< m_dim > &other) | |
simple copy constructor that just converts the matrices | |
Mat< n_dim > | reference () const |
reference point that you want to find the nearest point to | |
double | dist_squared () const |
squared distance between reference() and point() | |
bool | empty () const |
if true , point() won't work | |
void | merge (Nearest_point other) |
sets *this to the nearest of *this and other | |
void | merge (Mat< n_dim > new_pnt) |
updates *this to point to new_pnt if new_pnt is closer | |
Mat< n_dim > | point () const |
Current best estimate for nearest point. | |
Helper class for finding the nearest point to a given reference point.
Implementations of Surface_geom::nearest_point
often involve searching a set of candidate points to find the one that is nearest to the input point. This class abstracts the logic of comparing the distances and updating the current nearest point to make those implementations more concise.
|
inline |
Initializes an empty point.
This point is considered "empty" and point()
won't work until merge()
ed with a non-empty Nearest_point
.
ref | Sets reference() |
max_distance | Optionally initialize the distance to a finite value so that only points within this distance will be considered. |
|
inline |
Creates a Nearest_point
with a specified candidate point and computes the correct distance.
This point is non-empty and has a well-defined point()
.
|
inline |
Current best estimate for nearest point.
Throws an exception if empty()
.