LTI-Lib latest version v1.9 - last update 10 Apr 2010

ltiLine.h

00001 /*
00002  * Copyright (C) 2003, 2004, 2005, 2006
00003  * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany
00004  * 
00005  * This file is part of the LTI-Computer Vision Library (LTI-Lib)
00006  *
00007  * The LTI-Lib is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public License (LGPL)
00009  * as published by the Free Software Foundation; either version 2.1 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * The LTI-Lib is distributed in the hope that it will be
00013  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
00014  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public 
00018  * License along with the LTI-Lib; see the file LICENSE.  If
00019  * not, write to the Free Software Foundation, Inc., 59 Temple Place -
00020  * Suite 330, Boston, MA 02111-1307, USA.  
00021  */ 
00022 
00023  
00024 /*----------------------------------------------------------------
00025  * project ....: LTI Digital Image/Signal Processing Library
00026  * file .......: ltiLine.h
00027  * authors ....: Claudia Goenner
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 07.02.2003
00030  * revisions ..: $Id: ltiLine.h,v 1.7 2006/02/08 12:30:01 ltilib Exp $
00031  */
00032 
00033 #ifndef LTI_LINE_H
00034 #define LTI_LINE_H
00035 
00036 #include "ltiConfig.h"
00037 
00038 #include <iostream>
00039 #include <limits>
00040 
00041 #include "ltiIoHandler.h"
00042 #include "ltiMath.h"
00043 #include "ltiPoint.h"
00044 #include "ltiRectangle.h"
00045 
00046 namespace lti {
00047 
00048 
00049   /**
00050    * Type for computations with lines.
00051    *
00052    * A line (or more generally a tline<T>) is represented by a start point
00053    * and an end point.
00054    *
00055    * The type T correspond to the coordinate type used in both points.
00056    *
00057    * This class stores only the two points, and provides some functionality
00058    * using them.  Other operations can be achieved more efficiently if more
00059    * information about the line, like its slope, is also stored.  This is 
00060    * done by some derived classes.
00061    *
00062    * @ingroup gGeomData
00063    */
00064   template <class T>
00065   class tline {
00066   protected:
00067     /**
00068      * start point
00069      */
00070     tpoint<T> start;
00071     
00072     /**
00073      * end point
00074      */
00075     tpoint<T> end;
00076 
00077   public:
00078     /**
00079      * default constructor.
00080      *
00081      * Both points are left uninitialized (this can save some time)
00082      */
00083     explicit tline();
00084     
00085     /**
00086      * constructor with both points
00087      */
00088     tline(const tpoint<T>& theStart, const tpoint<T>& theEnd);
00089     
00090     /**
00091      * copy constructor
00092      */
00093     template <class U> 
00094     tline(const tline<U>& other) 
00095       : start(castFrom(other.start)),end(castFrom(other.end)) {
00096     };
00097 
00098     /**
00099      * cast operator
00100      */
00101     template <class U>
00102     tline<T>& castFrom(const tline<U>& other) {
00103       start.castFrom(other.start);
00104       end.castFrom(other.end);
00105       return (*this);
00106     };
00107 
00108     /**
00109      * general operator to set both points of the line
00110      */
00111     inline void set(const tpoint<T>& theStart,const tpoint<T>& theEnd);
00112 
00113     /**
00114      * set the start point. 
00115      */
00116     inline void setStart(const tpoint<T>& theStart);
00117 
00118     /**
00119      * set the end point. Does not compute the slope.
00120      */
00121     inline void setEnd(const tpoint<T>& theEnd);
00122 
00123     /**
00124      * exchange the start and end points, making the previous end a
00125      * start point and the previous start the end point.
00126      */
00127     inline void invert();
00128     
00129     /**
00130      * return a read only reference to the start point
00131      */
00132     inline const tpoint<T>& getStart() const;
00133 
00134     /**
00135      * return a read only reference to the end point
00136      */
00137     inline const tpoint<T>& getEnd() const;
00138 
00139     /**
00140      * @name Distance computation
00141      */
00142     //@{
00143     /**
00144      * calculate minimal euclidian distance of the line segment to the point c.
00145      *
00146      * This method is slower than the sqrDistanceTo, which avoids the
00147      * computation of a (in many cases not required) square root.
00148      *
00149      * @see sqrDistanceTo() distanceToXPol()
00150      */
00151     inline T distanceTo(const tpoint<T>& c) const;
00152 
00153     /**
00154      * Calculate minimal %square of euclidian distance to the point c. This
00155      * method is faster than distanceTo (because it does not calculate
00156      * the square root).
00157      *
00158      * @param c point to which the minimal distance is searched.
00159      * @return the square of the minimal distance to c
00160      */
00161     inline T distanceSqr(const tpoint<T>& c) const;
00162 
00163     /**
00164      * Calculate minimal %square of euclidian distance to the point c. This
00165      * method is faster than distanceTo (because it does not calculate
00166      * the square root).
00167      *
00168      * @param c point to which the minimal distance is searched.
00169      * @param p point in the line segment with the minimal distance to c.
00170      *
00171      * @return the square of the minimal distance to c
00172      */
00173     T distanceSqr(const tpoint<T>& c,tpoint<T>& p) const;
00174 
00175     /**
00176      * Calculate distance to the point c to the infinite line (eXtraPolated)
00177      * containing this line segment.
00178      *
00179      * @return the minimal distance to c
00180      */
00181     inline T distanceToXPol(const tpoint<T>& c) const;
00182 
00183     /**
00184      * Calculate %square of distance to the point c to the infinite
00185      * line (eXtraPolated) containing this line segment.
00186      *
00187      * @param c point to which the minimal distance is searched.
00188      *
00189      * @return the square of the minimal distance to c
00190      * @see sqrDistanceTo()
00191      *
00192      * This method is faster than distanceToXPol (because it does not
00193      * calculate the square root).
00194      */
00195     inline T distanceSqrXPol(const tpoint<T>& c) const;
00196 
00197     /**
00198      * Calculate %square of distance to the point c to the infinite
00199      * line (eXtraPolated) containing this line segment.
00200      *
00201      * @param c point to which the minimal distance is searched.
00202      * @param p point in the extrapolated line segment with the
00203      *          minimal distance to c.
00204      *
00205      * This method is faster than distanceToXPol (because it does not
00206      * calculate the square root).
00207      *
00208      *
00209      * @see sqrDistanceTo()
00210      */
00211     T distanceSqrXPol(const tpoint<T>& c,tpoint<T>& p) const;
00212 
00213     /** 
00214      * square of the length of this line
00215      */
00216     inline T sqrLength() const;
00217     //@}
00218   
00219     /**
00220      * @name Intersections
00221      */
00222     //@{ 
00223 
00224     /**
00225      * Check if this line segment intersects the \a other given one.
00226      *
00227      * @param other the other line segment to which an intersection is
00228      *              going to be checked.
00229      * @return true if both line segments intersect.
00230      */
00231     bool doesIntersect(const tline<T>& other) const;
00232 
00233     /**
00234      * Check if this line segment is parallel to the \a other given one.
00235      *
00236      * @param other the other line segment to which parallelism is
00237      *              going to be checked.
00238      * @return true if both line segments are parallel.
00239      */
00240     bool isParallel(const tline<T>& other) const;  
00241 
00242     /**
00243      * Check if this line segment is parallel and colinear to the
00244      * \a other given one.
00245      *
00246      * @param other the other line segment to which parallelism is
00247      *              going to be checked.
00248      * @return true if both line segments are parallel.
00249      */
00250     bool isColinear(const tline<T>& other) const;    
00251 
00252     /**
00253      * Compute the part of this line segment which lies within the
00254      * given rectangle, and leave the result here.
00255      *
00256      * This method assumes, the rectangle is already consistent, i.e.
00257      * the \a rect.ul point is in both coordinates smaller than \a rect.br.
00258      *
00259      * @return true if part of this line lies within the rectangle or its
00260      *              border, false otherwise.
00261      */
00262     bool intersect(const trectangle<T>& rect);
00263 
00264     /**
00265      * Compute the part of the \a other line segment which lies within the
00266      * given rectangle, and leave the result here.
00267      *
00268      * This method assumes, the rectangle is already consistent, i.e.
00269      * the \a rect.ul point is in both coordinates smaller than \a rect.br.
00270      *
00271      * @return true if part of this line lies within the rectangle or its
00272      *              border, false otherwise.
00273      */
00274     inline bool intersect(const tline<T>& other,
00275         const trectangle<T>& rect);
00276 
00277     /**
00278      * Compute the intersection point of this line segment with the 
00279      * \a other given one.
00280      *
00281      * @param other the other line segment to which the intersection point
00282      *              is going to be computed.
00283      * @param p     if there is an intersection between both line segments
00284      *              the intersection point will be written here.
00285      * @param colinear this parameter is set to true in case both line segments
00286      *              are parallel and co-linear.
00287      *
00288      * @return true if an unique intersection point exists. It returns 
00289      *              \c false otherwise. If both line segments are parallel and
00290      *              colinear, this method returns \c true and determines the
00291      *              intersection if the intersection is inifinitely small.
00292      *
00293      * This method can be overloaded in derived classes and other information
00294      * to accellerate the computations.
00295      */
00296     template<class U>
00297     bool getIntersectionPoint(const tline<T>& other, tpoint<U>& p,
00298             bool& colinear ) const
00299     {
00300       // due to the template argument tpoint<U>, this method must be here
00301       // otherwise MS Visual C++ won't compile this file!
00302       colinear = false;
00303     
00304       // NOTE:
00305       // This method requires following time constants: (out of date -> ToDo)
00306       // Additions/LogicOp : 13
00307       // Multiplications   : 8 
00308       // Divisions         : 2    
00309       // Comparisons       : 6~   
00310       
00311       const tpoint<T> d1(end-start);
00312       const tpoint<T> d2(other.end-other.start);
00313       const tpoint<T> d0(other.start-start);
00314       
00315       // determinant
00316       const T det = d1.y*d2.x - d1.x*d2.y;
00317       
00318       // auxiliar variables containing information of the intersection point
00319       const T t1 = d2.x*d0.y - d2.y*d0.x;
00320       const T t2 = d1.x*d0.y - d1.y*d0.x;
00321  
00322       // just one copy for the whole history of this class (faster!)
00323       static const T epsilon = std::numeric_limits<T>::epsilon();
00324       
00325       // the numerical tolerance for parallelism is limited by epsilon.
00326       if (det > epsilon) {
00327   //check overlap
00328   if ( (t1 < 0) || (det < t1) || (t2 < 0) || (det < t2) )
00329     return false;
00330   
00331   // compute the intersection point
00332   const double f = static_cast<double>(t1)/static_cast<double>(det);
00333   condRoundCastTo(start.x + f*d1.x, p.x );
00334   condRoundCastTo(start.y + f*d1.y, p.y );
00335   return true;
00336   
00337       } else if (det < -epsilon) {
00338   if ( (t1 > 0) || (det > t1) || (t2 > 0) || (det > t2) )
00339     return false;
00340   
00341   // compute the intersection point
00342   const double f = static_cast<double>(t1)/static_cast<double>(det);
00343   condRoundCastTo(start.x + f*d1.x,p.x );
00344   condRoundCastTo(start.y + f*d1.y,p.y );
00345   return true;
00346   
00347       } else {
00348   // lines are parallel, we just need to check, if the distance between
00349   // them is zero (in which case they may overlap in more than one point)
00350   colinear   = (abs(t1) <= epsilon) && (abs(t2) <= epsilon);
00351   
00352   if (colinear) {
00353     // lines are colinear, but do they overlap? in latter case they
00354     // intersect! also check if they overlap is at a single point
00355     if ( end.x <= other.start.x + epsilon &&
00356          end.x >= other.start.x - epsilon ) {
00357       p = end;
00358       return true;
00359     }
00360     else if ( end.x <= other.end.x + epsilon &&
00361         end.x >= other.end.x - epsilon ) {
00362       p = end;
00363       return true;
00364     }
00365     else if ( start.x <= other.start.x + epsilon &&
00366         start.x >= other.start.x - epsilon ) {
00367       p = start;
00368       return true;
00369     }
00370     else if ( start.x <= other.end.x + epsilon &&
00371         start.x >= other.end.x - epsilon ) {
00372       p = start;
00373       return true;
00374     }
00375   }
00376       }
00377       return false;
00378     };
00379 
00380     /**
00381      * Compute the common line segment between this line segment and the 
00382      * \a other given one and leave the result here. This intersection is only
00383      * going to be computed if both lines are colinear.
00384      *
00385      * @param other the other line segment to which the intersection
00386      *              is going to be computed.
00387      *
00388      * @return true if an common line segment exists. It returns 
00389      *              \c false otherwise. If both line segments are parallel and
00390      *              colinear, this method returns \c true and determines the
00391      *              line segment even if it is inifinitely small, i.e. a point.
00392      *
00393      * This method can be overloaded in derived classes and other information
00394      * to accellerate the computations.
00395      */
00396     bool getCommonLine(const tline<T>& other);
00397     
00398     /**
00399      * Compute the common line segment between the given line
00400      * segments.  This intersection is only going to be computed if
00401      * both lines are colinear.
00402      *
00403      * @param first first line segment.
00404      * @param second second line segment.
00405      *
00406      * @return true if a common line segment exists. It returns 
00407      *              \c false otherwise. If both line segments are parallel and
00408      *              colinear, this method returns \c true and determines the
00409      *              line segment even if it is inifinitely small, i.e. a point.
00410      *
00411      * The common line segment will be left in this instance.
00412      *
00413      * This method can be overloaded in derived classes and other information
00414      * to accellerate the computations. 
00415      */
00416     inline bool getCommonLine(const tline<T>& first, const tline<T>& second);
00417 
00418     /**
00419      * Check if this infinitely extrapolated line intersects the \a other given
00420      * infinite line at a single finite point.
00421      *
00422      * @param other the other line segment to which an intersection is
00423      *              going to be checked.
00424      *
00425      * @return true if both inifinite lines intersect at a single finite point.
00426      *            
00427      * This method can be overloaded in derived classes and other information
00428      * to accellerate the computations.
00429      */
00430     bool doesPointIntersectXPol(const tline<T>& other) const;
00431     //----------------
00432     /**
00433      * Compute the intersection point of this infinitely extrapolated line with the 
00434      * \a other given infinite line.
00435      *
00436      * @param other the other line segment to which the intersection point
00437      *              is going to be computed.
00438      * @param p     if there is an intersection between both line segments
00439      *              or between their respective infinite line extrapolations,
00440      *              the intersection point will be written here.
00441      * @param onThisLine if the intersection occurs at a point on the line
00442      *              segment, this parameter will be set to true.  Otherwise
00443      *              false.
00444      * @param onOtherLine if the intersection occurs at a point on the other
00445      *              line segment, this parameter will be set to true.
00446      * @param colinear this parameter is set to true in case both line segments
00447      *              are parallel and co-linear.
00448      *
00449      * @return true if an unique intersection point exists. It returns 
00450      *              \c false otherwise. If both line segments are parallel and
00451      *              colinear, this method returns \c false.
00452      *
00453      * This method can be overloaded in derived classes and other information
00454      * to accellerate the computations.
00455      */
00456     template<class U>
00457     bool getIntersectionPointXPol(const tline<T>& other, tpoint<U>& p,
00458           bool& onThisLine, bool& onOtherLine,
00459           bool& colinear) const {
00460 
00461       // due to the template argument tpoint<U>, this method must be here
00462       // otherwise MS Visual C++ won't compile this file!
00463       colinear = false; 
00464     
00465       // NOTE:
00466       // This method requires following time constants:
00467       // Additions/LogicOp : 13
00468       // Multiplications   : 8 
00469       // Divisions         : 2    
00470       // Comparisons       : 6~   
00471       
00472       const tpoint<T> d1(end-start);
00473       const tpoint<T> d2(other.end-other.start);
00474       const tpoint<T> d0(other.start-start);
00475       
00476       // determinant
00477       const T det = d1.y*d2.x - d1.x*d2.y;
00478       
00479       // auxiliar variables containing information of the intersection point
00480       const T t1 = d2.x*d0.y - d2.y*d0.x;
00481       const T t2 = d1.x*d0.y - d1.y*d0.x;
00482       
00483       // just one copy for the whole history of this class (faster!)
00484       static const T epsilon = std::numeric_limits<T>::epsilon();
00485       
00486       // the numerical tolerance for parallelism is limited by epsilon.
00487       if (det > epsilon) {
00488   // compute the intersection point on the extrapolated lines
00489   const double f = static_cast<double>(t1)/static_cast<double>(det);
00490   condRoundCastTo(start.x + f*d1.x,p.x );
00491   condRoundCastTo(start.y + f*d1.y,p.y );
00492   
00493   onThisLine  = ((t1>=0) && (det >= t1));
00494   onOtherLine = ((t2>=0) && (det >= t2));
00495   
00496   return true;
00497       } else if (det < -epsilon) {
00498   // compute the intersection point on the extrapolated lines
00499   const double f = static_cast<double>(t1)/static_cast<double>(det);
00500   condRoundCastTo(start.x + f*d1.x,p.x );
00501   condRoundCastTo(start.y + f*d1.y,p.y );
00502   
00503   onThisLine  = ((t1<=0) && (det <= t1));
00504   onOtherLine = ((t2<=0) && (det <= t2));
00505   
00506   return true;
00507       } else {
00508   // lines are parallel, we just need to check, if the distance between
00509   // them is zero (in which case they may overlap in more than one point)
00510   colinear = (abs(t1) <= epsilon) && (abs(t2) <= epsilon);
00511   
00512   if (colinear) {
00513     // lines are colinear, but do they overlap? in latter case they
00514     // intersect! But we only return true, if a single inersection point exists
00515     if (d1.x > epsilon) {   
00516       onThisLine = onOtherLine
00517         = ((start.x <= other.start.x) && (end.x >= other.start.x)) ||
00518         ((start.x <= other.end.x)   && (end.x >= other.end.x));
00519     } else if (d1.x < -epsilon) {
00520       onThisLine = onOtherLine
00521         = ((end.x <= other.start.x) && (start.x >= other.start.x)) ||
00522         ((end.x <= other.end.x)   && (start.x >= other.end.x));
00523     } else if (d1.y > epsilon) {
00524       onThisLine = onOtherLine
00525         = ((start.y <= other.start.y) && (end.y >= other.start.y)) ||
00526         ((start.y <= other.end.y)   && (end.y >= other.end.y));
00527     } else {
00528       onThisLine = onOtherLine
00529         = ((end.y <= other.start.y) && (start.y >= other.start.y)) ||
00530         ((end.y <= other.end.y)   && (start.y >= other.end.y));
00531     }
00532   }
00533       }
00534       
00535       return false;
00536     };
00537 
00538     /**
00539      * Compute the intersection point of this infinitely extrapolated line with the 
00540      * \a other given infinite line.
00541      *
00542      * @param other the other line segment to which the intersection point
00543      *              is going to be computed.
00544      * @param p     if there is an intersection between both line segments
00545      *              or between their respective infinite line extrapolations,
00546      *              the intersection point will be written here.
00547      *
00548      * @return true if an unique intersection point exists. It returns 
00549      *              \c false otherwise.
00550      *
00551      * This method can be overloaded in derived classes and other information
00552      * to accellerate the computations.
00553      */
00554     template<class U>
00555     bool getIntersectionPointXPol(const tline<T>& other, tpoint<U>& p) const {
00556 
00557       // due to the template argument tpoint<U>, this method must be here
00558       // otherwise MS Visual C++ won't compile this file!
00559       
00560       // NOTE:
00561       // This method requires following time constants:
00562       // Additions/LogicOp : 7
00563       // Multiplications   : 6
00564       // Divisions         : 1
00565       // Comparisons       : 2~
00566       
00567       const tpoint<T> d1(end-start);
00568       const tpoint<T> d2(other.end-other.start);
00569      
00570       // determinant
00571       const T det = d1.y*d2.x - d1.x*d2.y;
00572       //cout << " det " << det << " d1 " << d1 << " d2 " << d2;
00573 
00574       // just one copy for the whole history of this class (faster!)
00575       static const T epsilon = std::numeric_limits<T>::epsilon();
00576       
00577       // the numerical tolerance for parallelism is limited by epsilon.
00578       if (det > epsilon || det < -epsilon) {
00579   // compute the intersection point on the extrapolated lines
00580   const tpoint<T> d0(other.start-start);
00581   const T t1 = d2.x*d0.y - d2.y*d0.x;
00582   const double f = static_cast<double>(t1)/static_cast<double>(det);
00583   //cout << " f " << f;
00584   condRoundCastTo(start.x + f*d1.x,p.x );
00585   condRoundCastTo(start.y + f*d1.y,p.y );
00586   
00587   return true;
00588       }
00589     
00590       return false;      
00591     };
00592 
00593     /**
00594      * Compute the part of the infinite extrapolated line containing this line
00595      * segment which lies within the given rectangle, and leave the result
00596      * here.
00597      *
00598      * This method assumes, the rectangle is already consistent, i.e.
00599      * the \a rect.ul point is in both coordinates smaller than \a rect.br.
00600      *
00601      * @return true if part of this line lies within the rectangle or its
00602      *              border, false otherwise.
00603      */
00604     bool intersectXPol(const trectangle<T>& rect);
00605 
00606     /**
00607      * Compute the part of the infinite extrapolated line containing the \a
00608      * other line segment which lies within the given rectangle, and leave the
00609      * result here.
00610      *
00611      * This method assumes, the rectangle is already consistent, i.e.
00612      * the \a rect.ul point is in both coordinates smaller than \a rect.br.
00613      *
00614      * @return true if part of this line lies within the rectangle or its
00615      *              border, false otherwise.
00616      */
00617     inline bool intersectXPol(const tline<T>& other,
00618                               const trectangle<T>& rect);
00619 
00620     /**
00621      * @name Scaling and Translation operations
00622      */
00623     //@{
00624     
00625     /**
00626      * scale this line by the given \a c factor.
00627      */
00628     template<class U>
00629     inline tline<T>& scale(const U c) {
00630       start.multiply(c);
00631       end.multiply(c);
00632       return *this;
00633     };
00634 
00635     /**
00636      * create a new line equal this one scaled by the given \a c factor.
00637      */
00638     template<class U>
00639     inline tline<T> operator*(const U c) const {
00640       return tline<T>(start*c,end*c);
00641     };
00642 
00643     /**
00644      * scale this line by the given \a c factor.
00645      */
00646     template<class U>
00647     inline tline<T>& operator*=(const U c) {
00648       return multiply(c);
00649     };
00650 
00651     /**
00652      * divide both points by the given \a c factor
00653      */
00654     template<class U>
00655     inline tline<T>& divide(const U c) {
00656       start.divide(c);
00657       end.divide(c);
00658       return *this;      
00659     };
00660 
00661     /**
00662      * divide both points by the given \a c factor
00663      */
00664     template <class U>
00665     inline tline<T> operator/(const U c) const {
00666       return tline<T>(start/c,end/c);
00667     };
00668 
00669     /**
00670      * divide both points of tline<T> by a given factor
00671      */
00672     template <class U>
00673     inline tline<T>& operator/=(const U c) {
00674       return divide(c);  
00675     };
00676 
00677     /**
00678      * add given point to both ends of this line and leave the result here.
00679      * @param p the other line to be added to this one
00680      * @return a reference to this line
00681      */
00682     inline tline<T>& translate(const tpoint<T>& p);
00683 
00684     /**
00685      * add given point to both ends of the \a other line and leave the
00686      * result here.  
00687      * @param other the other line to be tranlated
00688      * @param p the translation factor
00689      * @return a reference to this line
00690      */
00691     inline tline<T>& translate(const tline<T>& other,const tpoint<T>& p);
00692 
00693     /**
00694      * Compute the orthogonal line and leave the result here.
00695      *
00696      * @param offset the offset to the point on the line, where the orthogonal
00697      *               shall start. This parameter is scaled by the length of the line.
00698      * @return a reference to this line
00699      *
00700      * This method can be overloaded in derived classes and other information
00701      * to accellerate the computations.
00702      */
00703     tline<T>& getOrthogonal(double offset);
00704     
00705     /**
00706      * Compute the orthogonal line to the other line and leave the result here.
00707      *
00708      * @param other  the line segment of which the orthogonal line
00709      *               is going to be computed.
00710      * @param offset the offset to the point on the line, where the orthogonal
00711      *               shall start. This parameter is scaled by the length of the line.
00712      * @return a reference to this line
00713      *
00714      * This method can be overloaded in derived classes and other information
00715      * to accellerate the computations.
00716      */
00717     inline tline<T>& getOrthogonal(const tline<T>& other, double offset);
00718   
00719     //@}
00720 
00721     /**
00722      * copy operator
00723      */
00724     inline tline<T>& copy(const tline<T>& other);
00725 
00726     /**
00727      * operator =
00728      */
00729     inline tline<T>& operator=(const tline<T>& other) {return copy(other);};
00730 
00731     /**
00732      * operator ==
00733      */
00734     inline bool operator==(const tline<T>& other) const;
00735 
00736     /**
00737      * operator !=
00738      */
00739     inline bool operator!=(const tline<T>& other) const;
00740   };
00741 
00742 
00743   // ----------------------------------------------------------------------
00744   // Type definitions
00745   // ----------------------------------------------------------------------
00746 
00747   /**
00748    * A line with integer coordinates
00749    */
00750   typedef tline<int> line;
00751 
00752   /**
00753    * A line with double coordinates
00754    */
00755   typedef tline<double> dline;
00756 
00757   /**
00758    * A line with float coordinates
00759    */
00760   typedef tline<float> fline;
00761 
00762   // ---------------------------------------------------
00763   // Storable interface
00764   // ---------------------------------------------------
00765 
00766   /**
00767    * read the vector from the given ioHandler. The complete flag indicates
00768    * if the enclosing begin and end should be also be read
00769    *
00770    * @ingroup gStorable
00771    */
00772   template <class T>
00773   bool read(ioHandler& handler,tline<T>& l, const bool complete=true);
00774   
00775   /**
00776    * write the vector in the given ioHandler. The complete flag indicates
00777    * if the enclosing begin and end should be also be written or not
00778    *
00779    * @ingroup gStorable
00780    */
00781   template<class T>
00782   bool write(ioHandler& handler,const tline<T>& l,const bool complete=true);
00783 
00784 } // namespace lti
00785 
00786 namespace std {
00787 
00788   template <class T>
00789   ostream& operator<<(ostream& s,const lti::tline<T>& l);
00790   
00791   template <class T>
00792   istream& operator>>(istream& s,lti::tline<T>& l);
00793 
00794 } // namespace std
00795 
00796 // implementation of inline methods
00797 #include "ltiLine_inline.h"
00798 
00799 #endif

Generated on Sat Apr 10 15:25:43 2010 for LTI-Lib by Doxygen 1.6.1