The codes are:
###MODELING THE cylinder UNDER UNIFORM CURRENT
##########define the detail parameters
H=10;C=50;M<-8
mx<-matrix(NA,nrow=9,ncol=40)
mt<-matrix(NA,nrow=40,ncol=8)
lx<-list();ly<-list();lz<-list();lt<-list();lf<-list()
for(i in 1:T){
lx[]<-mx;ly[]<-mx;lz[]<-mx;lt[]<-mx;lf[]<-mt}
for(i in seq(1,9,1)){
for(j in seq(1,40,1)){
lx[[1]][i,j]<-(C/2/pi)*cos(9*(j-1)*pi/180)
ly[[1]][i,j]<-(C/2/pi)*sin(9*(j-1)*pi/180)
lz[[1]][i,j]<-H/M*(i-1)
}
}
lt[[1]]<-matrix(1:360,nrow=9,ncol=40)
lf[[1]]<-matrix(1:320,nrow=40,ncol=8)
lt means the circle element force
lf means the axis element force
a means thecircumference element length
b means axis element length
display 3D shape
library(rgl)
open3d()
plot3d(lx[[1]],ly[[1]],lz[[1]],type="p",xlab = "x", ylab = "y", zlab = "z",size="2.0",lwd=2)
for(i in seq(1,9,1)){######draw circle element lines, lt[[1]] means the circle element force
for(j in seq(1,39,1)){
lines3d(c(lx[[1]][i,j],lx[[1]][i,j+1]),c(ly[[1]][i,j],ly[[1]][i,j+1]),c(lz[[1]][i,j],lz[[1]][i,j+1]),lwd=2)
lines3d(c(lx[[1]][i,1],lx[[1]][i,40]),c(ly[[1]][i,1],ly[[1]][i,40]),c(lz[[1]][i,1],lz[[1]][i,40]),lwd=2)
} }
for(i in seq(1,8,1)){######draw the axis element lines lf[[1]]means the axis element force
for(j in seq(1,40,1)){
lines3d(c(lx[[1]][i,j],lx[[1]][i+1,j]),c(ly[[1]][i,j],ly[[1]][i+1,j]),c(lz[[1]][i,j],lz[[1]][i+1,j]),lwd=2)
}}
The figure 2 is the cylinear with lines.
The problem is how to add color in lines3d to show different element by the fourth variable and the fifth varible. The fourth varible adn fifth varible are lt[[1]] and lf[[1]], separately.