Learn R Programming

MeshesOperations (version 0.1.0)

sampleOnMesh: Sampling on a mesh

Description

Uniformly samples points on a mesh.

Usage

sampleOnMesh(n, mesh)

Value

The simulated points on a matrix with three columns.

Arguments

n

number of simulations, a positive integer

mesh

either a list containing (at least) two fields vertices (numeric matrix with three columns) and faces (integer matrix or list of integer vectors), otherwise a rgl mesh (i.e. a mesh3d object)

Examples

Run this code
library(MeshesOperations)
library(rgl)
mesh <- torusMesh(R = 4, r = 2)
sims <- sampleOnMesh(200, mesh)
open3d(windowRect = c(50, 50, 562, 562))
view3d(0, 0, zoom = 0.75)
shade3d(mesh, color = "yellow")
points3d(sims, size = 5)

Run the code above in your browser using DataLab