27 #include <grass/Vect.h>
29 static double d_atan2(
double,
double);
44 n_points = points->n_points;
62 for (i = 1; i < n_points - 1; i++) {
63 if ((thresh < fabs(*xptr - last_x)) ||
64 (thresh < fabs(*yptr - last_y))) {
76 return ((
float)d_atan2(yarray[1] - last_y, xarray[1] - last_x));
79 return ((
float)d_atan2(*yptr - last_y, *xptr - last_x));
98 n_points = points->n_points;
104 last_x = *(xarray + n_points - 1);
105 last_y = *(yarray + n_points - 1);
106 xptr = xarray + n_points - 2;
107 yptr = yarray + n_points - 2;
113 for (i = n_points - 2; i > 0; i--) {
114 if ((thresh < fabs(*xptr - last_x)) ||
115 (thresh < fabs(*yptr - last_y))) {
128 d_atan2(yarray[n_points - 2] - last_y,
129 xarray[n_points - 2] - last_x));
132 return ((
float)d_atan2(*yptr - last_y, *xptr - last_x));
148 n_points = points->n_points;
158 for (i = 1; i < n_points; i++) {
159 if ((thresh < fabs(*xptr - last_x)) ||
160 (thresh < fabs(*yptr - last_y))) {
185 G_debug(5,
"dig_line_degenerate()");
187 n_points = points->n_points;
190 G_debug(5,
" Line is degenerate (one points)");
196 for (i = 1; i < n_points; i++) {
197 if (points->x[i] != points->x[i - 1] ||
198 points->y[i] != points->y[i - 1]) {
205 G_debug(5,
" Line is degenerate (more points)");
212 static double d_atan2(
double y,
double x)
214 if (y == 0.0 && x == 0.0)
217 return (atan2(y, x));
int dig_line_degenerate(struct line_pnts *points)
int dig_is_line_degenerate(struct line_pnts *points, double thresh)
int G_debug(int level, const char *msg,...)
Print debugging message.
float dig_calc_begin_angle(struct line_pnts *points, double thresh)
float dig_calc_end_angle(struct line_pnts *points, double thresh)