- 単位正方形にフィボナッチ格子を作ってそれを球面に張ることもできる
- それは球面にらせんを描き、そのらせん上に黄金比関連の角間隔で点を打つことに近似できる
FN <- function(n){
if(n<0){
return(both.fn.3(-n)*(-1)^(n+1))
}
if(n==0){
return(0)
}else if (n==1 | n==2){
return(1)
}else{
tmp <- rep(0,n)
tmp[1] <- tmp[2] <- 1
for(i in 3:n){
tmp[i] <- tmp[i-1]+tmp[i-2]
}
return(tmp[length(tmp)])
}
}
n <- 10
k <- 0:FN(n)
F <- cbind(k/FN(n),(k*FN(n-1)/FN(n))%%1)
plot(F)
S <- cbind(2*cos(2*pi*F[,2])*sqrt(F[,1]-F[,1]^2),2*sin(2*pi*F[,2])*sqrt(F[,1]-F[,1]^2),1-2*F[,1])
install.packages("rgl")
library(rgl)
plot3d(S)
fib.lattice.S2 <-function(N,f1=(sqrt(5)+1)/2,k=1){
f2 <- f1-1
P <- 2*N+1
i <- seq(from=-N, to=N,by=k)
theta <- asin(2*i/(2*N+1))
z <- sin(theta)
phi <- 2*pi*i*f2
x <- cos(theta)*cos(phi)
y <- cos(theta)*sin(phi)
return(cbind(x,y,z))
}
S2 <- fib.lattice.S2(FN(n)/2)
plot3d(S2)
plot(c(S),c(S2))
n <- 15
nn <- 5000
S2 <- fib.lattice.S2(nn)
plot3d(S2)
dist.S2 <- as.matrix(dist(S2))
ord.dist.S2 <- apply(dist.S2,1,order)
E <- t(ord.dist.S2[2:5,])
sorted.dist.S2 <- apply(dist.S2,1,sort)
matplot(t(sorted.dist.S2[1:6,]),type="l")
matplot(t(sorted.dist.S2[1:8,]),type="l")
adj.m <- dist.S2
thres <- max(sorted.dist.S2[4,])
thres <- max(sorted.dist.S2[5,])
thres <- mean(sorted.dist.S2[5,length(S2[,1])/2],sorted.dist.S2[6,length(S2[,1])/2])
thres <- mean(sorted.dist.S2[6,(length(S2[,1])/3):(length(S2[,1])*2/3)],sorted.dist.S2[6,length(S2[,1])/2])
thres <- max(sorted.dist.S2[5,(length(S2[,1])/3):(length(S2[,1])*2/3)])
thres <- min(sorted.dist.S2[6,])
thres <- mean(sorted.dist.S2[5:6,])
adj.m <- adj.m < thres
diag(adj.m) <- 0
el <- which(adj.m==1,arr.ind=TRUE)
plot3d(S2)
for(i in 1:length(el[,1])){
}
tabulate(apply(adj.m,1,sum))
g <- graph.adjacency(adj.m)
plot(g)
apply(adj.m,2,sum)
for(i in 1:length(E[,1])){
for(j in 1:length(E[i,])){
adj.m[i,E[i,j]] <- 1
el[cnt,] <- c(i,E[i,j])
cnt <- cnt+1
}
}
library(igraph)
g <- graph.adjacency(adj.m)
plot(g)
range(apply(adj.m,1,sum))
range(adj.m-t(adj.m))
plot3d(S2)
for(i in 1:length(el[,1])){
segments3d(rbind(S2[el[i,1],],S2[el[i,2],]))
}