11 static void delete_point(
int *
x,
int *y,
int count)
15 for (i = 0; i <
count; i++) {
23 static double find_azimuth(
double x1,
double y1,
double x2,
double y2)
31 return (y2 > y1) ? 90.0 : 270.0;
36 return 360.0 + (
RAD_DEG * atan(yy / xx));
39 return 180.0 + (
RAD_DEG * atan(yy / xx));
44 return (
RAD_DEG * atan(yy / xx));
47 return 180.0 + (
RAD_DEG * atan(yy / xx));
60 int min_x, max_x, min_y, max_y;
62 double min_azimuth = 1.0;
63 double azimuth1, azimuth2, diff1, diff2;
67 for (i = 0; i < n; i++) {
68 x[i] = (int) floor(p->
vertices[i].
x + 0.5);
69 y[i] = (int) floor(p->
vertices[i].
y + 0.5);
81 delta_x = x[i] - x[i + 1];
84 delta_y = y[i] - y[i + 1];
88 if ((x[i] == x[i + 1] && y[i] == y[i + 1]) ||
90 delete_point(&x[i + 1], &y[i + 1], n - i - 1);
100 delta_x = x[0] - x[n - 1];
103 delta_y = y[0] - y[n - 1];
107 if ((x[0] == x[n - 1] && y[0] == y[n - 1]) ||
124 min_x = max_x = x[0];
125 min_y = max_y = y[0];
126 for (i = 0; i < n; i++) {
136 delta_x = max_x - min_x;
137 delta_y = max_y - min_y;
149 for (i = 0; i < (n - 2); i++) {
156 azimuth1 = find_azimuth((
double)x[i], (
double)y[i],
157 (
double)x[i + 1], (
double)y[i + 1]);
158 azimuth2 = find_azimuth((
double)x[i], (
double)y[i],
159 (
double)x[i + 2], (
double)y[i + 2]);
161 diff1 = fmod(fabs((azimuth2 + 360.0) - azimuth1), 360.0);
162 diff2 = fmod(fabs((azimuth1 + 360.0) - azimuth2), 360.0);
164 if (diff1 <= min_azimuth || diff2 <= min_azimuth) {
166 delete_point(&x[i + 1], &y[i + 1], n - i - 1);
196 new->next_poly =
NULL;
void html_polygon(const struct path *p)
void G_free(void *)
Free allocated memory.
char * G_store(const char *)
Copy string to allocated memory.