| smoothShape | R Documentation |
Smooths the overall shape of the mesh by using the mean curvature flow.
smoothShape( vertices, faces, mesh = NULL, time, iterations = 1, normals = FALSE )
vertices |
a numeric matrix with three columns |
faces |
either an integer matrix (each row provides the vertex indices of the corresponding face) or a list of integer vectors, each one providing the vertex indices of the corresponding face |
mesh |
if not |
time |
positive number, a time step that corresponds to the speed by
which the surface is smoothed (the larger the faster); typical values lie
between |
iterations |
number of iterations, a positive integer |
normals |
Boolean, whether to compute the vertex normals of the output mesh |
A triangle mesh represented as the output of the
Mesh function.
library(MeshesOperations)
library(rgl)
# parabola ####
x <- seq(-1, 1, length.out = 30)
parabola <- cylinder3d(cbind(x, x^2, 0), radius = 0.2, closed = -2)
vertices <- t(parabola$vb[-4L, ])
faces <- c(
split(t(parabola$it), 1L:ncol(parabola$it)),
split(t(parabola$ib), 1L:ncol(parabola$ib))
)
sparabola <- smoothShape(
vertices, faces, time = 0.0005, iterations = 10
)
sparabola <- toRGL(sparabola)
open3d(windowRect = c(50, 50, 950, 500))
mfrow3d(1, 2)
view3d(0, 0, zoom = 0.9)
shade3d(parabola, color = "orange")
wire3d(parabola)
next3d()
view3d(0, 0)
shade3d(sparabola, color = "green")
wire3d(sparabola)
# Stanford bunny (light version)
vf <- readMeshFile(
system.file("extdata", "bunny.off", package = "MeshesOperations")
)
mesh <- Mesh(
vf[["vertices"]], vf[["faces"]], normals = TRUE
)
rglmesh <- toRGL(mesh)
smesh <- smoothShape(
mesh = mesh,
time = 0.00001, iterations = 1, normals = TRUE
)
srglmesh <- toRGL(smesh)
open3d(windowRect = c(50, 50, 900, 500))
mfrow3d(1, 2)
view3d(0, 0, zoom = 0.8)
shade3d(rglmesh, color = "purple")
next3d()
view3d(0, 0, zoom = 0.8)
shade3d(srglmesh, color = "violetred")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.