5 #include <opencv2/opencv.hpp>
11 #define DEFFLEQEPSILON 0.001
20 bool Within(
float fl,
float flLow,
float flHi,
float flEp =
24 bool SortbyDistance(
const Point2f & a,
const Point2f &b);
25 bool IsOnThis(
const Point2f& ptTest,
float flEp =
27 LineSegment(
const Point2d p1,
const Point2d p2,
double _probability=0.0);
28 LineSegment(
const Point2d center,
double angle,
double length,
double _probability=0.0);
32 inline void setProbability(
double _in)
34 probability=std::max(0.0,std::min(_in,1.0));
36 inline double getProbability()
const
40 double GetLength()
const;
41 void Clip(Rect boundry);
42 void GetDirection(Point2d &res)
const;
43 float GetYByX(
float x)
const;
44 int GetSide(
const Point2d point)
const;
45 double GetExteriorAngleDegree(
const LineSegment otherLine)
const;
46 double GetAbsMinAngleDegree(
const LineSegment otherLine)
const;
48 Point2f GetClosestPointOnLineSegment(Point2f p);
50 float DistanceFromLine(Point2f p);
52 bool IntersectLineForm(
LineSegment L, Point2d &res);
53 LineSegment PerpendicularLineSegment(
double scale = 1);
54 LineSegment PerpendicularLineSegment(
double len, cv::Point2d mid);
55 bool GetSlope(
double &slope)
57 if (abs(P2.x - P1.x) < 0.00001)
61 slope = (P2.y - P1.y) / (P2.x - P1.x);
64 double GetRadianFromX()
66 double res = atan2f((P2.y - P1.y), (P2.x - P1.x));
69 double GetDegreeFromX()
71 return (GetRadianFromX() / M_PI) * (180);;
75 double angle=GetRadianFromX();
76 Point2d mid=GetMiddle();
77 double len=GetLength()/2;
79 double x2=mid.x+cos(angle)*len;
80 double y2=mid.y+sin(angle)*len;
81 double x1=mid.x-cos(angle)*len;
82 double y1=mid.y-sin(angle)*len;
86 vector<LineSegment> GetMidLineSegments(
89 vector<LineSegment> lsList, lsListTmp;
92 for (
int counter = 0; counter < count; counter++)
95 for (
size_t i = 0; i < lsList.size(); i++)
98 Point2d midPoint = tmp.GetMiddle();
100 lsListTmp.push_back(
LineSegment(tmp.P2, midPoint));
107 vector<Point2d> GetMidPoints(
108 int count ,
bool sortthis =
112 vector<LineSegment> lsList, lsListTmp;
117 for (
int counter = 0; counter < count; counter++)
120 for (
size_t i = 0; i < lsList.size(); i++)
123 Point2d midPoint = tmp.GetMiddle();
124 res.push_back(midPoint);
125 lsListTmp.push_back(
LineSegment(tmp.P1, midPoint));
126 lsListTmp.push_back(
LineSegment(tmp.P2, midPoint));
133 sort(res.begin(), res.end(),
134 bind(&LineSegment::SortbyDistance,
this, _1, _2));
A class representing line segments.
Definition: LineSegment.hpp:17