Description Usage Arguments Value Examples
Voxel cloud visualization.
1 | plot_voxels(data, res, type, lcol, fcol, lwd, alpha, plot, message)
|
data |
a data.frame or data.table containing at least the voxel cloud x, y, z coordinates. |
res |
numeric. The voxel resolution. If not provided, the function will guess it. |
type |
character. How to represent a voxel ? If "w" only the voxel hedges are plotted, if "p" plain voxels are plotted, if "b" both hedges and plain voxels are plotted. Default = "b". |
lcol |
the line color for |
fcol |
the facets color for |
lwd |
numeric. The line width for |
alpha |
numeric. The transparency of the voxel faces for |
plot |
logical. Plot the voxels ? See return for mesh capture. Default = TRUE. |
message |
logical. Removes the message from the resolution guessing. Default = FALSE. |
If plot = TRUE
, the 3D plot of voxels is plotted. At anytime the mesh object that enables
to plot the voxels can be captured and to be plotted using the
shade3d
function from rgl.
The returned object is a list containing the 3D mesh of the voxel cloud and all additionnal fields
of the input data.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #- import tls data
tls=data.table::fread(system.file("extdata", "Tree_t0.asc", package="VoxR"))
#- voxelisation
voxels = VoxR::vox(tls,res=0.05)
#- plot the voxels
VoxR::plot_voxels(voxels)
#- capture the voxels mesh to plot with color scale
###- number of points in the voxel
voxels_mesh = VoxR::plot_voxels(voxels,plot = FALSE) # capture the mesh
colors=rev(rainbow(max(voxels_mesh$additionnal$npts),end=4/6)) # color scale
rgl::open3d()
rgl::shade3d(voxels_mesh$mesh,col=colors[round(voxels_mesh$additionnal$npts)]
,lit=FALSE,alpha=0.5) # plot
###- distance from the crow center
# compute distnce
voxels[,distance:=round(VoxR::point_distance(voxels[,1:3],c(mean(x),mean(y),mean(z)))*100)]
voxels_mesh = VoxR::plot_voxels(voxels,plot = FALSE) # capture mesh
cols=rev(rainbow(max(voxels_mesh$additionnal$distance),end=4/6)) # color scale
rgl::open3d()
rgl::shade3d(voxels_mesh$mesh,col=cols[round(voxels_mesh$additionnal$distance)]
,lit=FALSE,alpha=0.5) # plot
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.