polygon_grid: Polygon grid

Description Usage Arguments Details Value Examples

View source: R/polygon_grid.R

Description

Create a grid of points within a polygon (DON'T USE – doesn't work correctly. See plot in examples.)

Usage

1
polygon_grid(N, NV, vertices)

Arguments

N

The number of subintervals each side should be divided into i.e. there are (N+1) points on a side.

NV

The number of vertices in the polygon.

vertices

A vector of length 2.NV giving the (x,y) coordinates of each vertex of the polygon or a matrix with two rows and 2.NV columns of vertex coordinates.

Details

Code taken from https://people.sc.fsu.edu/~jburkardt/cpp_src/polygon_grid/polygon_grid.html.

Value

Returns a matrix with the x and y positions of each point in the grid.

Examples

1
2
3
4
5
6
v = cbind( c(0, 0.5), c(0.5,0), c(1,1), c(1.5,0),c(2,0.5))
par(mfrow=c(1,3))
for(i in 1:3){
  pts = polygon_grid(10, ncol(v)-i+1, c(v[, seq(ncol(v)-i+1)]))
  plot(pts, main=bquote(.(i)~ "vertices")) 
}

daffp/shapegrid documentation built on Aug. 2, 2020, 12:49 a.m.