Skip to content
Snippets Groups Projects
Commit 03bcd37f authored by nicoscattaneo's avatar nicoscattaneo
Browse files

update repo

parent 5de80af8
No related branches found
No related tags found
No related merge requests found
rm(list=ls())
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
library("rlas")
library("rgl")
library("stringr")
......@@ -8,10 +8,8 @@ library("VoxR")
library("data.table")
## function to scale X, Y and Z
getwd()
load("/home/nica/Documents/Helge_Tower_POV/DataR/pan3d.RData")
objects()
## load("/home/nica/Documents/Helge_Tower_POV/DataR/pan3d.RData")
load("/home/pepito/Documents/holger_tower_pov/DataR/pan3d.RData")
## this function scale points coordinate
## between 0 and (max-min) values
......@@ -20,41 +18,44 @@ Scale <- function(Vector){
(max(Vector)-min(Vector)))*
(max(Vector)-min(Vector))}
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## plot data - full path
DataPaths <- list.files("/home/nica/Documents/Helge_Tower_POV/DataR",
pattern = "plot_",
DataPaths <- list.files(paste0("/home/pepito/Documents",
"/holger_tower_pov/DataR"),
## pattern = "plot_",
pattern = "Plot_",
full.names = T)
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## Scale the data to imrpove visualization
Data <- read.las(DataPaths)
gc()
## Data <- Data[sample(1:nrow(Data), nrow(Data)*0.20), ]
Data <- Data[Classification %in% c(3, 4, 5), ]
Data[, X := Scale(Data$X)]
Data[, Y := Scale(Data$Y)]
Data[, Z := Scale(Data$Z)]
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## center the data around 0
Data[, X := X-mean(X)]
Data[, Y := Y-mean(Y)]
plot3d(Data, aspect = "iso", size = 0.2)
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## Create an satificial tower. Just the corners
CornA <- data.table(X = 1, Y = 1, Z = 40)
CornB <- data.table(X = 1, Y = -1, Z = 40)
CornC <- data.table(X = -1, Y = 1, Z = 40)
CornD <- data.table(X = -1, Y = -1, Z = 40)
spheres3d(CornA, radius = 0.3, col = "yellow")
spheres3d(CornB, radius = 0.3, col = "blue")
spheres3d(CornC, radius = 0.3, col = "red")
spheres3d(CornD, radius = 0.3, col = "green")
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## center the data around cornerX
## plot3d(Data, aspect = "iso", size = 0.5)
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## Create an artificial tower. Just the corners
CornA <- data.table(X = 3, Y = 3, Z = 50)
CornB <- data.table(X = 3, Y = -3, Z = 50)
CornC <- data.table(X = -3, Y = 3, Z = 50)
CornD <- data.table(X = -3, Y = -3, Z = 50)
spheres3d(CornA, radius = 1, col = "yellow")
spheres3d(CornB, radius = 1, col = "blue")
spheres3d(CornC, radius = 1, col = "red")
spheres3d(CornD, radius = 1, col = "green")
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## center the data around corner X
Data2 <- copy(Data)
Data2[, X := X - CornA$X]
Data2[, Y := Y - CornA$Y]
......@@ -63,34 +64,81 @@ CornA2 <- copy(CornA)
CornA2[, X := X - CornA$X]
CornA2[, Y := Y - CornA$Y]
plot3d(Data2, aspect = "iso", size = 0.2, col= "red")
spheres3d(c(0, 0, 40), radius = 0.3, col = "yellow")
## plot3d(Data2, aspect = "iso", size = 0.2, col= "red")
## spheres3d(c(0, 0, 40), radius = 1, col = "yellow")
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## compute angles on the plane.
## It should be from >180 dgrees to <90 dgrees.
## points should be selected from >180 dgrees
## to <90 dgrees.
## you must voxelize the point cloud first.
Data2 <- vox(Data2, 0.02)
plot3d(Data2, aspect = "iso", size = 0.2, col= "red")
spheres3d(c(0, 0, 40), radius = 0.3, col = "yellow")
## Data2[, npts := NULL]
## Data2[, angle_x := VoxR::axis_angle(Data2, axis = "X",
## project = "xy")]
plot3d(Data2[angle_x %inrange% list(0, 180), ], aspect = "iso", size = 0.7,
col= "black", add = T)
plot3d(Data2[angle_x %inrange% list(270.1, 359.9), ], aspect = "iso", size = 0.7,
col= "black", add = T)
spheres3d(c(0, 0, 40), radius = 0.3, col = "yellow")
summary(Data2$angle_x)
spheres3d(c(0, 0, 40), radius = 0.3, col = "yellow")
## plot3d(Data2, aspect = "iso", size = 0.2, col= "red")
## spheres3d(c(0, 0, 40), radius = 1, col = "yellow")
Data2[, npts := NULL]
Data2[, angle_x := VoxR::axis_angle(Data2, axis = "X",
project = "xy")]
## plot3d(Data2[angle_x %inrange% list(0, 180), ], aspect = "iso", size = 0.7,
## col= "black")
## plot3d(Data2[angle_x %inrange% list(270.1, 359.9), ], aspect = "iso", size = 0.7,
## col= "black", add = T)
Data3 <- Data2[angle_x %inrange% list(0, 180), ]
Data2 <- rbind(Data3, Data2[angle_x %inrange% list(270.1, 359.9), ])
rm(Data3)
gc()
## plot3d(Data2, aspect = "iso", size = 0.2,
## col= "grey21")
## spheres3d(c(0, 0, 40), radius = 1, col = "yellow")
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## Compute angles around the Z axis
Data2[, angle_x := NULL]
Data2[, z := z - CornA2$Z]
Data2[, angle_z := VoxR::axis_angle(Data2, axis = "Z")]
Data2[, z := z+CornA2$Z]
Data2[, angle_z := angle_z - 90]
Data2[, angle_x := VoxR::axis_angle(Data2, axis = "X",
project = "xy")]
## FOV
VerticalOpen <- 28
## VerticalOpen <- 10
OrizontalOpen <- 40
##
VertcalAngle <- 50
HorizAngle <- 90
plot3d(Data2, aspect = "iso", size = 0.2,
col= "grey21")
spheres3d(c(0, 0, 40), radius = 1, col = "yellow")
plot3d(Data2[angle_z < (90-VertcalAngle) + VerticalOpen &
angle_z > ((90-VertcalAngle)) &
angle_x < HorizAngle + OrizontalOpen &
angle_x > HorizAngle, ],
aspect = "iso", size = 0.7,
col= "red", add = T)
pan3d(2)
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
plot3d(Data2, aspect = "iso", size = 0.2,
col= "grey21")
spheres3d(c(0, 0, 40), radius = 0.5, col = "yellow")
for(HorizAngle in c(seq(0, 179.9, 10), seq(270.1, 360, 10))){
plot3d(Data2[angle_z < (90-VertcalAngle) + VerticalOpen &
angle_z > ((90-VertcalAngle)) &
angle_x < HorizAngle + OrizontalOpen &
angle_x > HorizAngle, ],
aspect = "iso", size = 0.7,
col= "red", add = T)
Sys.sleep(0.3)
rgl.pop()
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment