PointOnSegment - Maple Help

ComputationalGeometry

 PointOnSegment
 determine if a point lies on a line segment

 Calling Sequence PointOnSegment( P, L ) PointOnSegment( M, locs )

Parameters

 P - a point in real 2-D space given as a list or rtable of coordinates L - a list of a pair of points giving the ends of the line segment 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

Description

 • This command returns true if the point lies on the line segment and false if it does not.  It first checks if they are collinear using PointOrientation and then checks if the point in within the bounding box given by the endpoints of the line segment.

Examples

 > $\mathrm{with}\left(\mathrm{ComputationalGeometry}\right):$
 > $a≔\left[0,0\right];$$b≔\left[1,1\right];$$c≔\left[0.4,0.4\right];$$d≔\left[1.1,1.1\right];$$e≔\left[0.5,0.55\right]$
 ${a}{≔}\left[{0}{,}{0}\right]$
 ${b}{≔}\left[{1}{,}{1}\right]$
 ${c}{≔}\left[{0.4}{,}{0.4}\right]$
 ${d}{≔}\left[{1.1}{,}{1.1}\right]$
 ${e}{≔}\left[{0.5}{,}{0.55}\right]$ (1)
 > \mathrm{plots}:-\mathrm{display}\left(\mathrm{plottools}:-\mathrm{point}\left(\left[a,b,c,d,e\right],\mathrm{symbolsize}=20\right),\mathrm{plots}:-\mathrm{textplot}\left(\left[c\left[\right],"c"\right],\mathrm{align}=\left["above","left"\right]\right),\mathrm{plots}:-\mathrm{textplot}\left(\left[d\left[\right],"d"\right],\mathrm{align}=\left["below","left"\right]\right),\mathrm{plots}:-\mathrm{textplot}\left(\left[e\left[\right],"e"\right],\mathrm{align}=\left["above","left"\right]\right),\mathrm{plottools}:-\mathrm{line}\left(a,b\right),\mathrm{axes}=\mathrm{box}\right)
 > $\mathrm{PointOnSegment}\left(c,\left[a,b\right]\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{PointOnSegment}\left(d,\left[a,b\right]\right)$
 ${\mathrm{false}}$ (3)
 > $\mathrm{PointOnSegment}\left(e,\left[a,b\right]\right)$
 ${\mathrm{false}}$ (4)
 > $M≔\mathrm{Array}\left(\left[a,b,c,d,e\right],\mathrm{datatype}=\mathrm{float}\left[8\right],\mathrm{order}=\mathrm{C_order}\right)$
 ${M}{≔}\left[\begin{array}{cc}{0.}& {0.}\\ {1.}& {1.}\\ {0.400000000000000}& {0.400000000000000}\\ {1.10000000000000}& {1.10000000000000}\\ {0.500000000000000}& {0.550000000000000}\end{array}\right]$ (5)
 > $\mathrm{PointOnSegment}\left(M,\left[3,1,2\right]\right)$
 ${\mathrm{true}}$ (6)
 > $\mathrm{PointOnSegment}\left(M,\left[5,1,2\right]\right)$
 ${\mathrm{false}}$ (7)

Compatibility

 • The ComputationalGeometry[PointOnSegment] command was introduced in Maple 2019.