Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
Holger_Tower_POV
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas Cattaneo
Holger_Tower_POV
Commits
44c3dbbb
Commit
44c3dbbb
authored
1 year ago
by
Nicolas Cattaneo
Browse files
Options
Downloads
Patches
Plain Diff
update repo
parent
bf54ec37
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CodeR/03_Compute_angles_cone.r
+138
-6
138 additions, 6 deletions
CodeR/03_Compute_angles_cone.r
with
138 additions
and
6 deletions
CodeR/03_Compute_angles_cone.r
+
138
−
6
View file @
44c3dbbb
...
@@ -29,27 +29,159 @@ source(paste0(CodeR, "/Functions/Functions.r"))
...
@@ -29,27 +29,159 @@ source(paste0(CodeR, "/Functions/Functions.r"))
## plot data - full path
## plot data - full path
DataPaths
<-
list.files
(
DataR
,
DataPaths
<-
list.files
(
DataR
,
## pattern = "plot_",
## pattern = "plot_",
pattern
=
"Plot_"
,
##
pattern = "Plot_",
##
pattern = "merg",
pattern
=
"merg"
,
## pattern = ".rds",
## pattern = ".rds",
## pattern = "Tower",
## pattern = "Tower",
full.names
=
T
)
full.names
=
T
)
Data
<-
read.las
(
DataPaths
)
Data
<-
read.las
(
DataPaths
[
1
])
Data
[,
1
:
3
]
Data
<-
Data
[,
1
:
3
]
# Create a simple 3D arrow function
drawArrow
<-
function
(
start
,
end
,
col
=
"red"
,
lwd
=
5
,
arrowSize
=
0.1
)
{
segments3d
(
rbind
(
start
,
end
),
col
=
col
,
lwd
=
lwd
)
# Compute the direction vector
dirVector
<-
end
-
start
# Normalize the direction vector
dirVector
<-
dirVector
/
sqrt
(
sum
(
dirVector
^
2
))
# Create the arrow head (as three segments emanating from the arrow tip)
segments3d
(
rbind
(
end
,
end
-
arrowSize
*
dirVector
+
c
(
arrowSize
,
0
,
0
)),
col
=
col
,
lwd
=
lwd
)
segments3d
(
rbind
(
end
,
end
-
arrowSize
*
dirVector
+
c
(
-
arrowSize
,
0
,
0
)),
col
=
col
,
lwd
=
lwd
)
segments3d
(
rbind
(
end
,
end
-
arrowSize
*
dirVector
+
c
(
0
,
-
arrowSize
,
0
)),
col
=
col
,
lwd
=
lwd
)
}
# Example data
set.seed
(
123
)
n
<-
1000
x
<-
runif
(
n
,
500000
,
505000
)
# UTM x-coordinates
y
<-
runif
(
n
,
5000000
,
5005000
)
# UTM y-coordinates
z
<-
runif
(
n
,
0
,
100
)
# just some random z values
# Plot the point cloud
plot3d
(
x
,
y
,
z
,
type
=
"p"
,
col
=
"blue"
)
# Define the "Devise" point
devise
<-
c
(
502500
,
5002500
,
50
)
# For instance
spheres3d
(
devise
,
radius
=
100
)
# Compute the arrow length based on the data range
arrow_length
<-
max
(
c
(
diff
(
range
(
x
)),
diff
(
range
(
y
)),
diff
(
range
(
z
))))
/
10
# South (S)
drawArrow
(
devise
,
devise
+
c
(
0
,
-
arrow_length
,
0
),
col
=
"red"
)
# West (W)
drawArrow
(
devise
,
devise
+
c
(
-
arrow_length
,
0
,
0
),
col
=
"green"
)
# North (N)
drawArrow
(
devise
,
devise
+
c
(
0
,
arrow_length
,
0
),
col
=
"blue"
)
# East (E)
drawArrow
(
devise
,
devise
+
c
(
arrow_length
,
0
,
0
),
col
=
"yellow"
)
# Southwest (SW)
drawArrow
(
devise
,
devise
+
c
(
-
arrow_length
,
-
arrow_length
,
0
),
col
=
"purple"
)
# Southeast (SE)
drawArrow
(
devise
,
devise
+
c
(
arrow_length
,
-
arrow_length
,
0
),
col
=
"cyan"
)
# Northwest (NW)
drawArrow
(
devise
,
devise
+
c
(
-
arrow_length
,
arrow_length
,
0
),
col
=
"magenta"
)
# Northeast (NE)
drawArrow
(
devise
,
devise
+
c
(
arrow_length
,
arrow_length
,
0
),
col
=
"orange"
)
getArrowTipCoords
<-
function
(
base
,
length
,
direction
)
{
if
(
direction
==
"S"
)
{
return
(
base
+
c
(
0
,
-
length
,
0
))
}
else
if
(
direction
==
"W"
)
{
return
(
base
+
c
(
-
length
,
0
,
0
))
}
else
if
(
direction
==
"N"
)
{
return
(
base
+
c
(
0
,
length
,
0
))
}
else
if
(
direction
==
"E"
)
{
return
(
base
+
c
(
length
,
0
,
0
))
}
else
if
(
direction
==
"SW"
)
{
return
(
base
+
c
(
-
length
,
-
length
,
0
))
}
else
if
(
direction
==
"SE"
)
{
return
(
base
+
c
(
length
,
-
length
,
0
))
}
else
if
(
direction
==
"NW"
)
{
return
(
base
+
c
(
-
length
,
length
,
0
))
}
else
if
(
direction
==
"NE"
)
{
return
(
base
+
c
(
length
,
length
,
0
))
}
else
{
stop
(
"Invalid direction provided!"
)
}
}
# Define the "Devise" point and arrow length as before
devise
<-
c
(
502500
,
5002500
,
50
)
# For instance
arrow_length
<-
max
(
c
(
diff
(
range
(
x
)),
diff
(
range
(
y
)),
diff
(
range
(
z
))))
/
10
# Get the coordinates for each direction
s_tip
<-
getArrowTipCoords
(
devise
,
arrow_length
,
"S"
)
w_tip
<-
getArrowTipCoords
(
devise
,
arrow_length
,
"W"
)
n_tip
<-
getArrowTipCoords
(
devise
,
arrow_length
,
"N"
)
e_tip
<-
getArrowTipCoords
(
devise
,
arrow_length
,
"E"
)
sw_tip
<-
getArrowTipCoords
(
devise
,
arrow_length
,
"SW"
)
se_tip
<-
getArrowTipCoords
(
devise
,
arrow_length
,
"SE"
)
nw_tip
<-
getArrowTipCoords
(
devise
,
arrow_length
,
"NW"
)
ne_tip
<-
getArrowTipCoords
(
devise
,
arrow_length
,
"NE"
)
# Print the coordinates
print
(
list
(
S
=
s_tip
))
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## Hi Nico,
## Assuming the coordinates in the PointCloud are UTM,
## the preferred location of the SIF sensor would be at
## N 6694611.571 E 614675.0338 and height 315.8627 masl
## This is a point in the middle of the SW-SE edge of the tower
## top, and the preferred viewing direction is more or less south
## since there is a dense group of trees there; the crucial
## question is the viewing angle.
## Cheers, Holger
Devise
<-
data.table
(
X
=
614675.0338
,
Y
=
6694611.571
,
Z
=
315.8627
)
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Data
<-
Data
[
sample
(
1
:
nrow
(
Data
),
nrow
(
Data
)
*
0.10
),
]
Data
<-
Data
[
sample
(
1
:
nrow
(
Data
),
nrow
(
Data
)
*
0.10
),
]
Data
<-
rbind
(
Data
,
Devise
)
Data
[,
X
:=
Scale
(
Data
$
X
)]
Data
[,
X
:=
Scale
(
Data
$
X
)]
Data
[,
Y
:=
Scale
(
Data
$
Y
)]
Data
[,
Y
:=
Scale
(
Data
$
Y
)]
Data
[,
Z
:=
Scale
(
Data
$
Z
)]
Data
[,
X
:=
X
-
mean
(
X
)]
Data
[,
X
:=
X
-
mean
(
X
)]
Data
[,
Y
:=
Y
-
mean
(
Y
)]
Data
[,
Y
:=
Y
-
mean
(
Y
)]
Devise
<-
tail
(
Data
,
1
)
plot3d
(
Data
,
aspect
=
"iso"
,
size
=
0.
5
)
plot3d
(
Data
,
aspect
=
"iso"
,
size
=
0.
2
)
pan3d
(
3
)
pan3d
(
3
)
spheres3d
(
Devise
,
radius
=
0.5
,
col
=
"red"
)
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
## Create an artificial tower. Just the corners
## Create an artificial tower. Just the corners
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment