3 ms·
The brain solves it by noticing where two solid polygons overlap. In that sense, you could also find the collision by rasterizing both shapes and testing whethe
by Jasper_ 3y ago
The brain solves it by noticing where two solid polygons overlap. In that sense, you could also find the collision by rasterizing both shapes and testing whether any pixels overlap, but that's going to be slower and less precise than an algorithmic version.
With just an algebraic version of two polygons, your brain can't solve it as easily.
- akoboldfrying 3y agoActually, your "pixel overlap" method can be developed into a technique that is pretty efficient, provided we have (a) a quick way to partition any polygon into 2 roughly equal-size polygons and (b) a quick way to come up with a "covering disk" for any polygon (that is, a circle that contains the polygon, and doesn't extend too much further): isColliding(poly P, poly Q): if dist(P.circle.centre, Q.circle.centre) > P.circle.radius + Q.circle.radius: return false if P.circle.radius > THRESH: (P1, P2) = subdivide(P) return isColliding(P1, Q) || isColliding(P2, Q) if Q.circle.radius > THRESH: (Q1, Q2) = subdivide(Q) return isColliding(P, Q1) || isColliding(P, Q2) // Both P and Q are "small" return detectOverlapByRasterising(P, Q)