f = m->pos.y - b;
g = after(m)->pos.x - a;
h = after(m)->pos.y - b;
- t = (c * f) - (d * e);
- i[0] = ((t == 0) ? 0 : (t > 0 ? 1 : -1));
- t = (c * h) - (d * g);
- i[1] = ((t == 0) ? 0 : (t > 0 ? 1 : -1));
+ t = c * f - d * e;
+ i[0] = t == 0 ? 0 : (t > 0 ? 1 : -1);
+ t = c * h - d * g;
+ i[1] = t == 0 ? 0 : (t > 0 ? 1 : -1);
i[2] = i[0] * i[1];
}
struct position a, b, c;
a = l->pos;
b = after(l)->pos;
- c = (i == 0) ? m->pos : after(m)->pos;
- return ((a.x == b.x) ? ((a.x == c.x)
- && (-1 !=
- between(a.y, c.y, b.y))) : between(a.x,
- c.x,
- b.x));
+ c = i == 0 ? m->pos : after(m)->pos;
+ return a.x == b.x ? (a.x == c.x && -1 != between(a.y, c.y, b.y))
+ : between(a.x, c.x, b.x);
}
/* determine point of detected intersections */
} else {
m1 = SLOPE(ms, me);
m2 = SLOPE(ls, le);
- c1 = ms.y - (m1 * ms.x);
- c2 = ls.y - (m2 * ls.x);
+ c1 = ms.y - m1 * ms.x;
+ c2 = ls.y - m2 * ls.x;
*x = (c2 - c1) / (m1 - m2);
- *y = ((m1 * c2) - (c1 * m2)) / (m1 - m2);
+ *y = (m1 * c2 - c1 * m2) / (m1 - m2);
}
break;
case 2: /* the two lines have a common segment */
if (online(l, m, 0) == -1) { /* ms between ls and le */
pt1 = ms;
- pt2 =
- (online(m, l, 1) ==
- -1) ? ((online(m, l, 0) == -1) ? le : ls) : me;
+ pt2 = online(m, l, 1) == -1 ? (online(m, l, 0 == -1) ? le : ls) : me;
} else if (online(l, m, 1) == -1) { /* me between ls and le */
pt1 = me;
- pt2 =
- (online(l, m, 0) ==
- -1) ? ((online(m, l, 0) == -1) ? le : ls) : ms;
+ pt2 = online(l, m, 0) == -1 ? (online(m, l, 0) == -1 ? le : ls) : ms;
} else {
/* may be degenerate? */
if (online(m, l, 0) != -1)
*y = me.y;
}
} /* end switch */
- return (1);
+ return 1;
}
/*detect whether lines l and m intersect */
sgnarea(m, l, i);
if (i[2] > 0)
return;
- if (!intpoint
- (l, m, &x, &y, (i[2] < 0) ? 3 : online(m, l, abs(i[0]))))
+ if (!intpoint(l, m, &x, &y, i[2] < 0 ? 3 : online(m, l, abs(i[0]))))
return;
}
- else if (!intpoint(l, m, &x, &y, (i[0] == i[1]) ?
- 2 * MAX(online(l, m, 0),
+ else if (!intpoint(l, m, &x, &y, i[0] == i[1] ? 2 * MAX(online(l, m, 0),
online(l, m, 1)) : online(l, m, abs(i[0]))))
return;