segmentBoxContains
Checks whether a point is inside the bounding box of a line segment.
Basic example
Section titled “Basic example”Tests whether a point falls within the axis-aligned bounding box of a segment (dashed), not whether it lies on the segment itself. segmentsIntersect combines this with lineIntersection to confirm that a crossing point is actually on both segments.
import {segmentBoxContains} from "@d3plus/math";
segmentBoxContains([40, 40], [200, 160], [100, 120]);
segmentBoxContains([40, 40], [200, 160], [220, 100]);
Parameters
import {segmentBoxContains} from "@d3plus/math";
s1requiredPointThe first point of the line segment to be used for the bounding box, which should always be an
[x, y]formatted Array.s2requiredPointThe second point of the line segment to be used for the bounding box, which should always be an
[x, y]formatted Array.prequiredPointThe point to be checked, which should always be an
[x, y]formatted Array.