Skip to content

segmentBoxContains

Checks whether a point is inside the bounding box of a line segment.

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";
s1requiredPoint

The first point of the line segment to be used for the bounding box, which should always be an [x, y] formatted Array.

s2requiredPoint

The second point of the line segment to be used for the bounding box, which should always be an [x, y] formatted Array.

prequiredPoint

The point to be checked, which should always be an [x, y] formatted Array.