Saturday, September 27, 2014

New Blog

This weekend, I figured out how to use Jekyll, so this blog is moving to nielskornerup.github.io/Blog. I hope to see you all there!

Sunday, September 14, 2014

Elastic collisions

Hi! Today, I will tell you about a project that I have been working on in Independent study; an Elastic Collision simulator.

The Idea:
An Elastic Collision is one in which momentum and kinetic energy are conserved. Over the summer, I made a charged particle simulator, and starting this school year, I took the idea and made a gravity simulator. The primary problem with these two simulators is that particles can move inside of each other. In order to solve this problem, I want to implement Elastic Collisions, so I am working on the code with a different simulator. After I finish it, I plan to copy the code over to these two simulators to improve them as well.

The process:
To start this process, I first had to learn how Elastic collisions work. I found an equation to model the motion on Wikipedia. In order to implement this algorithm, I had to remember how to use arc tangent to compute angles from x and y speeds. The problem with arc tangent is that it has a range of (-pi/2, pi/2), so I had to figure out what the actual angle is depending on the sign on the X speed. If the X speed was negative, I would need to add pi to my result to get the correct angle. In order to calculate phi, I used the difference between x and y coordinates using the same basic system with arc tangent. In order to calculate the mass of a particle, I would square its radius.

The result:
This worked better than I expected, as a majority of the collisions looked accurate. Despite this, about 30% of my collisions were not working out as I expected them to. I started analyzing my code for bugs, but I could not find any. Eventually a classmate said that I could be having problems with particles tunneling into each other and preforming multiple collisions before escaping. Using this advice, I worked on creating anti-tunneling code.

Anti-tunneling:
In order to stop tunneling, I worked on a system where if two particles move into each-other, one will move backwards at the same angle until it is outside of the other. This seemed to solve my problem; however, I started having problems where particles would teleport when they collided. Thinking that this could be caused by multiple attempt to stop tunneling, I created a cool down timer for collisions, but this caused particles to get trapped inside of each other.

The state of my progress:
I have made significant progress on this project; however, I still have two bugs that I need to fix. I am hoping to fix these problems next week. See you then!

Tuesday, September 2, 2014

New year, new projects

Now I am in independent study for computer science, and I am working on a server that will allow clients to play games with clients that can be either AIs or actual players. We have decided on how we want to send input and output to and from the server. We have also implemented the rules for tic tack toe, which will be the default game for this project. Also, individually, I have worked on some of my own projects. I managed to get my charge simulator online, and I also wrote a gravity simulator. The charge simulator generates random charged particles at random velocities, and then simulates their movement while the gravity simulator does the same thing, but with gravity using differently sized objects. For both of these projects, I also figured out how to implement settings. The algorithms might still have a few bugs, so this is something that I plan to work on. I also plan to make a new project that tracks elastic collisions, but I need to learn how the physics behind that works first. I am also learning more javascript from this tutorial, and I plan to learn node.js for my projects. This year, I might also want to work on making my own blog using bootstrap, but I will see how things go. On a more personal level, I have been doing Aikido for about 1/2 a year now, and I have successfully advanced a rank.