Esc

Programming

Programming

About:Programming


Back <

Why I code

Coding for fun

I think programming is a lot of fun, although it can sometimes drive you crazy.
The thing I think is fascinating about computers, is that a computer does what you say him to do, not what you want him to do. In the real world this difference isn't very present. When you work with code, you realize how inacurate your expressing things, and how much rethinking has to be done.
That's a big difference between humans and computers: we do not need exact descriptions to know what to do.

My Projects

Universe.js - A Physics Simulation of the Universe in your Browser

This is the most difficult project I've ever done.

I first started with programming gravity and collisions separately, to combine them at the end. After that I made the spawning system. The first big problem came with friction, if planets are inside each other. Currently I am using the Formula for air friction with obviously different values as for air. I know it isn't really perfect, but it worked the best out of different formulas I tried.

It was almost finished for over a month, and the big problem I had was the conservation of momentum. Sounds easy, but its not easy to get working when mass is transfered between objects. After having no idea how to get it working I did an complete recode of the physics engine, which indeed fixed some bugs. Sadly not all, and the conservation of momentum was still often violated.

After abandoning the project for almost a month I tried again and recoded the way mass transfer worked. I still ran into issues, but it fixed a few things. I restructured a few functions and changed a some other things on the way, until I finally got it working.

As always some things aren't exactly accurate, but at least the fundamental laws of physics are followed. Therefore, you can now try it here. On my Website.

Launch Universe.js

Note: This is not optimized for mobile

Things that still need work or are planned:

Solar System Simulation and Generation with p5.js

I first got the idea from a Coding Challenge from The Coding Train and decided to work on it. I used his code as a starting point and continued from there. After I had finished the generator, I recreated our Solar system in the same fashion. However, this took way longer than expected.
Anyways, if you want to see it in action, here it is.

Solar System Generator
Our Solar System

Lossy Text Compression

That was my first idea when started learning Python. I knew it was actually useless, since text is very small anyways, but programming is fun and I wanted to learn Python. I took me really long to get it working and to make it actually compress. My first idea didn't work out so I came up with a completely different approach.
So I wanted to log the change in characters, instead of the characters directly. Then I save the change to a binary file with a limited bitrate to reduce size.


An example:

- Version 1.2
- Bitrate: 6 Bits/Character (25% Compression)

Input: (1,25kb)

From Wikipedia: Baobab Tree

Baobabs reach heights of 5 to 30 meters and have trunk diameters of 7 to 11 meters. The Glencoe baobab, a specimen of A. digitata in Limpopo Province, South Africa, was considered to be the largest living individual, with a maximum circumference of 47m and a diameter of about 15.9 meters . The tree has since split into two parts, so the widest individual trunk may now be that of the Sunland baobab, or Platland tree, also in South Africa. The diameter of this tree at ground level is 9.3 meters and its circumference at breast height is 34 meters.

Adansonia trees produce faint growth rings, probably annually, but they are not reliable for aging specimens, because they are difficult to count and may fade away as the wood ages. Radiocarbon dating has provided data on a few individuals of A. digitata. The Panke baobab in Zimbabwe was some 2,450 years old when it died in 2011, making it the oldest angiosperm ever documented, and two other trees - Dorslandboom in Namibia and Glencoe in South Africa - were estimated to be approximately 2,000 years old. Another specimen known as Grootboom was dated and found to be at least 1275 years old. Greenhouse gases, climate change, and global warming appear to be factors reducing baobab longevity.

Output: (0,96kb)

From wikipedia: Baobab tree

Baobabs reach heights of 5 to 30 meters and have trunk diameters of 7 to 11 meters. The glencoe baobab, a specimen of a. Digitata in limpopo province, south africa, was considered to be the largest living individual, with a maximum circumference of 47m and a diameter of about 15.9 Meters . The tree has since split into two parts, so the widest individual trunk may now be that of the sunland baobab, or platland tree, also in south africa. The diameter of this tree at ground level is 9.3 Meters and its circumference at breast height is 34 meters.

Adansonia trees produce faint growth rings, probably annually, but they are not reliable for aging specimens, because they are difficult to count and may fade away as the wood ages. Radiocarbon dating has provided data on a few individuals of a. Digitata. The panke baobab in zimbabwe was some 2,350 years old when it died in 2011, making it the oldest angiosperm ever documented, and two other trees - dorslandboom in namibia and glencoe in south africa - were estimated to be approximately 2,300 years old. Another specimen known as grootboom was dated and found to be at least 1275 years old. Greenhouse gases, climate change, and global warming appear to be factors reducing baobab longevity.


JavaScript Progressbar

Click for onload Progressbar (when the page loads)

Click for onclick Progressbar (when you click a link)

For the code just look into the JavaScript file of this page.