GLineSegment2D.cc
Go to the documentation of this file.
00001 #include "GLineSegment2D.h"
00002 #include <limits>
00003 
00004 namespace AprilTags {
00005 
00006 GLineSegment2D::GLineSegment2D(const std::pair<float,float>& p0Arg, const std::pair<float,float>& p1Arg)
00007 : line(p0Arg,p1Arg), p0(p0Arg), p1(p1Arg), weight() {}
00008 
00009 GLineSegment2D GLineSegment2D::lsqFitXYW(const std::vector<XYWeight>& xyweight) {
00010         GLine2D gline = GLine2D::lsqFitXYW(xyweight);
00011         float maxcoord = -std::numeric_limits<float>::infinity();
00012         float mincoord = std::numeric_limits<float>::infinity();;
00013         
00014         for (unsigned int i = 0; i < xyweight.size(); i++) {
00015                 std::pair<float,float> p(xyweight[i].x, xyweight[i].y);
00016                 float coord = gline.getLineCoordinate(p);
00017                 maxcoord = std::max(maxcoord, coord);
00018                 mincoord = std::min(mincoord, coord);
00019         }
00020         
00021         std::pair<float,float> minValue = gline.getPointOfCoordinate(mincoord);
00022         std::pair<float,float> maxValue = gline.getPointOfCoordinate(maxcoord);
00023         return GLineSegment2D(minValue,maxValue);
00024 }
00025 
00026 } // namespace


apriltags
Author(s): Mitchell Wills
autogenerated on Thu Aug 27 2015 12:23:28