24 #define _USE_MATH_DEFINES // for M_PI
34 #include "config_auto.h"
40 static int direction(
const EDGEPT* point) {
79 point_heap->
Push(&pair);
82 #ifndef GRAPHICS_DISABLED
107 vector1.
x = point2->
pos.
x - point1->
pos.
x;
108 vector1.
y = point2->
pos.
y - point1->
pos.
y;
109 vector2.
x = point3->
pos.
x - point2->
pos.
x;
110 vector2.
y = point3->
pos.
y - point2->
pos.
y;
112 float length = std::sqrt(
static_cast<float>(vector1.
length()) * vector2.
length());
113 if (
static_cast<int>(length) == 0)
115 angle =
static_cast<int>(floor(asin(vector1.
cross(vector2) /
116 length) / M_PI * 180.0 + 0.5));
119 if (vector1.
dot(vector2) < 0)
138 EDGEPT *best_point =
nullptr;
143 found_better =
false;
145 this_distance =
edgept_dist (critical_point, vertical_point);
146 if (this_distance <= *best_dist) {
152 *best_dist = this_distance;
153 best_point = vertical_point;
158 vertical_point = vertical_point->
next;
160 while (found_better ==
true);
175 EDGEPT *local_min =
nullptr;
176 EDGEPT *local_max =
nullptr;
178 this_point = outline->
loop;
179 local_min = this_point;
180 local_max = this_point;
182 if (this_point->
vec.
y < 0) {
184 if (local_max !=
nullptr)
189 local_min = this_point->
next;
191 else if (this_point->
vec.
y > 0) {
193 if (local_min !=
nullptr)
198 local_max = this_point->
next;
202 if (local_max !=
nullptr) {
206 local_max = this_point->
next;
213 local_min = this_point->
next;
219 this_point = this_point->
next;
221 while (this_point != outline->
loop);
235 dir = direction (local_min);
259 dir = direction (local_max);
287 EDGEPT_CLIST *new_points) {
290 EDGEPT_C_IT new_point_it(new_points);
291 int x = split_point->
pos.
x;
294 if (*best_point !=
nullptr)
300 if (((p->
pos.
x <= x && x <= p->next->pos.x) ||
301 (p->
next->
pos.
x <= x && x <= p->pos.x)) &&
305 (*best_point ==
nullptr || !
same_point((*best_point)->pos, p->
pos))) {
308 new_point_it.add_before_then_move(this_edgept);
311 if (*best_point ==
nullptr)
312 best_dist =
edgept_dist (split_point, this_edgept);
317 *best_point = this_edgept;
322 while (p != target_point);