runif_in_tetrahedron | R Documentation |
Uniform sampling in a tetrahedron (in dimension 3).
runif_in_tetrahedron(n, v1, v2, v3, v4)
n |
number of simulations |
v1, v2, v3, v4 |
vertices of the tetrahedron |
The simulations in a n
times 3
matrix.
runif_in_simplex
for sampling in a simplex in
arbitrary dimension.
library(rgl)
tetrahedron <- tetrahedron3d()
shade3d(tetrahedron, color = "red", alpha = 0.3)
vs <- tetrahedron$vb[1L:3L, ]
sims <- runif_in_tetrahedron(100, vs[, 1], vs[, 2], vs[, 3], vs[, 4])
points3d(sims)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.