orderPoints: Order Points Clockwise or Counter-Clockwise

Description Usage Arguments Examples

View source: R/orderPoints.R

Description

Returns the indexes of supplied points, x and y, ordered either clockwise or anticlockwise about another point, which by default is taken to be the non-weighted midpoint of the supplied data

Usage

1
2
orderPoints(x, y, ..., xm = mean(range(x)), ym = mean(range(y)),
  clockwise = TRUE)

Arguments

x

numeric vector of x values

y

numeric vector of y values of same length as x

...

not used

xm

the x value of the reference point

ym

the y value of the reference point

clockwise

order in clockwise or anticlockwise manner

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#Generate a random set of points and put them clockwise order
set.seed(1)
x  = runif(100)
y  = runif(100)
op    = orderPoints(x,y)

#To demonstrate, Lets view the points in order
library(ggplot2)
df    = data.frame(x,y)
df    = df[op,];
df$id = 1:nrow(df)
ggplot(data=df,aes(x,y,colour=id)) +
    geom_path() + geom_point() +
    scale_colour_gradient(low="green",high="red")

Example output

Loading required package: geometry
Loading required package: magic
Loading required package: abind

contoureR documentation built on May 2, 2019, 12:08 p.m.