Skip to main content
100%

Circle-Polygon Intersection

✓ Published0🌍 Public
Mmbostock
Last edited Feb 9, 2016
Created on Dec 5, 2012

A red circle and a black polygon are displayed on an SVG canvas, and the circle changes from red to green when the polygon intersects it. The polygon’s vertices are draggable control points; dragging them updates the polygon’s path and recomputes the intersection state. It uses D3 v3’s `d3.behavior.drag`, along with custom geometric functions (`pointInPolygon`, `pointLineSegmentDistance`) to test whether the circle’s center or any edge of the circle is inside the polygon or within its radius.

AI-generated description

Drag the control points of the polygon to see whether the polygon intersects with the circle.

gpl-3.0 Licensed

Similar vizzes