diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000000000000000000000000000000000000..10ad24d00a3788d95045b638db411d9354677e1a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/DataR/ diff --git a/CodeR/01_test_data_structure.r b/CodeR/01_test_data_structure.r new file mode 100644 index 0000000000000000000000000000000000000000..2e9986b27488912da264bf76e2cc6392f0f305da --- /dev/null +++ b/CodeR/01_test_data_structure.r @@ -0,0 +1,96 @@ +rm(list=ls()) + +## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +library("rlas") +library("rgl") +library("stringr") +library("VoxR") +library("data.table") + +## function to scale X, Y and Z +getwd() + +load("/home/nica/Documents/Helge_Tower_POV/DataR/pan3d.RData") +objects() + +## this function scale points coordinate +## between 0 and (max-min) values +Scale <- function(Vector){ + ((Vector - min(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_", + full.names = T) + +## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +## Scale the data to imrpove visualization +Data <- read.las(DataPaths) +gc() + +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 +Data2 <- copy(Data) +Data2[, X := X - CornA$X] +Data2[, Y := Y - CornA$Y] + +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") + +## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +## compute angles on the plane. +## It should be 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") + + + diff --git a/CodeR/01_test_data_structure.r~ b/CodeR/01_test_data_structure.r~ new file mode 100644 index 0000000000000000000000000000000000000000..b27fbb163aebcb274279e4b843fe9d82e534aac1 --- /dev/null +++ b/CodeR/01_test_data_structure.r~ @@ -0,0 +1,55 @@ +rm(list=ls()) + +## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +library("rlas") +library("rgl") +library("stringr") +library("VoxR") +library("data.table") + +## function to scale X, Y and Z +getwd() + +load("/home/nica/Documents/Helge_Tower_POV/DataR/pan3d.RData") +objects() + +## this function scale points coordinate +## between 0 and (max-min) values +Scale <- function(Vector){ + ((Vector - min(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_", + full.names = T) + +## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +## Scale the data to imrpove visualization +Data <- read.las(DataPaths) +gc() + +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 = 2, Y = 2, Z = 40) +CornB <- data.table(X = 2, Y = -2, Z = 40) +CornC <- data.table(X = -2, Y = 2, Z = 40) +CornD <- data.table(X = -2, Y = -2, Z = 40) + +spheres3d(CornA, radius = 0.3, col = "yellow") +spheres3d(CornB, radius = 0.3, col = "yellow") +spheres3d(CornC, radius = 0.3, col = "yellow") +spheres3d(CornD, radius = 0.3, col = "yellow") +