 ComputationalGeometry - Maple Programming Help

Home : Support : Online Help : Mathematics : Geometry : Computational Geometry : ComputationalGeometry/PointOrientation

ComputationalGeometry

 PointOrientation
 determine the orientation of points accurately

 Calling Sequence PointOrientation( P1, P2, P3 ) PointOrientation( P1, P2, P3, P4 ) PointOrientation( A, pos )

Parameters

 Pn - three points in real 2-D or four points in real 3-D space given as lists or rtables of their coordinates A - an array of point coordinates in 2-D or 3-D space. Each point is a row in the array. A must be C_order and datatype=float pos - positive integer indices of the three or four rows of A to treat as input

Description

 • This command returns a string describing the orientation of the points.
 • In dimension two, if the third point is on the left side of the ray starting at the first point and going through the second point then the points are in counterclockwise orientation and the command returns "ccw". If the third point is on the right then "cw" is returned. If the three points are on a line then "degenerate" is returned.
 • The check is done by carefully computing the signed area of the triangle formed by the three points.
 • In dimension three, the command returns "ccw" if the fourth point is below the plane defined by the first three and "cw" if it is above (using a right-hand rule for plane orientation).  If the first three points are on a line, or the fourth point lies on the plane, then "degenerate" is returned.
 • The last calling sequence is designed for checking large collections of points without having to make copies of their values.

Examples

 > $\mathrm{with}\left(\mathrm{ComputationalGeometry}\right):$
 > $a≔\left[0,0\right];$$b≔\left[1,1\right];$$c≔\left[0.4,0.8\right];$$d≔\left[0.8,0.4\right];$$e≔\left[0.5,0.5\right]$
 ${a}{≔}\left[{0}{,}{0}\right]$
 ${b}{≔}\left[{1}{,}{1}\right]$
 ${c}{≔}\left[{0.4}{,}{0.8}\right]$
 ${d}{≔}\left[{0.8}{,}{0.4}\right]$
 ${e}{≔}\left[{0.5}{,}{0.5}\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","right"\right]\right),\mathrm{plots}:-\mathrm{textplot}\left(\left[e\left[\right],"e"\right],\mathrm{align}=\left["above","left"\right]\right),\mathrm{plottools}:-\mathrm{arrow}\left(a,b,0.001,0.025,0.05\right),\mathrm{axes}=\mathrm{box}\right) > $\mathrm{PointOrientation}\left(a,b,c\right)$
 ${"ccw"}$ (2)
 > $\mathrm{PointOrientation}\left(a,b,d\right)$
 ${"cw"}$ (3)
 > $\mathrm{PointOrientation}\left(a,b,e\right)$
 ${"degenerate"}$ (4)
 > $A≔\mathrm{Array}\left(\left[a,b,c,d,e\right],\mathrm{datatype}=\mathrm{float}\left[8\right],\mathrm{order}=\mathrm{C_order}\right)$
 ${A}{≔}\left[\begin{array}{cc}{0.}& {0.}\\ {1.}& {1.}\\ {0.400000000000000}& {0.800000000000000}\\ {0.800000000000000}& {0.400000000000000}\\ {0.500000000000000}& {0.500000000000000}\end{array}\right]$ (5)
 > $\mathrm{PointOrientation}\left(A,\left[1,2,5\right]\right)$
 ${"degenerate"}$ (6)

Points in three dimensions

 > $a≔\left[0,0,0\right];$$b≔\left[1,1,0\right];$$c≔\left[0.4,0.8,0\right]$
 ${a}{≔}\left[{0}{,}{0}{,}{0}\right]$
 ${b}{≔}\left[{1}{,}{1}{,}{0}\right]$
 ${c}{≔}\left[{0.4}{,}{0.8}{,}{0}\right]$ (7)
 > $d≔\left[0.8,0.4,-1\right];$$e≔\left[0.5,0.5,1\right];$$f≔\left[0.5,0.5,0\right]$
 ${d}{≔}\left[{0.8}{,}{0.4}{,}{-1}\right]$
 ${e}{≔}\left[{0.5}{,}{0.5}{,}{1}\right]$
 ${f}{≔}\left[{0.5}{,}{0.5}{,}{0}\right]$ (8)
 > \mathrm{plots}:-\mathrm{display}\left(\mathrm{plottools}:-\mathrm{point}\left(\left[a,b,c,d,e,f\right],\mathrm{symbolsize}=20\right),\mathrm{plots}:-\mathrm{textplot}\left(\left\{\left[a\left[\right],"a"\right],\left[b\left[\right],"b"\right],\left[c\left[\right],"c"\right],\left[d\left[\right],"d"\right],\left[e\left[\right],"e"\right],\left[f\left[\right],"f"\right]\right\},\mathrm{dimension}=3,\mathrm{align}=\left["left","above"\right]\right),\mathrm{plottools}:-\mathrm{polygon}\left(\left[\left[-0.1,-0.1,0\right],\left[1.1,-0.1,0\right],\left[1.1,1.1,0\right],\left[-0.1,1.1,0\right]\right],\mathrm{color}="Green"\right),\mathrm{plots}:-\mathrm{arrow}\left(a,\left[0,0,0.4\right]\right),\mathrm{axes}=\mathrm{box}\right) > $\mathrm{PointOrientation}\left(a,b,c,d\right)$
 ${"ccw"}$ (9)
 > $\mathrm{PointOrientation}\left(a,b,c,e\right)$
 ${"cw"}$ (10)
 > $\mathrm{PointOrientation}\left(a,b,c,f\right)$
 ${"degenerate"}$ (11)
 > $\mathrm{PointOrientation}\left(a,b,f,e\right)$
 ${"degenerate"}$ (12)

Compatibility

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