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
00022
00023
00024 GLine2D(float slope, float b);
00025
00027
00028
00029
00030
00031 GLine2D(float dX, float dY, const std::pair<float,float>& pt);
00032
00034
00035
00036
00037 GLine2D(const std::pair<float,float>& p1, const std::pair<float,float>& p2);
00038
00041
00042
00043
00044
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 }
00073
00074 #endif