We wanted to make something to engage people with physics, there exists out there a lot of asteroid simulations but we wanted to make one that was a bit different. That used as much real data as it could. We also took inspiration from a few works of fiction like Armageddon, or walking with dinosaurs.

What it does

That app gets all the near earth asteroids that have come close to earth in the last 7 days and adds them to a simulation to show how they would orbit the earth. The user can also add asteroids to around earth. When these asteroids collide with earth, the user is shown a satellite image of the place of impact as well as the approximate population affected by the asteroid.

How we built it

We made the app in Android Studio using Java. To get the data for the asteroids, it does an api request to NASA's near earth object api for the previous 7 days. It uses the distance of closest approach and the closest approach velocity to specify the orbit of the asteroids. We used the rates of changes of the position vector of the asteroids, from newtonian gravity and conservation laws, to update the asteroid's position for a given time step. Once these asteroids collide with earth we get their latitude and longitude coordinates. These get fed into 2 different sets of code, one of them gets the satellite image for that location using a Nasa api and the other gets the population of the nearest cities using within the approximate blast radius of the asteroid.

Challenges we ran into

For this project we wanted to use as much actual data as possible. So we were ideally wanting the user to be shown the orbits of the near earth asteroids, which wouldn't actually collide with earth, they would only pass near us. Then they could click on them to alter their trajectory by different amounts to see how this would affect whether they would collide with earth, where it would impact and the number of people it would affect. Unfortunately, due to time constraints adding the ability to alter the trajectories of the asteroids become a little infeasible. So in order to incorporate the asteroid data and show off the collision api components, the physics system isn't perfectly accurate but this seems an okay compromise to get a working prototype. Additionally, there were quite a few issues when trying to interface with the apis, and finding the right one in the case of the population api. Figuring out which Http library to use and troubleshooting problems with api keys ate up quite a lot of our time at the beginning but we figured it out in the end.

Actually drawing the Earth and asteroids was quite the challenge. This is because there were several coordinate systems at play. There was the actual distance in meters, and then the distance in dp to be drawn on the phone screen. Then on top of this there were translations and scaling to do with the panning and zooming the user can perform. It was also tricky to strike a balance between making the earth and asteroids look nice and having the app be simple enough to code and perform well enough with a large amount of asteroids on screen.

Accomplishments that we're proud of

We’re happy that the app is functional and that we managed to implement the majority of features that we wanted to. We think that it looks good and performs well. The panning and zooming feels natural, and even though the apis were very slowly because we coded it asynchronously the app doesn’t freeze even when it’s waiting for data.

Neither of us had made an app before this, so we’re happy that our first attempt turned out ok.

What we learned

At the beginning of this hackathon both of us had used Java a bit before but hadn’t made anything quite as involved as this. Although this might have made the initial progress of the app a lot slower we now feel a lot more proficient in Java now being able to interact with apis and build android apps.

What's next for Close Call

As said in the sections above, the physics of the app isn’t quite right due to not being able to alter the trajectories of the near earth asteroids. In the future we hope to add a bit of GUI to allow the user to change the trajectories of the asteroids and there be able to implement a better physics engine to showcase our apps features.


Built With

Share this project: