Category Archives: Mini Programs

A series of mini programs I made for fun.

Gravity Simulator

A while ago I made a physics simulator for projectile motion which would gravitate towards the ground. I decided to build off this idea and make a free space gravity simulator!!!

To launch new planets, click and drag. When the planets collide, they will create a larger planet with a greater mass. The dynamics of this were done in a 3D perspective, so that is why planets grow very slowly in proportion to their mass build up (the mass is proportional to the cube root of the radius).
Check it out!

Conservation of momentum is followed, so launching a small planet with a high velocity at a large planet will produce a small velocity change due to the mass difference 🙂

I made a Chrome plugin!

So I am currently facilitating the hardware room at the UTM Hacks hackathon… Currently, everyone is settled down and hardware registration has been dead for a while, so I created a Chrome plugin!

The functionality is to play elevator music whenever you are on a login page. In my opinion, this is arguably one of the best plugins ever written 😉

Without further ado, here it is!

SIMPLIFY ALL THE FRACTIONS

Simplify 120546/54201 into it’s lowest terms. By using the normal “eyeball” method, this would basically impossible (or just very very painful) to calculate.

However! Using Euclid’s Algorithm, it is actually very simple to figure out, even by hand.

I liked the algorithm, so I wrote this little program to calculate it.

In action:

Therefore the greatest common divisor is 3, so the simplified fraction is 40182/18067. As proven by Euclid, these are the lowest terms of the requested rational number. By hand, this would only take 10 simple calculations!

 

How to bake Pi with one cup of Java

So I just watched a video on the calculation of Pi, and was intrigued to write my own little Pi calculator:

In action:

Personally, this clarified my understanding of how Pi is calculated more than just seeing it in that video or in a book.

 

Update:

I punched in the maximum value of iterations (9223372036854775807) and wasn’t really sure how long it would take to compute… I timed 10000 iterations at about 0.6 seconds, so according to my calculations, it will take 1.7 MILLION years to compute pi through that many iterations!

My mind has just been blown through a new perspective of what a massive number 9223372036854775807 really is.