SolAR

Ariful Islam
3 min readFeb 23, 2019

Space, the final frontier

For every sci-fi fan, going to space has always been the ultimate dream. Some work really hard to go and achieve that dream to go see what else is out there in our solar system and unless you are an aspiring astronaut, Elon Musk, or a billionaire; the dream of seeing the solar system in front of you might stay a dream.

But that dream can be a reality!

How you ask?

With the power of Augmented Reality! Using Unity3D and a little bit of C# you can build your own AR app that lets you see the solar system right in front of you as if it was already there!

The process of making this is actually very simple! Since the planets are all somewhat of a circle, you simply need to make one Sun and one planet. After that, you can just make duplicates of the planet. The only thing that will be different is the orbit radius of the planets.

Since the planets in our solar system don’t have a perfectly circular orbit, the code would need to have the function to adjust the X-radius and the Y-radius.

The sun is fairly simple, just have a spherical GameObject with a mesh(get one from any website) and a light radiating from the surface. For the code of it just add a rotation function.

For the planets, however, it is a bit more work.

First set up a database for the ellipse function:

Ellipse Database

Keep in mind that even though the solar system will appear to be 3D the orbits will still be in 2D and that is why using a Vector2 function, only the X-axis and the Y-axis are adjustable and required.

Now for the actual ellipse path, using the ellipse database, I had to write a script so that the database is calculated accurately to render an elliptical orbit depending on any given X and Y values.

Ellipse Renderer

In this script, the 2D coordinates are put into a 3D function(Vector3) to calculate the elliptical orbit. It is possible to void the segments part but usually calculating arcs of sectors are harder and therefore cause the entire app to lag so I divided the ellipse into segments so that it is easier to calculate and the app runs without lag.

Now its time for the orbit!

This script acts like a pre-flight checklist for the orbit of the planets. It checks the progress of the orbit, the time period of the orbit(which can be adjusted depending on the X-radius and the Y-radius), and whether or not the orbit is active.

For displaying the orbit in 3D space, I had to take the 2D Y-coordinate and put it as a Z-coordinate. Also, the time period couldn’t be 0 since that would show the object spinning at one spot so for any value lower than 0.1, the calculations would take the value of 0.1.

After all that work, what you will finally be able to see is

The future of AR in the field of bringing amazing experiences to you is just starting off, as time goes by, using AR we can explore the seven seas, the surface of Mars and even the lives of bacteria, without having to leave the comfort of our homes!

--

--

Ariful Islam

Tech enthusiast and AR developer on a journey of self-discovery and growth.