Learn R Programming

MeshesTools (version 1.0.0)

distancesToMesh: Distance to a mesh

Description

Computes the distances from given points to a mesh.

Usage

distancesToMesh(mesh, points)

Value

A numeric vector providing the distances between the given point(s) to the mesh.

Arguments

mesh

a mesh given either as a list containing (at least) the fields vertices and faces, otherwise a rgl mesh (i.e. a mesh3d object)

points

either one point given as a numeric vector or several points given as a numeric matrix with three columns

Examples

Run this code
# cube example ####
library(MeshesTools)
mesh <- rgl::cube3d()
points <- rbind(
  c(0, 0, 0),
  c(1, 1, 1)
)
distancesToMesh(mesh, points) # should be 1 and 0

# cyclide example ####
library(MeshesTools)
a <- 100; c <- 30; mu <- 80
mesh <- cyclideMesh(a, c, mu, nu = 100L, nv = 100L)
O2 <- c(c, 0, 0)
# should be a - mu = 20 (see ?cyclideMesh):
distancesToMesh(mesh, O2)

Run the code above in your browser using DataLab