Learn R Programming

uniformly (version 0.5.0)

runif_in_hexahedron: Uniform sampling in a hexahedron

Description

Uniform sampling in a hexahedron (polyhedron with six faces).

Usage

runif_in_hexahedron(n, hexahedron)

Value

The simulations in a n times 3 matrix.

Arguments

n

number of simulations

hexahedron

a hexahedron given by a 3 times 8 matrix whose eight columns are the vertices; see makeHexahedron

Examples

Run this code
library(uniformly)
hexahedron <- makeHexahedron(
  p0 = c(0, 0, 0),
  p1 = c(2, 0, 0),
  p2 = c(2, 2, 0),
  p3 = c(0, 2, 0),
  p4 = c(0.5, 1.5, 2),
  p5 = c(0.5, 0.5, 2),
  p6 = c(1.5, 0.5, 2),
  p7 = c(1.5, 1.5, 2)
)
sims <- runif_in_hexahedron(200, hexahedron)
plotHexahedron(hexahedron, alpha = 0.3)
rgl::points3d(sims)

Run the code above in your browser using DataLab