Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

vgl_distance.h

Go to the documentation of this file.
00001 // This is core/vgl/vgl_distance.h
00002 #ifndef vgl_distance_h_
00003 #define vgl_distance_h_
00004 //:
00005 // \file
00006 // \brief Set of distance functions
00007 // \author fsm
00008 //
00009 // Note that these functions return double, not the template parameter Type,
00010 // since e.g. the distance between two vgl_point_2d<int> is not always an int,
00011 // but even the squared distance between such a point and a line is not integer.
00012 //
00013 // \verbatim
00014 //  Modifications
00015 //    2 July 2001 Peter Vanroose added vgl_distance(point,line) and (point,plane)
00016 //    2 July 2001 Peter Vanroose inlined 4 functions and made return types double
00017 //    2 Jan. 2003 Peter Vanroose corrected functions returning negative distance
00018 //    5 June 2003 Peter Vanroose added vgl_distance(line_3d,line_3d)
00019 //   11 June 2003 Peter Vanroose added vgl_distance(line_3d,point_3d)
00020 //   14 Nov. 2003 Peter Vanroose made all functions templated
00021 //   25 Sept 2004 Peter Vanroose added 3D vgl_distance_to_linesegment()
00022 //   25 Sept 2004 Peter Vanroose added 3D vgl_distance_to_*_polygon()
00023 // \endverbatim
00024 
00025 #include <vgl/vgl_fwd.h> // forward declare various vgl classes
00026 
00027 //: Squared distance between point \a (x,y) and closest point on line segment \a (x1,y1)-(x2,y2)
00028 template <class T>
00029 double vgl_distance2_to_linesegment(T x1, T y1,
00030                                     T x2, T y2,
00031                                     T x, T y);
00032 
00033 //: Distance between point \a (x,y) and closest point on line segment \a (x1,y1)-(x2,y2)
00034 template <class T>
00035 double vgl_distance_to_linesegment(T x1, T y1,
00036                                    T x2, T y2,
00037                                    T x, T y);
00038 
00039 //: Squared distance between point \a (x,y,z) and closest point on line segment \a (x1,y1,z1)-(x2,y2,z2)
00040 template <class T>
00041 double vgl_distance2_to_linesegment(T x1, T y1, T z1,
00042                                     T x2, T y2, T z2,
00043                                     T x,  T y,  T z);
00044 
00045 //: Distance between point \a (x,y,z) and closest point on line segment \a (x1,y1,z1)-(x2,y2,z2)
00046 template <class T>
00047 double vgl_distance_to_linesegment(T x1, T y1, T z1,
00048                                    T x2, T y2, T z2,
00049                                    T x,  T y,  T z);
00050 
00051 //: Distance between point \a (x,y) and closest point on open polygon \a (px[i],py[i])
00052 template <class T>
00053 double vgl_distance_to_non_closed_polygon(T const px[], T const py[], unsigned int n,
00054                                           T x, T y);
00055 
00056 //: Distance between point \a (x,y,z) and closest point on open polygon \a (px[i],py[i],pz[i])
00057 template <class T>
00058 double vgl_distance_to_non_closed_polygon(T const px[], T const py[], T const pz[], unsigned int n,
00059                                           T x, T y, T z);
00060 
00061 //: Distance between point \a (x,y) and closest point on closed polygon \a (px[i],py[i])
00062 template <class T>
00063 double vgl_distance_to_closed_polygon(T const px[], T const py[], unsigned int n,
00064                                       T x, T y);
00065 
00066 //: Distance between point \a (x,y,z) and closest point on closed polygon \a (px[i],py[i]),pz[i]
00067 template <class T>
00068 double vgl_distance_to_closed_polygon(T const px[], T const py[], T const pz[], unsigned int n,
00069                                       T x, T y, T z);
00070 
00071 //: find the shortest distance of the line to the origin
00072 // \relates vgl_line_2d
00073 template <class T>
00074 double vgl_distance_origin(vgl_line_2d<T> const& l);
00075 
00076 //: find the shortest distance of the plane to the origin
00077 // \relates vgl_plane_3d
00078 template <class T>
00079 double vgl_distance_origin(vgl_plane_3d<T> const& pl);
00080 
00081 //: find the shortest distance of the line to the origin
00082 // \relates vgl_line_3d_2_points
00083 template <class T>
00084 double vgl_distance_origin(vgl_line_3d_2_points<T> const& l);
00085 
00086 //: find the shortest distance of the line to the origin
00087 // \relates vgl_homg_line_2d
00088 template <class T>
00089 double vgl_distance_origin(vgl_homg_line_2d<T> const& l);
00090 
00091 //: find the shortest distance of the plane to the origin
00092 // \relates vgl_homg_plane_3d
00093 template <class T>
00094 double vgl_distance_origin(vgl_homg_plane_3d<T> const& pl);
00095 
00096 //: find the shortest distance of the line to the origin
00097 // \relates vgl_homg_line_3d_2_points
00098 template <class T>
00099 double vgl_distance_origin(vgl_homg_line_3d_2_points<T> const& l);
00100 
00101 //: return the distance between two points
00102 // \relates vgl_point_2d
00103 template <class T> inline
00104 double vgl_distance(vgl_point_2d<T>const& p1,
00105                     vgl_point_2d<T>const& p2) { return length(p2-p1); }
00106 
00107 //: return the distance between two points
00108 // \relates vgl_point_3d
00109 template <class T> inline
00110 double vgl_distance(vgl_point_3d<T>const& p1,
00111                     vgl_point_3d<T>const& p2) { return length(p2-p1); }
00112 
00113 //: return the distance between two points
00114 // \relates vgl_homg_point_1d
00115 template <class T>
00116 double vgl_distance(vgl_homg_point_1d<T>const& p1,
00117                     vgl_homg_point_1d<T>const& p2);
00118 
00119 //: return the distance between two points
00120 // \relates vgl_homg_point_2d
00121 template <class T> inline
00122 double vgl_distance(vgl_homg_point_2d<T>const& p1,
00123                     vgl_homg_point_2d<T>const& p2) { return length(p2-p1); }
00124 
00125 //: return the distance between two points
00126 // \relates vgl_homg_point_3d
00127 template <class T> inline
00128 double vgl_distance(vgl_homg_point_3d<T>const& p1,
00129                     vgl_homg_point_3d<T>const& p2) { return length(p2-p1); }
00130 
00131 //: return the perpendicular distance from a point to a line in 2D
00132 // \relates vgl_point_2d
00133 // \relates vgl_line_2d
00134 template <class T>
00135 double vgl_distance(vgl_line_2d<T> const& l,
00136                     vgl_point_2d<T> const& p);
00137 template <class T> inline
00138 double vgl_distance(vgl_point_2d<T> const& p,
00139                     vgl_line_2d<T> const& l) { return vgl_distance(l,p); }
00140 
00141 //: return the perpendicular distance from a point to a line in 2D
00142 // \relates vgl_homg_point_2d
00143 // \relates vgl_homg_line_2d
00144 template <class T>
00145 double vgl_distance(vgl_homg_line_2d<T> const& l,
00146                     vgl_homg_point_2d<T> const& p);
00147 template <class T> inline
00148 double vgl_distance(vgl_homg_point_2d<T> const& p,
00149                     vgl_homg_line_2d<T> const& l) { return vgl_distance(l,p); }
00150 
00151 //: return the perpendicular distance from a point to a plane in 3D
00152 // \relates vgl_point_3d
00153 // \relates vgl_plane_3d
00154 template <class T>
00155 double vgl_distance(vgl_plane_3d<T> const& l,
00156                     vgl_point_3d<T> const& p);
00157 template <class T> inline
00158 double vgl_distance(vgl_point_3d<T> const& p,
00159                     vgl_plane_3d<T> const& l) { return vgl_distance(l,p); }
00160 
00161 //: return the perpendicular distance from a point to a plane in 3D
00162 // \relates vgl_homg_point_3d
00163 // \relates vgl_homg_plane_3d
00164 template <class T>
00165 double vgl_distance(vgl_homg_plane_3d<T> const& l,
00166                     vgl_homg_point_3d<T> const& p);
00167 template <class T> inline
00168 double vgl_distance(vgl_homg_point_3d<T> const& p,
00169                     vgl_homg_plane_3d<T> const& l) { return vgl_distance(l,p); }
00170 
00171 //: distance between a point and the closest point on the polygon.
00172 //  If the third argument is "false", the edge from last to first point of
00173 //  each polygon sheet is not considered part of the polygon.
00174 // \relates vgl_point_2d
00175 // \relates vgl_polygon
00176 template <class T>
00177 double vgl_distance(vgl_polygon<T> const& poly,
00178                     vgl_point_2d<T> const& point,
00179                     bool closed=true);
00180 
00181 template <class T> inline
00182 double vgl_distance(vgl_point_2d<T> const& point,
00183                     vgl_polygon<T> const& poly,
00184                     bool closed=true) { return vgl_distance(poly,point,closed); }
00185 
00186 //: Return the perpendicular distance between two lines in 3D.
00187 //  See vgl_closest_point.h for more information.
00188 
00189 template <class T>
00190 double vgl_distance(vgl_homg_line_3d_2_points<T> const& line1,
00191                     vgl_homg_line_3d_2_points<T> const& line2);
00192 
00193 template <class T>
00194 double vgl_distance(vgl_homg_line_3d_2_points<T> const& l,
00195                     vgl_homg_point_3d<T> const& p);
00196 
00197 template <class T> inline
00198 double vgl_distance(vgl_homg_point_3d<T> const& p,
00199                     vgl_homg_line_3d_2_points<T> const& l) { return vgl_distance(l,p); }
00200 
00201 template <class T>
00202 double vgl_distance(vgl_line_3d_2_points<T> const& l,
00203                     vgl_point_3d<T> const& p);
00204 
00205 template <class T> inline
00206 double vgl_distance(vgl_point_3d<T> const& p,
00207                     vgl_line_3d_2_points<T> const& l) { return vgl_distance(l,p); }
00208 
00209 
00210 //: Closest distance from a point \a p to a line segment \a l in 2D
00211 // \relates vgl_point_2d
00212 // \relates vgl_line_segment_2d
00213 // \sa vgl_distance_to_linesegment()
00214 // \sa vgl_distance2_to_linesegment()
00215 template <class T>
00216 double vgl_distance(vgl_line_segment_2d<T> const& l,
00217                     vgl_point_2d<T> const& p);
00218 template <class T> inline
00219 double vgl_distance(vgl_point_2d<T> const& p,
00220                     vgl_line_segment_2d<T> const& l) { return vgl_distance(l,p); }
00221 
00222 
00223 //: Closest distance from a point \a p to a line segment \a l in 3D
00224 // \relates vgl_point_3d
00225 // \relates vgl_line_segment_3d
00226 // \sa vgl_distance_to_linesegment()
00227 // \sa vgl_distance2_to_linesegment()
00228 template <class T>
00229 double vgl_distance(vgl_line_segment_3d<T> const& l,
00230                     vgl_point_3d<T> const& p);
00231 template <class T> inline
00232 double vgl_distance(vgl_point_3d<T> const& p,
00233                     vgl_line_segment_3d<T> const& l) { return vgl_distance(l,p); }
00234 
00235 
00236 #endif // vgl_distance_h_

Generated on Thu Jan 10 14:39:24 2008 for core/vgl by  doxygen 1.4.4