plot_voxels: Voxel cloud visualization.

Description Usage Arguments Value Examples

View source: R/plot_voxels.R

Description

Voxel cloud visualization.

Usage

1
plot_voxels(data, res, type, lcol, fcol, lwd, alpha, plot, message)

Arguments

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 type = "w" or "b".

fcol

the facets color for type = "p" or "b".

lwd

numeric. The line width for type = "w" or "b".

alpha

numeric. The transparency of the voxel faces for type = "p" or "b".

plot

logical. Plot the voxels ? See return for mesh capture. Default = TRUE.

message

logical. Removes the message from the resolution guessing. Default = FALSE.

Value

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.

Examples

 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

Example output

Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl.init' failed, running with 'rgl.useNULL = TRUE'. 
null 
   2 
null 
   3 

VoxR documentation built on Nov. 16, 2020, 9:14 a.m.