void *IoMessage_locals_boxArgAt_(IoMessage *self, void *locals, int n) { IoObject *v = IoMessage_locals_valueArgAt_(self, locals, n); if (!ISBOX(v)) { IoMessage_locals_numberArgAt_errorForType_(self, locals, n, "Box"); } return v; }
int polyOverlap(Point p, Poly * pp, Point q, Poly * qp) { Point op, cp; Point oq, cq; /* translate bounding boxes */ addpt(&op, p, pp->origin); addpt(&cp, p, pp->corner); addpt(&oq, q, qp->origin); addpt(&cq, q, qp->corner); /* If bounding boxes don't overlap, done */ if (!pintersect(op, cp, oq, cq)) return 0; if (ISBOX(pp) && ISBOX(qp)) return 1; if (ISCIRCLE(pp) && ISCIRCLE(qp)) { double d = (pp->corner.x - pp->origin.x + qp->corner.x - qp->origin.x); double dx = p.x - q.x; double dy = p.y - q.y; if ((dx * dx + dy * dy) > (d * d) / 4.0) return 0; else return 1; } if (tp1 == NULL) { tp1 = N_GNEW(maxcnt, Point); tp2 = N_GNEW(maxcnt, Point); } transCopy(pp->verts, pp->nverts, p, tp1); transCopy(qp->verts, qp->nverts, q, tp2); return (edgesIntersect(tp1, tp2, pp->nverts, qp->nverts) || (inBox(*tp1, oq, cq) && inPoly(tp2, qp->nverts, *tp1)) || (inBox(*tp2, op, cp) && inPoly(tp1, pp->nverts, *tp2))); }