29 const double a = l->
pos.
x;
30 const double b = l->
pos.
y;
31 const double c =
after(l)->pos.x - a;
32 const double d =
after(l)->pos.y - b;
33 const double e = m->
pos.
x - a;
34 const double f = m->
pos.
y - b;
35 const double g =
after(m)->pos.x - a;
36 const double h =
after(m)->pos.y - b;
37 double t = c * f - d * e;
56static int between(
double f,
double g,
double h) {
107 }
else if (ms.
x == me.
x) {
111 const double m1 =
SLOPE(ms, me);
112 const double m2 =
SLOPE(ls,
le);
113 const double c1 = ms.
y - m1 * ms.
x;
114 const double c2 = ls.
y - m2 * ls.
x;
115 *
x = (c2 - c1) / (m1 - m2);
116 *
y = (m1 * c2 - c1 * m2) / (m1 - m2);
121 if (
online(l, m, 0) == -1) {
123 pt2 =
online(m, l, 1) == -1 ? (
online(m, l, 0 == -1) ?
le : ls) : me;
124 }
else if (
online(l, m, 1) == -1) {
126 pt2 =
online(l, m, 0) == -1 ? (
online(m, l, 0) == -1 ?
le : ls) : ms;
129 if (
online(m, l, 0) != -1)
135 *
x = (pt1.
x + pt2.
x) / 2;
136 *
y = (pt1.
y + pt2.
y) / 2;
140 if ((ls.
x -
le.x) * (ms.
y - ls.
y) == (ls.
y -
le.y) * (ms.
x - ls.
x)) {
156 intersections_t *ilist) {
static int between(double f, double g, double h)
static void sgnarea(struct vertex *l, struct vertex *m, int i[])
static int online(struct vertex *l, struct vertex *m, int i)
void find_intersection(struct vertex *l, struct vertex *m, intersections_t *ilist)
detect whether lines l and m intersect
static int sign(double v)
static int intpoint(struct vertex *l, struct vertex *m, double *x, double *y, int cond)
#define LIST_APPEND(list, item)