蝴蝶曲線的極坐標(biāo)方程為
參數(shù)取值范圍為。
寫成參數(shù)方程,為
參數(shù)取值范圍與極坐標(biāo)下是相同的。一般為了追求曲線多一些變化,往往把改寫成。
這些天不少文章用matlab、mathematica、maple、python語(yǔ)言,甚至scratch、VBA等繪制它,卻唯獨(dú)少了R語(yǔ)言。然而R語(yǔ)言在可視化的表現(xiàn)力方面是相當(dāng)相當(dāng)強(qiáng)大的。下面用R來(lái)畫蝴蝶曲線。
t<-seq(from = 0, to = 12*pi, by = 0.005)
x<-sin(t)*(exp(cos(t)) - 2*cos(4*t)-(sin(t/11))^5)
y<-cos(t)*(exp(cos(t)) - 2*cos(4*t)-(sin(t/11))^5)
mydata<-data.frame(x = x, y = y)
library(ggplot2)
ggplot(data = mydata,aes(x = x, y = y))+
geom_point(colour = 'blue')+
coord_cartesian()
t<-seq(from = 0, to = 12*pi, by = 0.005)
x<-sin(t)*(exp(cos(t)) - 2*cos(4*t)-(sin(t/11))^5)
y<-cos(t)*(exp(cos(t)) - 2*cos(4*t)-(sin(t/11))^5)
mydata<-data.frame(x = x, y = y)
par(mfrow=c(2,1))
plot(x,y,"s",col="blue")
plot(x,y,"h",col="cyan2")
t<-seq(from = 0, to = 12*pi, by = 0.005)
r <-exp(cos(t))-2*cos(4*t)+(sin(t/12))^5
library(IDPmisc)
#小心IDPmisc極坐標(biāo)轉(zhuǎn)直角坐標(biāo)的phi用度作為角單位
xy <- clock2cart(rho=r,phi=t/pi*180,circle=-360)
library(ggplot2)
ggplot(data = xy,aes(x = x, y = y))+
geom_point(colour = 'red')
t<-seq(from = 0, to = 12*pi, by = 0.005)
r <-exp(cos(t))-2*cos(4*t)+(sin(t/12))^5
library(IDPmisc)
#小心IDPmisc極坐標(biāo)轉(zhuǎn)直角坐標(biāo)的phi用度作為角單位
xy <- clock2cart(rho=r,phi=t/pi*180,circle=-360)
library(ggplot2)
ggplot(data = xy,aes(x = x, y = y))+
geom_point(colour = 'red')+
coord_polar()
聯(lián)系客服