31 const double a = l->
pos.
x;
32 const double b = l->
pos.
y;
33 const double c =
after(l)->pos.x - a;
34 const double d =
after(l)->pos.y - b;
35 const double e = m->
pos.
x - a;
36 const double f = m->
pos.
y - b;
37 const double g =
after(m)->pos.x - a;
38 const double h =
after(m)->pos.y - b;
39 double t = c * f - d * e;
58static int between(
double f,
double g,
double h) {
109 }
else if (ms.
x == me.
x) {
113 const double m1 =
SLOPE(ms, me);
114 const double m2 =
SLOPE(ls,
le);
115 const double c1 = ms.
y - m1 * ms.
x;
116 const double c2 = ls.
y - m2 * ls.
x;
117 *
x = (c2 - c1) / (m1 - m2);
118 *
y = (m1 * c2 - c1 * m2) / (m1 - m2);
123 if (
online(l, m, 0) == -1) {
125 pt2 =
online(m, l, 1) == -1 ? (
online(m, l, 0 == -1) ?
le : ls) : me;
126 }
else if (
online(l, m, 1) == -1) {
128 pt2 =
online(l, m, 0) == -1 ? (
online(m, l, 0) == -1 ?
le : ls) : ms;
131 if (
online(m, l, 0) != -1)
137 *
x = (pt1.
x + pt2.
x) / 2;
138 *
y = (pt1.
y + pt2.
y) / 2;
142 if ((ls.
x -
le.x) * (ms.
y - ls.
y) == (ls.
y -
le.y) * (ms.
x - ls.
x)) {
181 fprintf(stderr,
"\n**ERROR**\n using too many intersections\n");
static NORETURN void graphviz_exit(int status)
static int between(double f, double g, double h)
void find_intersection(struct vertex *l, struct vertex *m, struct intersection ilist[], struct data *input)
detect whether lines l and m intersect
static void sgnarea(struct vertex *l, struct vertex *m, int i[])
static int online(struct vertex *l, struct vertex *m, int i)
static int sign(double v)
static int intpoint(struct vertex *l, struct vertex *m, double *x, double *y, int cond)