lines_interception: Intersection of Lines by AABBs

Description Usage Arguments Value Author(s) See Also Examples

View source: R/lines_interception.R

Description

Intersection of lines by several Axis-Aligned Bounding Boxs.

Usage

1
lines_interception(orig, end, AABBs, edge_length, threads = 1, progress = TRUE)

Arguments

orig

A data.table with the describing *XYZ* coordinates of the the start path of the rays.

end

A data.table with the describing *XYZ* coordinates of the the end path of the rays.

AABBs

A data.table with *XYZ* coordinates of the center of AABBs.

edge_length

A positive numeric vector with the AABB length edge for the X, Y, and Z coordinates.

threads

An integer >= 0 describing the number of threads to use. This need to be used if parallel = TRUE.

progress

Logical, if TRUE displays a graphical progress bar. TRUE as default.

Value

It returns a data.table with nine columns: 1-5 columns with the counts for the code of intersection (see line_AABB), and 6-9 columns with sum the path length of intersection. The number of rows match with nrow(AABBs).

Author(s)

J. Antonio Guzmán Q.

See Also

line_AABB, voxels

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
26
27
28
29
30
31
32
33
34
35
#Create points with paths
n <- 20
orig <- data.table(X = runif(n, min = -5, max = 5),
                   Y = runif(n, min = -5, max = 5),
                   Z = runif(n, min = -5, max = 5))

end <- data.table(X = runif(n, min = -5, max = 5),
                  Y = runif(n, min = -5, max = 5),
                  Z = runif(n, min = -5, max = 5))

#Create a potential AABB
AABBs <- data.table(X = 0, Y = 0, Z = 0)
edge_length <- c(2, 2, 2)

#Plot

cube <- rgl::cube3d()
cube <- rgl::scale3d(cube,
                     edge_length[1]/2,
                     edge_length[2]/2,
                     edge_length[3]/2)
box <- rgl::translate3d(cube, AABBs[[1]], AABBs[[2]], AABBs[[3]])
rgl::shade3d(box, col= "green", alpha = 0.6)
rgl::points3d(orig, size = 5, col = "black")
rgl::points3d(end, size = 5, col = "red")

for(i in 1:nrow(orig)) {
rgl::lines3d(c(orig[[1]][i], end[[1]][i]),
             c(orig[[2]][i], end[[2]][i]),
             c(orig[[3]][i], end[[3]][i]), col = "grey")
}


#Estimation
lines_interception(orig, end, AABBs, edge_length, progress = FALSE)

Antguz/rTLS documentation built on Dec. 14, 2021, 9:49 a.m.