11 static void delete_point(
int *
x,
int *y,
int count)
15 for (i = 0; i <
count; i++) {
21 static double find_azimuth(
double x1,
double y1,
double x2,
double y2)
29 return (y2 > y1) ? 90.0 : 270.0;
34 return 360.0 + (
RAD_DEG * atan(yy / xx));
37 return 180.0 + (
RAD_DEG * atan(yy / xx));
42 return (
RAD_DEG * atan(yy / xx));
45 return 180.0 + (
RAD_DEG * atan(yy / xx));
57 int min_x, max_x, min_y, max_y;
59 double min_azimuth = 1.0;
60 double azimuth1, azimuth2, diff1, diff2;
64 for (i = 0; i < n; i++) {
66 y[i] = (int)floor(p->
vertices[i].
y + 0.5);
78 delta_x =
x[i] -
x[i + 1];
81 delta_y = y[i] - y[i + 1];
85 if ((
x[i] ==
x[i + 1] && y[i] == y[i + 1]) ||
87 delete_point(&
x[i + 1], &y[i + 1], n - i - 1);
97 delta_x =
x[0] -
x[n - 1];
100 delta_y = y[0] - y[n - 1];
104 if ((
x[0] ==
x[n - 1] && y[0] == y[n - 1]) ||
119 min_x = max_x =
x[0];
120 min_y = max_y = y[0];
121 for (i = 0; i < n; i++) {
131 delta_x = max_x - min_x;
132 delta_y = max_y - min_y;
143 for (i = 0; i < (n - 2); i++) {
150 azimuth1 = find_azimuth((
double)
x[i], (
double)y[i],
151 (
double)
x[i + 1], (
double)y[i + 1]);
152 azimuth2 = find_azimuth((
double)
x[i], (
double)y[i],
153 (
double)
x[i + 2], (
double)y[i + 2]);
155 diff1 = fmod(fabs((azimuth2 + 360.0) - azimuth1), 360.0);
156 diff2 = fmod(fabs((azimuth1 + 360.0) - azimuth2), 360.0);
158 if (diff1 <= min_azimuth || diff2 <= min_azimuth) {
160 delete_point(&
x[i + 1], &y[i + 1], n - i - 1);
189 new->next_poly =
NULL;
void G_free(void *)
Free allocated memory.
char * G_store(const char *)
Copy string to allocated memory.
void html_polygon(const struct path *p)