static cpBool cpSegmentShapePointQuery(cpShape *shape, cpVect p){ if(!cpBBcontainsVect(shape->bb, p)) return cpFalse; cpSegmentShape *seg = (cpSegmentShape *)shape; // Calculate normal distance from segment. cpFloat dn = cpvdot(seg->tn, p) - cpvdot(seg->ta, seg->tn); cpFloat dist = cpfabs(dn) - seg->r; if(dist > 0.0f) return cpFalse; // Calculate tangential distance along segment. cpFloat dt = -cpvcross(seg->tn, p); cpFloat dtMin = -cpvcross(seg->tn, seg->ta); cpFloat dtMax = -cpvcross(seg->tn, seg->tb); // Decision tree to decide which feature of the segment to collide with. if(dt <= dtMin){ if(dt < (dtMin - seg->r)){ return cpFalse; } else { return cpvlengthsq(cpvsub(seg->ta, p)) < (seg->r*seg->r); } } else { if(dt < dtMax){ return cpTrue; } else { if(dt < (dtMax + seg->r)) { return cpvlengthsq(cpvsub(seg->tb, p)) < (seg->r*seg->r); } else { return cpFalse; } } } return cpTrue; }
int bmx_cpbb_containsvect(cpBB * bb, cpVect * v) { return cpBBcontainsVect(*bb, *v); }
static int cpPolyShapePointQuery(cpShape *shape, cpVect p){ return cpBBcontainsVect(shape->bb, p) && cpPolyShapeContainsVert((cpPolyShape *)shape, p); }
static VALUE rb_cpBBcontainsVect(VALUE self, VALUE other) { int value = cpBBcontainsVect(*BBGET(self), *VGET(other)); return value ? Qtrue : Qfalse; }