MinkowskiSum: Minkowski sum of two meshes

View source: R/MinkowskiSum.R

MinkowskiSumR Documentation

Minkowski sum of two meshes

Description

Returns the mesh defined as the Minkowski sum of the two input meshes.

Usage

MinkowskiSum(mesh1, mesh2, triangulate = TRUE, normals = FALSE)

Arguments

mesh1, mesh2

two meshes, each one given either as a list containing (at least) the 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)

triangulate

Boolean, whether to triangulate the output mesh (note that it is not necessarily triangle when the two input meshes are triangle)

normals

Boolean, whether to compute the vertex normals of the output mesh

Value

A mesh represented as the output of the Mesh function.

Examples

# example 1: octahedron + sphere
library(MeshesOperations)
library(rgl)
mesh1 <- octahedron3d()
mesh2 <- sphereMesh(iterations = 2L)
mesh <- MinkowskiSum(mesh1, mesh2, normals = TRUE)
rglmesh <- toRGL(mesh)
open3d(windowRect = c(50, 50, 562, 562))
view3d(30, 30, zoom = 0.8)
shade3d(rglmesh, color = "maroon")

# example2: truncated icosahedron + tetrahedron
library(MeshesOperations)
library(rgl)
# mesh 1
mesh1 <- truncatedIcosahedron
# mesh 2: regular tetrahedron
a <- 1 / sqrt(3)
vertices <- rbind(
		c( a, -a, -a),
		c( a,  a,  a),
		c(-a, -a,  a),
		c(-a,  a, -a)
)
faces <- rbind(
		c(1L, 2L, 3L),
		c(3L, 2L, 4L),
		c(4L, 2L, 1L),
		c(1L, 3L, 4L)
)
mesh2 <- list(vertices = vertices, faces = faces)
# sum
mesh <- MinkowskiSum(mesh1, mesh2, normals = FALSE)
# plot
rglmesh <- toRGL(mesh)
open3d(windowRect = c(50, 50, 562, 562))
view3d(30, 30, zoom = 0.8)
shade3d(rglmesh, color = "navy")
plotEdges(mesh[["vertices"]], mesh[["edges0"]], color = "yellow")

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