98 inside1 = (p.
x >= b.
LL.
x) && (p.
x <= b.
UR.
x)
99 && (p.
y >= b.
LL.
y) && (p.
y <= b.
UR.
y);
100 inside2 = (q.
x >= b.
LL.
x) && (q.
x <= b.
UR.
x)
101 && (q.
y >= b.
LL.
y) && (q.
y <= b.
UR.
y);
102 if (inside1 != inside2) {
105 if (inside1 & inside2) {
121 if (((p.
y >= b.
LL.
y) ^ (q.
y >= b.
LL.
y))
123 && (p.
x <= b.
UR.
x)) {
126 }
else if (p.
y == q.
y) {
130 if (((p.
x >= b.
LL.
x) ^ (q.
x >= b.
LL.
x))
132 && (p.
y <= b.
UR.
y)) {
136 double m, x, y, low, high;
144 m = (q.
y - p.
y)/(q.
x - p.
x);
146 low = p.
x; high = q.
x;
148 low = q.
x; high = p.
x;
155 y = p.
y + (b.
LL.
x - p.
x)*m;
156 if ((b.
LL.
x >= low) && (b.
LL.
x <= high)
157 && (y >= b.
LL.
y) && (y <= b.
UR.
y)) {
166 if ((y >= b.
LL.
y) && (y <= b.
UR.
y)
167 && (b.
UR.
x >= low) && (b.
UR.
x <= high)) {
176 low = p.
y; high = q.
y;
178 low = q.
y; high = p.
y;
180 x = p.
x + (b.
LL.
y - p.
y)/m;
181 if ((x >= b.
LL.
x) && (x <= b.
UR.
x)
182 && (b.
LL.
y >= low) && (b.
LL.
y <= high)) {
191 if ((x >= b.
LL.
x) && (x <= b.
UR.
x)
192 && (b.
UR.
y >= low) && (b.
UR.
y <= high)) {
203 p[3].
x = p[2].
x = p[1].
x;
211 static double sina, cosa;
212 static int last_cwrot;
217 if (cwrot != last_cwrot) {
221 P.
x = p.
x * cosa - p.
y * sina;
222 P.
y = p.
y * cosa + p.
x * sina;
231 pf = rotatepf(pf, cwrot);
238 int x = p.
x, y = p.
y;
259 return rotatep(p, cwrot);
266 double x = p.
x, y = p.
y;
287 return rotatepf(p, cwrot);
294 int x = p.
x, y = p.
y;
315 return rotatep(p, 360-ccwrot);
322 double x = p.
x, y = p.
y;
343 return rotatepf(p, 360-ccwrot);
385 #define SMALL 0.0000000001
394 double a2 = (p.
y-a.
y)*dx - (p.
x-a.
x)*dy;
396 if (a2 <
SMALL)
return 0.;
397 return a2 / (dx*dx + dy*dy);
400 #define dot(v,w) (v.x*w.x+v.y*w.y)
410 pointf mv = sub_pointf(b,a);
411 pointf lv = sub_pointf(d,c);
413 double lc = -
dot(ln,c);
414 double dt =
dot(ln,mv);
416 if (fabs(dt) <
SMALL)
return 0;
418 *p = sub_pointf(a,scale((
dot(ln,a)+lc)/dt,mv));
box flip_rec_box(box b, point p)
pointf cwrotatepf(pointf p, int cwrot)
boxf flip_rec_boxf(boxf b, pointf p)
int lineToBox(pointf p, pointf q, boxf b)
pointf ccwrotatepf(pointf p, int ccwrot)
point cwrotatep(point p, int cwrot)
void rect2poly(pointf *p)
boxf mkboxf(pointf p, pointf q)
int line_intersect(pointf a, pointf b, pointf c, pointf d, pointf *p)
point ccwrotatep(point p, int ccwrot)
void(* pf)(char *, void *)
box mkbox(point p, point q)
double ptToLine2(pointf a, pointf b, pointf p)