00001 /*---------------------------------------------------------------------+ 00002 | Library QgarLib, graphics analysis and recognition | 00003 | Copyright (C) 2002 Qgar Project, LORIA | 00004 | | 00005 | This library is free software; you can redistribute it and/or | 00006 | modify it under the terms of the GNU Lesser General Public | 00007 | License version 2.1, as published by the Free Software Foundation. | 00008 | | 00009 | This library is distributed in the hope that it will be useful, | 00010 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00011 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 00012 | See the GNU Lesser General Public License for more details. | 00013 | | 00014 | The GNU Lesser General Public License is included in the file | 00015 | LICENSE.LGPL, in the root directory of the Qgar packaging. See | 00016 | http://www.gnu.org/licenses/lgpl.html for the terms of the licence. | 00017 | To receive a paper copy, write to the Free Software Foundation, | 00018 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. | 00019 | | 00020 | Contact Project Qgar for any information: | 00021 | LORIA - équipe Qgar | 00022 | B.P. 239, 54506 Vandoeuvre-lès-Nancy Cedex, France | 00023 | email: qgar-contact@loria.fr | 00024 | http://www.qgar.org/ | 00025 *---------------------------------------------------------------------*/ 00026 00027 00028 #ifndef ___QGAR_DISTANCE_H_INCLUDED__ 00029 #define ___QGAR_DISTANCE_H_INCLUDED__ 00030 00031 00032 /** 00033 * @file _QGAR_distance.H 00034 * @brief Global functions to compute distances between primitives. 00035 * 00036 * @warning <b>Not to be used as include file!</b> 00037 * <br>When working with primitives, use header file primitives.H. 00038 * 00039 * @author <a href="mailto:qgar-develop@loria.fr?subject=Qgar fwd Gérald Masini">Gérald Masini</a> 00040 * @date February 03 2005, 17:44 00041 * @since Qgar 2.2 00042 */ 00043 00044 00045 // For RCS/CVS use: Do not delete 00046 /* $Id: _QGAR_distance.H,v 1.2 2005/09/14 10:53:19 masini Exp $ */ 00047 00048 00049 00050 namespace qgar 00051 { 00052 00053 00054 /*-------------------------------------------------------------------* 00055 | | 00056 | GLOBAL FUNCTIONS TO COMPUTE DISTANCES BETWEEN PRIMITIVES | 00057 | | 00058 *-------------------------------------------------------------------*/ 00059 00060 00061 /** 00062 * @name Global functions to compute distances between primitives 00063 */ 00064 //@{ 00065 00066 00067 /** 00068 * @ingroup GLOB_PRIM_DIST 00069 * 00070 * @brief Difference between X coordinates of the given points: 00071 * <b>X(aPt1) - X(aPt2)</b>. 00072 * 00073 * @param aPt1 a point 00074 * @param aPt2 a point 00075 */ 00076 template <class T> 00077 inline T 00078 qgDX(const GenPoint<T>& aPt1, const GenPoint<T>& aPt2); 00079 00080 00081 /** 00082 * @ingroup GLOB_PRIM_DIST 00083 * 00084 * @brief Difference between Y coordinates of the given points: 00085 * <b>Y(aPt1) - Y(aPt2)</b>. 00086 * 00087 * @param aPt1 a point 00088 * @param aPt2 a point 00089 */ 00090 template <class T> 00091 inline T 00092 qgDY(const GenPoint<T>& aPt1, const GenPoint<T>& aPt2); 00093 00094 00095 /** 00096 * @ingroup GLOB_PRIM_DIST 00097 * 00098 * @brief Distance between two points. 00099 * 00100 * @param aPt1 a point 00101 * @param aPt2 a point 00102 */ 00103 template <class T> 00104 double 00105 qgDist(const GenPoint<T>& aPt1, const GenPoint<T>& aPt2); 00106 00107 00108 /** 00109 * @ingroup GLOB_PRIM_DIST 00110 * 00111 * @brief Distance between point <b>c</b> and its a perpendicular 00112 * projection onto the line passing through points 00113 * <b>a</b> and <b>b</b>. 00114 * 00115 * @param c a point 00116 * @param a a point 00117 * @param b a point 00118 */ 00119 template <class T> 00120 double 00121 qgDist(const GenPoint<T>& c, 00122 const GenPoint<T>& a, 00123 const GenPoint<T>& b); 00124 00125 00126 /** 00127 * @ingroup GLOB_PRIM_DIST 00128 * 00129 * @brief Distance between point <b>(0,0)</b> and its perpendicular 00130 * projection onto the line supporting a segment. 00131 * 00132 * Always positive. 00133 * 00134 * @param aSeg a segment 00135 */ 00136 template <class T> 00137 inline double 00138 qgDist(const GenSegment<T>& aSeg); 00139 00140 00141 /** 00142 * @ingroup GLOB_PRIM_DIST 00143 * 00144 * @brief Distance between point <b>(0,0)</b> and its perpendicular 00145 * projection onto the line supporting a Qgar segment. 00146 * 00147 * Always positive. 00148 * 00149 * @param aQSeg a Qgar segment 00150 */ 00151 template <class T> 00152 inline double 00153 qgDist(const GenQgarSegment<T>& aQSeg); 00154 00155 00156 /** 00157 * @ingroup GLOB_PRIM_DIST 00158 * 00159 * @brief Distance between a point and its perpendicular 00160 * projection onto the line supporting a segment. 00161 * 00162 * Always positive. 00163 * 00164 * @param aPt a point 00165 * @param aSeg a segment 00166 */ 00167 template <class T> 00168 inline double 00169 qgDist(const GenPoint<T>& aPt, const GenSegment<T>& aSeg); 00170 00171 00172 /** 00173 * @ingroup GLOB_PRIM_DIST 00174 * 00175 * @brief Distance between a point and its perpendicular 00176 * projection onto the line supporting a Qgar segment. 00177 * 00178 * Always positive. 00179 * 00180 * @param c a point 00181 * @param aQSeg a Qgar segment 00182 */ 00183 template <class T> 00184 inline double 00185 qgDist(const GenPoint<T>& c, const GenQgarSegment<T>& aQSeg); 00186 00187 00188 /** 00189 * @ingroup GLOB_PRIM_DIST 00190 * 00191 * @brief Squared distance between two points. 00192 * 00193 * @param aPt1 a point 00194 * @param aPt2 a point 00195 */ 00196 template <class T> 00197 double 00198 qgSqr_dist(const GenPoint<T>& aPt1, const GenPoint<T>& aPt2); 00199 00200 00201 //@} 00202 00203 00204 /*-------------------------------------------------------------------* 00205 | | 00206 *-------------------------------------------------------------------*/ 00207 00208 00209 } // namespace qgar 00210 00211 00212 #endif /* ___QGAR_DISTANCE_H_INCLUDED__ */