GLine2D.h
Go to the documentation of this file.
00001 #ifndef GLINE2D_H
00002 #define GLINE2D_H
00003 
00004 #include <cmath>
00005 #include <utility>
00006 #include <vector>
00007 
00008 #include "MathUtil.h"
00009 #include "XYWeight.h"
00010 
00011 namespace AprilTags {
00012 
00014 class GLine2D {
00015 public:
00016 
00018   GLine2D();
00019 
00021   /*  @param slope the slope
00022    *  @param b the y intercept
00023    */
00024   GLine2D(float slope, float b);
00025 
00027   /*  @param dx A change in X corresponding to dy
00028    *  @param dy A change in Y corresponding to dx
00029    *  @param p A point that the line passes through
00030    */
00031   GLine2D(float dX, float dY, const std::pair<float,float>& pt);
00032 
00034   /*  @param p1 the first point
00035    *  @param p2 the second point
00036    */
00037   GLine2D(const std::pair<float,float>& p1, const std::pair<float,float>& p2);
00038 
00041   /*  This allows easy computation if one point is between two other points on the line:
00042    *  compute the line coordinate of all three points and test if a<=b<=c. This is 
00043    *  implemented by computing the dot product of the vector 'p' with the
00044    *  line's direct unit vector.
00045    */
00046   float getLineCoordinate(const std::pair<float,float>& p);
00047   
00049   std::pair<float,float> getPointOfCoordinate(float coord);
00050 
00052   std::pair<float,float> intersectionWith(const GLine2D& line) const;
00053 
00054   static GLine2D lsqFitXYW(const std::vector<XYWeight>& xyweights);
00055 
00056   inline float getDx() const { return dx; }
00057   inline float getDy() const { return dy; }
00058   inline float getFirst() const { return p.first; }
00059   inline float getSecond() const { return p.second; }
00060 
00061 protected:
00062   void normalizeSlope();
00063   void normalizeP();
00064 
00065 private:
00066   float dx, dy;
00067   std::pair<float,float> p;  
00068   bool didNormalizeSlope;
00069   bool didNormalizeP;
00070 };
00071 
00072 } // namespace
00073 
00074 #endif


apriltags
Author(s): Michael Kaess, Hordur Johannson
autogenerated on Thu Jun 6 2019 20:53:23