ComputationalGeometry
SegmentsIntersect
determine if two line segments intersect
Calling Sequence
Parameters
Description
Examples
Compatibility
SegmentsIntersect( L1, L2 )
SegmentsIntersect( L1, L2, intersection )
SegmentsIntersect( M, locs )
SegmentsIntersect( M, locs, intersection )
L1, L2
-
line segments given as pairs of points in 2-D space
M
an array of point coordinates in 2-D space. Each point is a row in the array. M must be C_order and datatype=float[8]
locs
positive integer indices of the three rows of M to treat as input the first location is the point and the other two the ends of the segment
This command returns true if the two line segments intersect and false if they do not. It does so using four calls to PointOrientation.
If the intersection option is given and the segments do not intersect false will be returned, otherwise the coordinate of the intersection will be returned.
If one segment is completely contained within the other, the list of endpoints of the smaller segment will be returned.
with⁡ComputationalGeometry:
SegmentsIntersect⁡0,0,1,1,0,1,1,0
true
L≔1,0,1,5:
K≔1,−2,1,−1,0,1,0,3,2,1,2,3,1,6.5,1,8,1,6,1.5,8,0.5,4,1.5,7,0.5,0.5,1,−0.75,1,5,1.5,6,1,4.5,1.5,5,0.5,3.75,1.5,3.5,1,2.5,1,3.5,0.5,1.5,1,2,1,0,1.5,−2,1,0.5,1,−0.5:
plots:-display⁡plottools:-line⁡L,legend=L,color=Red,seq⁡plottools:-line⁡Ki,legend=K ‖i,color=Blue,i=1..7,seq⁡plottools:-line⁡Ki,legend=K ‖i,color=Green,i=8..14,axes=boxed
None of the blue segments intersect L
seq⁡SegmentsIntersect⁡L,Ki,i=1..7
false
All of the green segments intersect L
seq⁡SegmentsIntersect⁡L,Ki,i=8..14
M≔Array⁡L,seq⁡k,kinK,datatype=float8,order=C_order
SegmentsIntersect⁡M,1,2,3,4,intersection
SegmentsIntersect⁡M,1,2,25,26,intersection
1.2.
Line 11, completely contained in L
SegmentsIntersect⁡M,1,2,23,24,intersection
1.2.50000000000000,1.3.50000000000000
Line 14, partially overlaps L
SegmentsIntersect⁡M,1,2,29,30,intersection
1.0.,1.0.500000000000000
The ComputationalGeometry[SegmentsIntersect] command was introduced in Maple 2019.
For more information on Maple 2019 changes, see Updates in Maple 2019.
See Also
ComputationalGeometry[PointOrientation]
Download Help Document