calculates and visualises distances between surface meshes or 3D coordinates and a surface mesh.
meshDist(x, ...)# S3 method for mesh3d
meshDist(
x,
mesh2 = NULL,
distvec = NULL,
from = NULL,
to = NULL,
steps = 20,
ceiling = FALSE,
rampcolors = colorRamps::blue2green2red(steps - 1),
NAcol = "white",
file = "default",
imagedim = "100x800",
uprange = 1,
ray = FALSE,
raytol = 50,
raystrict = FALSE,
save = FALSE,
plot = TRUE,
sign = TRUE,
tol = NULL,
tolcol = "green",
displace = FALSE,
shade = TRUE,
method = c("vcglib", "morpho"),
add = FALSE,
scaleramp = TRUE,
threads = 1,
titleplot = "Distance in mm",
...
)
# S3 method for matrix
meshDist(
x,
mesh2 = NULL,
distvec = NULL,
from = NULL,
to = NULL,
steps = 20,
ceiling = FALSE,
rampcolors = colorRamps::blue2green2red(steps - 1),
NAcol = "white",
uprange = 1,
plot = TRUE,
sign = TRUE,
tol = NULL,
tolcol = "green",
type = c("s", "p"),
radius = NULL,
displace = FALSE,
add = FALSE,
scaleramp = FALSE,
titleplot = "Distance in mm",
...
)
Returns an object of class "meshDist" if the input is a surface mesh and one of class "matrixDist" if input is a matrix containing 3D coordinates.
object of mesh3d with colors added
vector with distances
vector with color values
list of parameters used
reference mesh; object of class "mesh3d" or a n x 3 matrix containing 3D coordinates.
additional arguments passed to shade3d
. See
material3d
for details.
target mesh: either object of class "mesh3d" or a character pointing to a surface mesh (ply, obj or stl file)
vector: optional, a vector containing distances for each
vertex/coordinate of x
, if distvec != NULL, mesh2
will be ignored.
numeric: minimum distance to be colorised; default is set to 0 mm
numeric: maximum distance to be colorised; default is set to the maximum distance
integer: determines break points for color ramp: n steps will produce n-1 colors.
logical: if TRUE, the next larger integer of "to" is used
character vector: specify the colors which are used to create a colorramp.
character: specify color for values outside the range defined by from
and to
.
character: filename for mesh and image files produced. E.g. "mydist" will produce the files mydist.ply and mydist.png
character of type 100x200 where 100 determines the width and 200 the height of the image.
numeric between 0 and 1: restricts "to" to a quantile of "to", if to is NULL.
logical: if TRUE, the search is along vertex normals.
maximum distance to follow a normal.
logical: if TRUE, only outward along normals will be sought for closest points.
logical: save a colored mesh.
logical: visualise result as 3D-plot and distance charts
logical: request signed distances. Only meaningful, if mesh2 is specified or distvec contains signed distances.
numeric: threshold to color distances within this threshold green.
a custom color to color vertices below a threshold defined by tol
. Default is green.
logical: if TRUE, displacement vectors between original and closest points are drawn colored according to the distance.
logical: if FALSE, the rendering of the colored surface will be supressed.
accepts: "vcglib" and "morpho" (and any abbreviation). vcglib uses a command line tool using vcglib headers, morpho uses fortran routines based on a kd-tree search for closest triangles.
logical: if TRUE, visualization will be added to the rgl window currently in focus
logical: if TRUE, the colorramp will be symmetrical for signed distances: spanning from -max(from,to)
to max(from,to)
.
integer: number of threads to use. 0 = let system decide.
character: axis description of heatmap.
character: "s" shows coordinates as spheres, while "p" shows 3D dots.
determines size of spheres; if not specified, optimal radius size will be estimated by centroid size of the configuration.
Stefan Schlager
calculates the distances from a mesh or a set of 3D coordinates to another at each vertex; either closest point or along the normals
Detection of inside/outside uses the algorithm proposed in:
Baerentzen, Jakob Andreas. & Aanaes, H., 2002. Generating Signed Distance Fields From Triangle Meshes. Informatics and Mathematical Modelling, .
render.meshDist
, , export.meshDist
,
shade3d
data(nose)##load data
##warp a mesh onto another landmark configuration:
longnose.mesh <- tps3d(shortnose.mesh, shortnose.lm, longnose.lm,threads=1)
if (FALSE) {
mD <- meshDist(longnose.mesh, shortnose.mesh)
##now change the color ramp
render(mD,rampcolors = c("white","red"))
}
#use unsigned distances and a ramp from blue to red
#color distances < 0.01 green:
if (FALSE) {
meshDist(longnose.mesh, shortnose.mesh, rampcolors = c("blue", "red"),sign=FALSE, tol=0.5)
}
Run the code above in your browser using DataLab