23 #define _USE_MATH_DEFINES // for M_PI
33 #include "config_auto.h"
39 static int direction(
const EDGEPT* point) {
78 point_heap->
Push(&pair);
81 #ifndef GRAPHICS_DISABLED
106 vector1.
x = point2->
pos.
x - point1->
pos.
x;
107 vector1.
y = point2->
pos.
y - point1->
pos.
y;
108 vector2.
x = point3->
pos.
x - point2->
pos.
x;
109 vector2.
y = point3->
pos.
y - point2->
pos.
y;
111 float length = std::sqrt(static_cast<float>(vector1.
length()) * vector2.
length());
112 if (static_cast<int>(length) == 0)
114 angle = static_cast<int>(floor(asin(vector1.
cross(vector2) /
115 length) / M_PI * 180.0 + 0.5));
118 if (vector1.
dot(vector2) < 0)
137 EDGEPT *best_point =
nullptr;
142 found_better =
false;
144 this_distance =
edgept_dist (critical_point, vertical_point);
145 if (this_distance <= *best_dist) {
151 *best_dist = this_distance;
152 best_point = vertical_point;
157 vertical_point = vertical_point->
next;
159 while (found_better ==
true);
174 EDGEPT *local_min =
nullptr;
175 EDGEPT *local_max =
nullptr;
177 this_point = outline->
loop;
178 local_min = this_point;
179 local_max = this_point;
181 if (this_point->
vec.
y < 0) {
183 if (local_max !=
nullptr)
188 local_min = this_point->
next;
190 else if (this_point->
vec.
y > 0) {
192 if (local_min !=
nullptr)
197 local_max = this_point->
next;
201 if (local_max !=
nullptr) {
205 local_max = this_point->
next;
212 local_min = this_point->
next;
218 this_point = this_point->
next;
220 while (this_point != outline->
loop);
234 dir = direction (local_min);
258 dir = direction (local_max);
286 EDGEPT_CLIST *new_points) {
289 EDGEPT_C_IT new_point_it(new_points);
290 int x = split_point->
pos.
x;
293 if (*best_point !=
nullptr)
299 if (((p->
pos.
x <= x && x <= p->next->pos.x) ||
300 (p->
next->
pos.
x <= x && x <= p->pos.x)) &&
304 (*best_point ==
nullptr || !
same_point((*best_point)->pos, p->
pos))) {
307 new_point_it.add_before_then_move(this_edgept);
310 if (*best_point ==
nullptr)
311 best_dist =
edgept_dist (split_point, this_edgept);
316 *best_point = this_edgept;
321 while (p != target_point);