Skittles Galaxy

Skittles Galaxy

Visual Progress

http://photopeach.com/album/9mjhe5

http://bunkrapp.com/present/evz1l4/?utm_medium=share

The parametric equations of the logarithmic spiral in terms of the polar angle θ is expressed in Cartesian coordinates as:

\[x = r*cos(\theta)\] \[y = r*sin(\theta)\]

Defining the First Galactic Arm

In order to get a basic perspective of how to arithmetically illustrate the “galactic arms” of a galaxy, we will use a range of (0, 9\(\pi\)) for the polar angle \(\theta\). The \(\phi\) , pitch angle, of 12 degrees, which simplifies to \(\pi\)/15 radians, will be used to make them look more like realistic galatic arms.Below, we will define the range of \(\theta\) (theta), \(\phi\) (pitch), and define r as \(e^{\theta tan(\phi)}\):

theta <- (seq(0,(9*pi), length.out = 500))
pitch <- (pi/15)
r <- (exp(1))^(theta*(tan(pitch)))
x <- (r*(cos(theta)))
y <- (r*(sin(theta)))

Plotting the First Galatic Arm

plot(x,y,col=rainbow(6),pch=".",xlab="",ylab="",axes = FALSE, cex=2.0, xlim = c(-30,30),ylim=c(-35,35))

Defining the Second Galactic Arm

The second galactic arm’s equation is expressed in polar coordinates as \(r = e^{(\theta+\pi)tan\phi}\). x2 and y2 are Cartesian Coordinates with respect to the the the second galatic arm’s polar coordinates.

r2 <- ((exp(1))^((theta+pi)*(tan(pitch))))
x2 <- (r2*(cos(theta)))
y2 <- (r2*(sin(theta)))

Plotting the Second Galactic Arm

plot(x,y,col=rainbow(6),pch=".",xlab="",ylab="",axes = FALSE, cex=2.0, xlim = c(-30,30),ylim=c(-35,35))
points(x2,y2,col=rainbow(6),pch=".",cex=2.0)

Creating the Fuzzy Spirals using Uniform Distribution

We will introduce a variable called “u”,for uniform distribution set, which will be a set/vector of numbers from -10 to 10 as well as a variable called “i” which will act as the sequence identifier for “u”. The variable “u” is defined with the function sample() in order to assist with the Randomizing process of creating scatter “stars” along the galatic arms that have been plotted. We will also distribute 10,000 stars to each galatic arm create a more realistic feel.

#set theta length to 10,000
theta <- (seq(0,(9*pi), length.out = 1e4))
# i is the index holder 
i <- seq(1:1e4)
#u contains set of random numbers between -10 and 10 
 u <- sample(-10:10,1e4, replace = T)

In order to add the uniform distribution scatter to the line we will add u[i] to both the x and y coordinates.

plot((x+u[i]),(y+u[i]),col=rainbow(6),pch=".",xlab="",ylab="",axes = FALSE, cex=2.0, xlim = c(-200,200),ylim=c(-200,200))
points((x2+u[i]),(y2+u[i]),col=rainbow(6),pch=".",cex=2.0)

Creating the Fuzzy Spirals using Jitter()

Another way to create the fuzzy spirals is to utilize a predefined R funciton called jitter.

Syntax: >jitter([value], [disposition] amount =)

While using jitter, we blacked out the the background, and adjust the xlim and ylim in order to feel like we were looking at the milky way…

#Black dot
plot(0,0, lwd=2, ylab="",xlab="",cex=600,axes=FALSE, ylim=c(-300,350),xlim=c(-225,225),pch=".")

#Spiral
theta<- seq(0,9*pi, len=1e4)
r<- (exp(1))^(theta*tan(pi/15))
x<- r*cos(theta)
y<- r*sin(theta)
points(jitter(x, amount= 21.0), jitter(y, amount = 20.0),pch=".",col= rainbow(5),ylab="",xlab="",cex=1.5,ylim=c(-300,350),xlim=c(-225,250))


#Second spiral
f<- (exp(1))^((theta+pi)*tan(pi/15))
x<- f*cos(theta)
y<- f*sin(theta)
points(jitter(x, amount= 21.0), jitter(y, amount = 20.0),pch=".", col= rainbow(5),lwd=2,ylab="",xlab="",cex=1.5,ylim=c(-300,350),xlim=c(-225,250))