distancesToMesh: Distance to a mesh

View source: R/distances.R

distancesToMeshR Documentation

Distance to a mesh

Description

Computes the distances from given points to a mesh.

Usage

distancesToMesh(mesh, points)

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

Value

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

Examples

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

# cyclide example ####
library(MeshesOperations)
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)

stla/MeshesOperations documentation built on Oct. 23, 2022, 8:23 a.m.