hexed 0.3.0
 
Loading...
Searching...
No Matches
hexed::Nearest_point< n_dim > Class Template Reference

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.
 

Detailed Description

template<int n_dim = dyn>
class hexed::Nearest_point< n_dim >

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.

Constructor & Destructor Documentation

◆ Nearest_point() [1/2]

template<int n_dim = dyn>
hexed::Nearest_point< n_dim >::Nearest_point ( Mat< n_dim > ref,
double max_distance = huge )
inline

Initializes an empty point.

This point is considered "empty" and point() won't work until merge()ed with a non-empty Nearest_point.

Parameters
refSets reference()
max_distanceOptionally initialize the distance to a finite value so that only points within this distance will be considered.

◆ Nearest_point() [2/2]

template<int n_dim = dyn>
hexed::Nearest_point< n_dim >::Nearest_point ( Mat< n_dim > ref,
Mat< n_dim > pnt )
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().

Member Function Documentation

◆ point()

template<int n_dim = dyn>
Mat< n_dim > hexed::Nearest_point< n_dim >::point ( ) const
inline

Current best estimate for nearest point.

Throws an exception if empty().


The documentation for this class was generated from the following file: