Butterfly Curve
http://photopeach.com/album/i28wm5
http://bunkrapp.com/present/evz1l4/?utm_medium=share
Polar Coordinate is a geometric term that refers to a pair or tuple of coordinates that locate a point’s position, usually given in the form (r, \(\theta\)). The first element of the tuple, r, refers to the straight line which connects the point to it’s origin. The second element in the tuple is the angle \(\theta\). Points in a polar coordinate plane can be converted onto a Cartesian coordinate plane using the following formula for the (x,y) coordinates:
\[ x = r*cos(\theta) \] \[ y = r*sin(\theta) \]
First, we found the period of the butterfly curve. This was accomplished by examining the equation of a butterfly expressed in polar coordinates, \(e^{cos(\theta)}-2cos(4\theta)+Sin^5(\theta/12)\), as 3 seperate expressions and determining the period for them.
The period of the trigonometric functions controls the distance between curces at different intervals. For example, there are points on the plot of the butterfly curve that appear closer and farther apart. This is due to the periodicity of the functions and its effect on both the x-axis and y-axis, in this instance they’re reffered to as cosine and sine.
In addition to that, we also found the amplitude of the functions which controls the minimum and maximum values that the curves will reach. As we can see there are some curves that are smaller, wider, narrower, and bigger. the functions amplitude is responsible for this type of line behavior.
Now let’s proceed to the fun part. We will define define \(\theta\) (theta), and r in relation to \(\theta\):
theta<- seq(0,(24.5*pi), length.out = 1e4)
r<- (exp(1))^cos(theta) - 2*cos(4*theta) + sin(theta/12)^5
Now that we have established the range of angle \(\theta\) and the formula for the length of ‘r’ from the origin we will convert these polar coordinates to cartesian coordinates.
x <- r*(cos(theta))
y <- r*(sin(theta))
Once the First butterfly has been plotted. It’s time to bring the butterfly’s family along. We can create duplicates with the same formula we already possess. Here are the affects of mixing constants with the expression and editing the desired output and disposition of the object you have created.
* Coefficient of r will change the size of the object. Also if the coefficient is less than 0, the image will “about face.”
* Adding/Subtracting Constant at the end of the expression will move the object along the x or y axis depending on which axis you apply it too.
* Changing the coefficient of pi will rotate the object that has been created.
#First Butterfly
plot(x,y,col=rainbow(1e4),lwd = 2,xlab="",ylab="",axes=FALSE,ylim=c(-4,9), xlim = c(-5,5),asp=1)
#Second Butterfly
x2<- 0.5*r*cos(theta + pi/6)
y2<- 0.5*r*sin(theta + pi/6) +5
lines(x2,y2,col="orange",lwd=2,xlab="",ylab="")
#Third Butterfly
x3<- r*cos(theta + pi/2.5) -6.7
y3<- r*sin(theta + pi/2.7) -1.33
lines(x3,y3,col="purple",lwd=2,xlab="",ylab="")
#Fourth Butterfly
x4<- 0.25*r*cos(theta +pi/4)+5
y4<- 0.25*r*sin(theta +pi/4)-3.71
lines(x4,y4,col="magenta",lwd=2,xlab="",ylab="")
#Fifth Butterfly
x4<- 0.25*r*cos(theta +pi)+5.3
y4<- 0.25*r*sin(theta +pi/16)+4
lines(x4,y4,col="lightgreen",lwd=2,xlab="",ylab="")
#Sixth Butterfly
x5<- 0.75*r*cos(theta +pi/-4)-4.6
y5<- 0.75*r*sin(theta +pi/-8)+6
lines(x5,y5,col="gold",lwd=2,xlab="",ylab="")