26 #include <utils/math/angle.h> 27 #include <fvmodels/shape/line.h> 47 LineShape::LineShape(
unsigned int roi_width,
unsigned int roi_height)
53 max_length = (int)sqrt( roi_width * roi_width + roi_height * roi_height );
54 last_calc_r = last_calc_phi = 0.f;
56 this->roi_width = roi_width;
57 this->roi_height = roi_height;
63 LineShape::~LineShape()
72 LineShape::printToStream(std::ostream &stream)
74 stream <<
"r=" << r <<
" phi=" << phi
75 <<
" count= " << count;
79 LineShape::setMargin(
unsigned int margin)
81 this->margin = margin;
86 LineShape::isClose(
unsigned int in_roi_x,
unsigned int in_roi_y)
107 LineShape::calcPoints()
110 if ((last_calc_r == r) && (last_calc_phi == phi))
return;
117 bool reverse_direction =
false;
122 if ( rad_angle < M_PI/4 ) {
123 x1 = (int)round( r * cos( rad_angle ) );
124 y1 = (int)round( r * sin( rad_angle ) );
126 x2 = (int)round( r / cos( rad_angle ) );
127 }
else if ( rad_angle < M_PI/2 ) {
128 x1 = (int)round( r * cos( rad_angle ) );
129 y1 = (int)round( r * sin( rad_angle ) );
131 y2 = (int)round( r / cos( M_PI/2 - rad_angle ) );
132 }
else if ( rad_angle < 3.0/4.0 * M_PI ) {
133 x1 = (int)round(-r * cos( M_PI - rad_angle ) );
134 y1 = (int)round( r * sin( M_PI - rad_angle ) );
136 y2 = (int)round( r / cos( rad_angle - M_PI/2 ) );
141 reverse_direction =
true;
145 x1 = (int)round(-r * cos( M_PI - rad_angle ) );
146 y1 = (int)round( r * sin( M_PI - rad_angle ) );
148 x2 = (int)round(-r / cos( M_PI - rad_angle ) );
153 reverse_direction =
true;
161 float vx, vy, length;
164 length = sqrt( vx * vx + vy * vy );
171 if ( ! reverse_direction) {
185 }
else if (y2 == 0) {
189 cout <<
"ERROR!" << endl
190 <<
" This case should not have occurred. Please have a look at method" << endl
191 <<
" \"LineShape::calc()\". Treatment of special case is not correct." << endl;
205 LineShape::getPoints(
int *x1,
int *y1,
int *x2,
int *y2)
float deg2rad(float deg)
Convert an angle given in degrees to radians.