# 心臓の射影幾何〜非対称〜

• 卵・栗はらせんが軸に対して対称な回転をしていた
• それを崩すと心室様の形になる
# Projection: x4 has component of x3
p <- 0.4
# A projection matrix: Two convergence points are specified at (1,0,0) and (-1,0,0)
M <- matrix(c(1,-1,0,0,0,0,1,0,0,0,0,1,1,1,p,0),byrow=TRUE,4,4)

# A parameter to decide number of visible windings
q <- 1
# kurtosis parameter
d <- 3
# A parameter of fatness
k <- 0.6
# Projection: x4 has component of x3
p <- 0.4

lambdas <- c(d,-1,0+q*1i,0-q*1i )
# A matrix to consist rotations in (x3,x4)-plane
V <- matrix(c(1,0,0,0,0,1,0,0,0,0,1,-1i*1,0,0,1,1i*1),4,4)
# A projection matrix: Two convergence points are specified at (1,0,0) and (-1,0,0)
M <- matrix(c(1,-1,0,0,0,0,1,0,0,0,0,1,1,1,p,0),byrow=TRUE,4,4)

x.init <- rep(1,4)
x.init[3:4] <- x.init[3:4]*k
t <- seq(from=-30,to=30,length=500)

X <- matrix(0,length(t),4)
for(i in 1:4){
X[,i] <- x.init[i] * exp(lambdas[i]*t)
}

X. <- Re(t(V%*% t(X)))

# A surface is consisted of mulitple spirals that are made by rotation of the standard spiral in the original 4-dimensional space

phis <- seq(from=0,to=1,length=100)*2*pi
Y.all <- matrix(0,0,3)
for(ii in 1:length(phis)){
Rot <- matrix(c(cos(phis[ii]),sin(phis[ii]),-sin(phis[ii]),cos(phis[ii])),2,2)
X.2 <- X.
X.2[,3:4] <- t(Rot %*% t(X.2[,3:4]))
X.. <- t(M %*% t(X.2))
Y <- X..[,1:3]/X..[,4]
Y.all <- rbind(Y.all,Y)
}
col <- rep(1,length(Y.all[,1]))
minY <- min(Y.all)
maxY <- max(Y.all)
plot3d(rbind(Y.all,rbind(rep(minY,3),rep(maxY,3))),col=c(col,rep(2,2)),type="l")