-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdatePlanarDistance.R
More file actions
28 lines (20 loc) · 1.22 KB
/
updatePlanarDistance.R
File metadata and controls
28 lines (20 loc) · 1.22 KB
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
updatePlanarDistance <- function(session, type, params=rep(0,6), reflection=c(1,0,0)) {
dist <- 0
if (type=="monoclinic") {
beta = params[5]*pi/180;
dist <- (((reflection[1]^2/params[1]^2+reflection[3]^2/params[3]^2-2*reflection[1]*reflection[3]*cos(beta)/(params[1]*params[3]))/(sin(beta)^2))+reflection[2]^2/params[2]^2)^-0.5
} else if (type=="orthorhombic") {
dist <- (reflection[1]^2/params[1]^2+reflection[2]^2/params[2]^2+reflection[3]^2/params[3]^2)^-0.5
} else if (type=="tetragonal") {
dist <- ((reflection[1]^2+reflection[2]^2)/params[1]^2+reflection[3]^2/params[3]^2)^-0.5
} else if (type=="cubic") {
dist <- ((reflection[1]^2+reflection[2]^2+reflection[3]^2)/params[1]^2)^-0.5
} else if (type=="hexagonal") {
dist <- (4/3*((reflection[1]^2+reflection[1]*reflection[2]+reflection[2]^2)/params[1]^2)+reflection[3]^2/params[3]^2)^-0.5
} else if (type=="triclinic") {
} else { # trigonal
}
updateTextInput(session, "pdist1", value = ifelse(is.na(dist), "", format(dist,3)) )
updateTextInput(session, "svect1", value = ifelse(is.na(dist), "", format(1/dist,3)) )
updateTextInput(session, "svect3", value = ifelse(is.na(dist), "", format(2*pi/dist,3)) )
}