If points are collinear it is possible to ask whether they are ordered along the common line. This function is not strict, i.e. it is possible for the middle point to coincide with either the first or last point and still be regarded as ordered between them. This functionality comes in two versions, one that access orderedness between three vectors of points and one that assess it along a single vector. Note that for the later version the return value is 2 elements shorter than the input vector.

in_order(x, y, z)

in_order_along(x)

Arguments

x, y, z

Vectors of points

Value

A logical vector

Examples

p <- point(1:30, 1:30)
p <- p[sample(30)]

in_order(p[1:10], p[11:20], p[21:30])
#>  [1] FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

in_order_along(p)
#>  [1] FALSE  TRUE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE
#> [13] FALSE FALSE  TRUE  TRUE FALSE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE
#> [25]  TRUE FALSE FALSE FALSE