1 #ifndef rsdl_dist_h_
2 #define rsdl_dist_h_
3 //:
4 // \file
5 // \brief Point to point and point to bounding box distance functions.
6 // \author Chuck Stewart
7 // \date June 2001
8 //
9 //  Distance functions for rsdl points and bounding boxes.  These
10 //  points and bounding boxes have a mixture of cartesian and angular
11 //  coordinates, so the computation is a little more complicated than
12 //  ordinary Euclidean distance calculations.  Angles are treated in
13 //  a full 2*pi range, so that the maximum distance between two angles
14 //  is pi.  Also, bounding intervals on angles can be such that the
15 //  numerical value on the "min" angle is greater than the numerical
16 //  value on the "max" angle.  These are values that wrap-around 0.
17 //
18 //  Two assumptions are important.  First, it is assumed that all
19 //  angles are truly within a 2*pi range; it doesn't matter which.
20 //  This is an implementation (and efficiency) convenience.  Second,
21 //  any normalization for comparing angle and cartesian distance
22 //  measures has already been done.
23 
24 
25 #include <rsdl/rsdl_point.h>
26 #include <rsdl/rsdl_bounding_box.h>
27 
28 //: Return the square distance between two rsdl_point's.
29 double
30 rsdl_dist_sq( const rsdl_point & p, const rsdl_point& q );
31 
32 //: Return the distance between two rsdl_point's.
33 double
34 rsdl_dist( const rsdl_point & p, const rsdl_point& q );
35 
36 //: Return the minimum square distance between \a p and any point in \a b.
37 double
38 rsdl_dist_sq( const rsdl_point & p, const rsdl_bounding_box& b );
39 
40 //: Return the minimum distance between \a p and any point in \a b.
41 double
42 rsdl_dist( const rsdl_point & p, const rsdl_bounding_box& b );
43 
44 //: Determine if a point is inside a bounding box.
45 bool
46 rsdl_dist_point_in_box( const rsdl_point & pt,
47                         const rsdl_bounding_box & box );
48 
49 
50 //: Determine the relation between a purported "inner" box and a purported "outer" box.
51 //  \a inside will be true iff all points in \a inner are in \a outer
52 //  \a intersect will be true iff at least one point from \a inner is in \a outer.
53 void
54 rsdl_dist_box_relation( const rsdl_bounding_box & inner,
55                         const rsdl_bounding_box & outer,
56                         bool& inside,
57                         bool& intersects );
58 
59 #endif
60