halton.lattice: Halton lattice inside a rectangle

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/halton.lattice.r

Description

Constructs a lattice of Halton boxes (a Halton lattice) inside a rectangular box.

Usage

1
2
3
4
5
6
7
8
halton.lattice(
  box = matrix(c(0, 0, 1, 1), 2),
  N = 10000,
  J = NULL,
  eta = rep(1, nrow(box)),
  triangular = FALSE,
  bases = NULL
)

Arguments

box

A DX2 matrix containing coordinates of the box. One row per dimension. Column 1 is the minimum, column 2 is the maximum. box[1,] contains c(min,max) coordinates of the box in dimension 1 (horizontal). box[2,] contains c(min,max) coordinates of the box in dimension 2 (vertical). Etc for higher dimensions. Default is the 2D unit box.

N

Approximate number of points to place in the whole box. If J is specified, it takes precedence. If J is NULL, the algorithm attempts to place N points in the bounding box using Halton boxes that are as close to square as possible. N is not exact, but is a target.

J

A DX1 vector of base powers which determines the size and shape of the Halton boxes. Elements of J less than or equal to 1 are re-set to 1. See additional description in help for hip.polygon function.

eta

A DX1 vector of the number of points to add inside each Halton box. e.g., if eta = c(3,2), a small grid of 3 by 2 points is added inside each Halton box. eta[1] is for the horizontal dimension, eta[2] is for the vertical dimension, etc for higher dimensions.

triangular

boolean, if TRUE, construct a triangular grid. If FALSE, construct rectangular grid. See help for hip.polygon.

bases

A DX1 vector of Halton bases. These must be co-prime.

Details

This is designed to be called with the bounding box of a spatial object. See examples.

Definition of Halton lattice: A Halton lattice has the same number of points in every Halton box. Halton boxes are the bases[1]^J[1] X bases[2]^J[2] matrix of rectangles over a square. Each Halton box contains prod(eta) points.

Value

A data frame containing coordinates in the Halton lattice. Names of the coordinates are dimnames(box)[1]. If box does not have dimnames, names of the coordinates are c("d1", "d2", ...) (d1 is horizontal, d2 is vertical, etc).

In addition, return has following attributes:

Author(s)

Trent McDonald

See Also

halton.lattice, hip.polygon

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Lattice of 2^3*3^2 = 72 points in unit box
hl <- halton.lattice( J=c(3,2) )

# Plot
hl.J <- attr(hl,"J")
hl.b <- attr(hl,"bases")
hl.bb <- attr(hl,"hl.bbox") 

plot( hl.bb[1,], hl.bb[2,], type="n", pty="s")
points( hl[,1], hl[,2], pch=16, cex=.75, col="red")

for(d in 1:ncol(hl)){
  tmp2 <- hl.bb[d,1] + (0:(hl.b[d]^hl.J[d]))*(diff(hl.bb[d,]))/(hl.b[d]^hl.J[d])
  if( d == 1){
      abline(v=tmp2)
  } else{
      abline(h=tmp2)
  }
}

# Lattice of approx 1000 points over bounding box of spatial object
hl <- halton.lattice( bbox(HI.coast), N=1000 )

SDraw documentation built on July 8, 2020, 6:23 p.m.