54 bool inside1 =
INSIDE(p, b);
55 bool inside2 =
INSIDE(q, b);
56 if (inside1 != inside2) {
59 if (inside1 && inside2) {
75 }
else if (p.
y == q.
y) {
89 m = (q.
y - p.
y)/(q.
x - p.
x);
90 double low = fmin(p.
x, q.
x);
91 double high = fmax(p.
x, q.
x);
94 y = p.
y + (b.
LL.
x - p.
x)*m;
106 low = fmin(p.
y, q.
y);
107 high = fmax(p.
y, q.
y);
108 x = p.
x + (b.
LL.
y - p.
y)/m;
124 p[3].
x = p[2].
x = p[1].
x;
132 assert(cwrot == 0 || cwrot == 90 || cwrot == 180 || cwrot == 270);
137 return (
pointf){.x = p.
y, .y = -p.
x};
139 return (
pointf){.x = p.
x, .y = -p.
y};
150 assert(ccwrot == 0 || ccwrot == 90 || ccwrot == 180 || ccwrot == 270);
157 return (
pointf){.x = p.
x, .y = -p.
y};
176#define SMALL 0.0000000001
185 double a2 = (p.
y-a.
y)*
dx - (p.
x-a.
x)*
dy;
187 if (a2 <
SMALL)
return 0.;
191#define dot(v,w) (v.x*w.x+v.y*w.y)
204 double lc = -
dot(ln,c);
205 double dt =
dot(ln,mv);
207 if (fabs(dt) <
SMALL)
return 0;
int lineToBox(pointf p, pointf q, boxf b)
boxf flip_rec_boxf(boxf b, pointf p)
void rect2poly(pointf *p)
pointf ccwrotatepf(pointf p, int ccwrot)
double ptToLine2(pointf a, pointf b, pointf p)
pointf cwrotatepf(pointf p, int cwrot)
int line_intersect(pointf a, pointf b, pointf c, pointf d, pointf *p)
geometric types and macros (e.g. points and boxes)
geometric functions (e.g. on points and boxes)
static pointf add_pointf(pointf p, pointf q)
static pointf sub_pointf(pointf p, pointf q)
static pointf scale(double c, pointf p)
static pointf exch_xyf(pointf p)
static pointf perp(pointf p)