26#include <fvmodels/shape/line.h>
27#include <utils/math/angle.h>
47 max_length = (int)sqrt(roi_width * roi_width + roi_height * roi_height);
48 last_calc_r = last_calc_phi = 0.f;
50 this->roi_width = roi_width;
51 this->roi_height = roi_height;
65 stream <<
"r=" << r <<
" phi=" << phi <<
" count= " << count;
71 this->margin = margin;
98 if ((last_calc_r == r) && (last_calc_phi == phi))
106 bool reverse_direction =
false;
111 if (rad_angle < M_PI / 4) {
112 x1 = (int)round(r * cos(rad_angle));
113 y1 = (int)round(r * sin(rad_angle));
115 x2 = (int)round(r / cos(rad_angle));
116 }
else if (rad_angle < M_PI / 2) {
117 x1 = (int)round(r * cos(rad_angle));
118 y1 = (int)round(r * sin(rad_angle));
120 y2 = (int)round(r / cos(M_PI / 2 - rad_angle));
121 }
else if (rad_angle < 3.0 / 4.0 * M_PI) {
122 x1 = (int)round(-r * cos(M_PI - rad_angle));
123 y1 = (int)round(r * sin(M_PI - rad_angle));
125 y2 = (int)round(r / cos(rad_angle - M_PI / 2));
130 reverse_direction =
true;
134 x1 = (int)round(-r * cos(M_PI - rad_angle));
135 y1 = (int)round(r * sin(M_PI - rad_angle));
137 x2 = (int)round(-r / cos(M_PI - rad_angle));
142 reverse_direction =
true;
146 if (!(x1 == x2 && y1 == y2)) {
149 float vx, vy, length;
152 length = sqrt(vx * vx + vy * vy);
159 if (!reverse_direction) {
173 }
else if (y2 == 0) {
177 cout <<
"ERROR!" << endl
178 <<
" This case should not have occurred. Please have a look at method" << endl
179 <<
" \"LineShape::calc()\". Treatment of special case is not correct." << endl;
void printToStream(std::ostream &stream)
Print line.
void setMargin(unsigned int margin)
Set margin around shape.
LineShape(unsigned int roi_width, unsigned int roi_height)
Constructor.
bool isClose(unsigned int in_roi_x, unsigned int in_roi_y)
Check if the given point is close to the shape.
void calcPoints()
Calc points for line.
void getPoints(int *x1, int *y1, int *x2, int *y2)
Get two points that define the line.
float deg2rad(float deg)
Convert an angle given in degrees to radians.