axis_angle: Computes points angle with an axis (X, Y or Z) and the origin...

Description Usage Arguments Value Examples

View source: R/axis_angle.R

Description

Computes points angle with an axis (X, Y or Z) and the origin of the 3D cartesian coordinates system.

Usage

1

Arguments

data

a data.frame or data.table containing the x, y, z, ... coordinates of a point cloud or voxel cloud.

axis

charecter. Specifying the reference axis to compute the angles: "X", "Y" or "Z".

project

character. If specifyed the point cloud is projected into a 2D plan before computing the angles. Can be "xy", "yz" or "xz". Default is without projection.

message

logical. If FALSE, messages are disabled. Default = TRUE.

@references Lecigne, B., Delagrange, S., & Messier, C. (2018). Exploring trees in three dimensions: VoxR, a novel voxel-based R package dedicated to analysing the complex arrangement of tree crowns. Annals of botany, 121(4), 589-601.

Value

A vector containing the angle values of the points.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#- import tls data
tls=data.table::fread(system.file("extdata", "Tree_t0.asc", package="VoxR"))

#- compute angle with the Z axis
tls[,angle_z:=VoxR::axis_angle(tls,axis = "Z")]

#- compute angle with the X axis with projection in the xy plan
tls[,angle_x:=VoxR::axis_angle(tls,axis = "X",project = "xy")]

#- round angle values for visualization
tls[,angle_z:=round(angle_z)]
tls[,angle_x:=round(angle_x)]

#- plot the angle with Z axis
cols=rev(rainbow(max(tls$angle_z)+1,end=4/6)) # color scale
rgl::open3d()
rgl::plot3d(tls,col=cols[tls$angle_z+1],add=TRUE)

#- plot the angle with X axis
cols=rev(rainbow(max(tls$angle_x)+1,end=4/6)) # color scale
rgl::open3d()
rgl::plot3d(tls,col=cols[tls$angle_x+1],add=TRUE)

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