LFLineSegment.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #pragma once
00029 #include <stdio.h>
00030 #define _USE_MATH_DEFINES
00031 #include <math.h>
00032 #undef _USE_MATH_DEFINES
00033
00034 #include <opencv/cxcore.h>
00035
00036
00037 class LFLineSegment
00038 {
00039 public:
00040 LFLineSegment()
00041 {
00042 sx_ = 0;
00043 sy_ = 0;
00044 ex_ = 0;
00045 ey_ = 0;
00046 normal_.x =0;
00047 normal_.y =0;
00048 nSupport_ = 0;
00049 weight_ = 0;
00050
00051 };
00052 ~LFLineSegment() {
00053
00054 };
00055
00056 double sx_,sy_,ex_,ey_;
00057 int nSupport_;
00058 double len_;
00059 double weight_;
00060 CvPoint2D64f normal_;
00061
00062 inline LFLineSegment& operator=(const LFLineSegment &rhs);
00063
00064
00065 inline static int Compare(const void *l1,const void *l2);
00066 inline static int LineSegmentCompare( LFLineSegment &l1, LFLineSegment &l2);
00067
00068
00069 void Read(FILE* fin);
00070 void Center(double *center);
00071 void Translate(double *vec);
00072
00073 double Theta();
00074
00075 void Rotate(double theta);
00076 void Scale(double s);
00077 double Length();
00078
00079 };
00080
00081 inline int LFLineSegment::LineSegmentCompare( LFLineSegment &l1, LFLineSegment &l2 )
00082 {
00083 if( l1.len_ > l2.len_ )
00084 return -1;
00085 else if( l1.len_ == l2.len_ )
00086 return 0;
00087 else
00088 return 1;
00089 };
00090
00091 inline int LFLineSegment::Compare(const void *l1,const void *l2 )
00092 {
00093 return LineSegmentCompare( *(LFLineSegment*)l1, *(LFLineSegment*)l2 );
00094
00095 };
00096
00097 inline LFLineSegment& LFLineSegment::operator=(const LFLineSegment &rhs)
00098 {
00099 sx_ = rhs.sx_;
00100 sy_ = rhs.sy_;
00101 ex_ = rhs.ex_;
00102 ey_ = rhs.ey_;
00103 len_ = rhs.len_;
00104 weight_ = rhs.weight_;
00105
00106 nSupport_ = rhs.nSupport_;
00107 normal_ = rhs.normal_;
00108 return (*this);
00109 }