Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
frechet::numeric Namespace Reference

Detailed Description

definitions and functions for optimal numerical precision.

The functions in namespace frechet::numeric are meant to be used transparently with different floating point types.

In particular, the template functions can be used with 'double' precision, with 'long double' precision, and even with 'quad' precision (though quad types are currently not used).

Functions

template<typename Number >
Number sq (const Number &x)
 square function template for arbitrary number types More...
 
template<typename Float >
Float sqrt (const Float &x)
 square-root function template for floating point types More...
 
template<>
double sqrt (const double &x)
 default sqrt() specialisation using the run-time libraries More...
 
template<>
long double sqrt (const long double &x)
 sqrt() specialisation for "long double" More...
 
template<typename Number >
Number abs (const Number &x)
 abs() function template for arbitrary numerical types More...
 
double round_up (double x, int ulps=1)
 rounding function with 'units in the last place' Roughly speaking, a ulp is the smallest representable floating point value. More...
 
template<typename Float >
Float euclidean_distance_sq (const Float &px, const Float &py, const Float &qx, const Float &qy)
 euclidean distance function template for arbitrary floating point types More...
 
template<typename Float >
Float euclidean_distance (const Float &px, const Float &py, const Float &qx, const Float &qy)
 euclidean distance function template for arbitrary floating point types More...
 
template<typename Float >
Float euclidean_distance (const Point &p, const Point &q)
 euclidean distance function template for arbitrary floating point types More...
 
template<typename Float >
Float euclidean_distance_sq (const Point &p, const Point &q)
 euclidean distance function template for arbitrary floating point types More...
 
template<typename Float >
Float euclidean_segment_distance (const Float &ax, const Float &ay, const Float &bx, const Float &by, const Float &px, const Float &py)
 Euclidean Distance between a point and a segment; function template for arbitrary floating point types. More...
 
template<typename Float >
Float euclidean_segment_distance (const QLineF &s, const Point &p)
 Euclidean Distance between a point and a segment; function template for arbitrary floating point types. More...
 
double min (double a, double b)
 minimum function with checks for NAN More...
 
double max (double a, double b)
 maximum function with checks for NAN More...
 
int lower_floor (double x, int min=0)
 floor function with lower limit More...
 
int compare (double a, double b)
 comparator function More...
 
Point normalized (Point p)
 normalize a vector to unit length More...
 
Point intersection (Point p1, Point p2, Point p3, Point p4)
 compute the intersection of two lines More...
 
Point between (Point p, Point q, double w)
 compute a point on a line segment More...
 
double segment_length (const Curve &c, int i)
 compute the length of a polygon segment More...
 
double max_euclidean_distance (const Curve &P, const Curve &Q)
 compute the maximum distance between two polygons This value serves as an upper bound for the Frechet Distance between polyongs. More...
 

Variables

static const constexpr double double_eps = std::numeric_limits<double>::epsilon()
 smallest double value More...
 

Function Documentation

◆ abs()

template<typename Number >
Number frechet::numeric::abs ( const Number &  x)
inline

abs() function template for arbitrary numerical types

Parameters
xa number
Template Parameters
Numbera number type (like int,double,long double,...)
Returns
abs(x)

Definition at line 91 of file numeric.h.

◆ between()

Point frechet::numeric::between ( Point  p,
Point  q,
double  w 
)
inline

compute a point on a line segment

Parameters
pan endppoint of a line segment
qthe second endppoint of the line segment
wdistance from p (w in [0,1])
Returns
the point on the line segment given by the distance w. Returns p, if w==0. Return q, if w==1. Returns a point between p and q, if 0 < w < 1.

Definition at line 295 of file numeric.h.

◆ compare()

int frechet::numeric::compare ( double  a,
double  b 
)
inline

comparator function

Parameters
aa number
ba number
Returns
+1 if (a>b); -1 if (a<b); 0 if (a==b)

Definition at line 254 of file numeric.h.

◆ euclidean_distance() [1/2]

template<typename Float >
Float frechet::numeric::euclidean_distance ( const Float &  px,
const Float &  py,
const Float &  qx,
const Float &  qy 
)
inline

euclidean distance function template for arbitrary floating point types

Parameters
pxx-coordinate of first point
pyy-coordinate of first point
qxx-coordinate of second point
qyy-coordinate of second point
Template Parameters
Floata floating point type (float,double,long double,...)
Returns
the euclidean distance between p and q

Definition at line 143 of file numeric.h.

◆ euclidean_distance() [2/2]

template<typename Float >
Float frechet::numeric::euclidean_distance ( const Point p,
const Point q 
)
inline

euclidean distance function template for arbitrary floating point types

Parameters
pthe first point
qthe second point
Template Parameters
Floata floating point type (float,double,long double,...)
Returns
the euclidean distance between p and q

Definition at line 158 of file numeric.h.

◆ euclidean_distance_sq() [1/2]

template<typename Float >
Float frechet::numeric::euclidean_distance_sq ( const Float &  px,
const Float &  py,
const Float &  qx,
const Float &  qy 
)
inline

euclidean distance function template for arbitrary floating point types

Parameters
pxx-coordinate of first point
pyy-coordinate of first point
qxx-coordinate of second point
qyy-coordinate of second point
Template Parameters
Floata floating point type (float,double,long double,...)
Returns
the square of the euclidean distance

Definition at line 126 of file numeric.h.

◆ euclidean_distance_sq() [2/2]

template<typename Float >
Float frechet::numeric::euclidean_distance_sq ( const Point p,
const Point q 
)
inline

euclidean distance function template for arbitrary floating point types

Parameters
pthe first point
qthe second point
Template Parameters
Floata floating point type (float,double,long double,...)
Returns
the squared euclidean distance between p and q

Definition at line 171 of file numeric.h.

◆ euclidean_segment_distance() [1/2]

template<typename Float >
Float frechet::numeric::euclidean_segment_distance ( const Float &  ax,
const Float &  ay,
const Float &  bx,
const Float &  by,
const Float &  px,
const Float &  py 
)
inline

Euclidean Distance between a point and a segment; function template for arbitrary floating point types.

Parameters
axan endpoint of a line segment
ayan endpoint of a line segment
bxthe second endpoint of a line segment
bythe second endpoint of a line segment
pxa point
pya point
Template Parameters
Floata floating point type (float,double,long double,...)
Returns
the euclidean distance between p and the segment [ab]

Definition at line 189 of file numeric.h.

◆ euclidean_segment_distance() [2/2]

template<typename Float >
Float frechet::numeric::euclidean_segment_distance ( const QLineF &  s,
const Point p 
)
inline

Euclidean Distance between a point and a segment; function template for arbitrary floating point types.

Parameters
sa line segment
pa point
Template Parameters
Floata floating point type (float,double,long double,...)
Returns
the euclidean distance between p and the segment

Definition at line 208 of file numeric.h.

◆ intersection()

Point frechet::numeric::intersection ( Point  p1,
Point  p2,
Point  p3,
Point  p4 
)
inline

compute the intersection of two lines

Parameters
p1a point on the first line
p2another point of the first line
p3a point on the second line
p4another point of the second line
Returns
the intersection of both lines, or NAN if they do not intersect

Definition at line 278 of file numeric.h.

◆ lower_floor()

int frechet::numeric::lower_floor ( double  x,
int  min = 0 
)
inline

floor function with lower limit

Parameters
xa number
minthe minimum return value
Returns
the largest integer properly smaller than x and >= min

Definition at line 243 of file numeric.h.

◆ max()

double frechet::numeric::max ( double  a,
double  b 
)
inline

maximum function with checks for NAN

Parameters
aa floating point value, may be NAN
ba floating point value, may be NAN
Returns
the maximum of a and b

Definition at line 233 of file numeric.h.

◆ max_euclidean_distance()

double frechet::numeric::max_euclidean_distance ( const Curve P,
const Curve Q 
)
inline

compute the maximum distance between two polygons This value serves as an upper bound for the Frechet Distance between polyongs.

Parameters
Pa polygon
Qanother polygon
Returns
maximum distance between two vertexes of the polygons

Definition at line 318 of file numeric.h.

◆ min()

double frechet::numeric::min ( double  a,
double  b 
)
inline

minimum function with checks for NAN

Parameters
aa floating point value, may be NAN
ba floating point value, may be NAN
Returns
the minimum of a and b

Definition at line 222 of file numeric.h.

◆ normalized()

Point frechet::numeric::normalized ( Point  p)
inline

normalize a vector to unit length

Parameters
pa point
Returns
vector scaled to unit length

Definition at line 265 of file numeric.h.

◆ round_up()

double frechet::numeric::round_up ( double  x,
int  ulps = 1 
)
inline

rounding function with 'units in the last place' Roughly speaking, a ulp is the smallest representable floating point value.

Parameters
xa value to be rounded
ulpsnumber of units in the last place to round up
Returns
x rounded upwards by ulps

Definition at line 112 of file numeric.h.

◆ segment_length()

double frechet::numeric::segment_length ( const Curve c,
int  i 
)
inline

compute the length of a polygon segment

Parameters
ca polygon
iindex of segment
Returns
euclidean length of the i-th polygon segment

Definition at line 306 of file numeric.h.

◆ sq()

template<typename Number >
Number frechet::numeric::sq ( const Number &  x)
inline

square function template for arbitrary number types

Parameters
xa number
Template Parameters
Numbera number type (like int,double,long double,...)
Returns
x*x

Definition at line 61 of file numeric.h.

◆ sqrt() [1/3]

template<typename Float >
Float frechet::numeric::sqrt ( const Float &  x)
inline

square-root function template for floating point types

Parameters
xa number
Template Parameters
Floata floating point type (like double,long double,...)
Returns
sqrt(x)

◆ sqrt() [2/3]

template<>
double frechet::numeric::sqrt ( const double &  x)
inline

default sqrt() specialisation using the run-time libraries

Definition at line 76 of file numeric.h.

◆ sqrt() [3/3]

template<>
long double frechet::numeric::sqrt ( const long double &  x)
inline

sqrt() specialisation for "long double"

Definition at line 82 of file numeric.h.

Variable Documentation

◆ double_eps

const constexpr double frechet::numeric::double_eps = std::numeric_limits<double>::epsilon()
static

smallest double value

Definition at line 52 of file numeric.h.