DEV Community

Cover image for Understanding the Universe through Code: Planetary Motion
Jithin KS
Jithin KS

Posted on • Updated on

Understanding the Universe through Code: Planetary Motion

We know that our planet Earth is in constant motion around the Sun.

Have you ever thought about how our ancestors discovered this?

I think most of us don't fully appreciate the difficulties that they encountered in making this discovery.

Even though we are not feeling it, the Earth is actually moving around the Sun at a staggering speed of 30km/s.

Just go out and look at the sky during the day time or at night and see if you can find any hints that will help you to reach this conclusion. It turns out that there aren't any trivial ones.

Alt Text

It took the effort of a lot of great scientific minds, over several years, to discover this.

In this article, we are going to make an effort to understand and appreciate the beauty of this discovery with the help of visualizations.

Before that, let me tell you about one of the most important observations made by our ancestors that lead to this discovery.

They carefully observed the motion of planets in the sky over several days and months and kept track of their positions very accurately.

They found out that the planets traced out a curve which looked like this.

Alt Text

Can you believe that this observation was what lead them to speculate (correctly) that the Earth and the other planets are moving around the Sun?

How on earth did this "curve" that they observe in the sky lead them to this seemingly unrelated conclusion?

Let us try to find this out by creating a miniature solar system visualization.

And with the help of a few lines of code, we make our solar system model.

Alt Text

There is Earth, Mars and the Sun.

Now let us shift the centre of the coordinate to the Earth. This is necessary because from our viewpoint, we feel that the Earth is stationary and the rest of the heavenly bodies are moving around us.

Alt Text

Now from this viewpoint, let us look at the trajectory traced by Mars.

Alt Text

At first, it might look confusing, but observe this visualization for some time.

Does the curve look familiar?

The curve that we see in the sky is a small portion of the curve that we obtained now. But it looks squeezed when viewed from Earth's vantage point.

Alt Text

We obtained this by shifting the centre of the coordinate system to the Earth and tracing the path of Mars. Cool isn't it?

It took Johannes Kepler almost 40 years to analyse the data of the positions of the planets to finally come up with his laws that mathematically explained these ideas.

If you wish to get more clarity into these ideas, please see the workbook given below and play around with the visualizations and code yourself.

Workbook (Open in desktop)

Alt Text

PS - While creating the visualizations, I've assumed that the orbits of the planets are circular. But in reality, they are elliptical. The circular orbit which is an approximation gives us a reasonably good explanation. But to be more precise, we need elliptical orbits. And of course, do not take the scales seriously.

Thanks for reading !!!

Top comments (15)

Collapse
 
leob profile image
leob

An article about physics and astronomy, more of this! :-)

Collapse
 
jithinks profile image
Jithin KS • Edited

Do you think that the visualization has indeed really helped in having a good understanding??

Collapse
 
leob profile image
leob

Yes I think so, as they say: an image is worth a thousand words!

Collapse
 
belinde profile image
Franco Traversaro

In my opinion, it has

Collapse
 
adrian271 profile image
Adrian

I took Astronomy in High School and College (~20 yrs ago) and I've never considered or seen how Mars moves relative to Earth. This is blowing my mind.

Thread Thread
 
jithinks profile image
Jithin KS • Edited

I thought the concept of retrograde motion of planets was something that every astronomy students are well aware of.

Thread Thread
 
leob profile image
leob • Edited

Qualitatively it's easy to understand (at least when you have the knowledge that we have now) but mathematically it must be pretty hard to calculate/solve correctly ...

And just imagine how brilliant the old folks like Copernicus and Galilei must have been, when the contemporary view was that the earth was in the center - to depart from that view and then arrive at the only logically consistent solution to the puzzle, and deduce correctly how it really worked, just brilliant ...

Thread Thread
 
jithinks profile image
Jithin KS

Yeah, you are right. But in my opinion, even qualitative understanding is difficult if you don't use suitable pedagogical tools to explain. The first time I saw this curve was when I was in high school, it was utterly non-intuitive. How on earth is mars moving back and then forward? I always wanted to see if this is the case and when I coded this and saw the retrograde motion appearing for the first time, it was really a goosebumps moment. I wanted to share that feeling with others, hence wrote this article.

Thread Thread
 
leob profile image
leob • Edited

Yeah well it's pretty easy to understand if you realize that it's just two balls moving on concentric circles with different speeds (and different momentary positions on the circles) moving relatively to each other - you can draw half a dozen states on a piece of paper and then it already becomes obvious whence the back and forth movement ...

But what really impresses me is that someone like Galileo grokked this, while he didn't have the ready-made model at hand that we have - he had to pull the whole thing out of thin air to just "see" it - that requires a huge amount of insight, imagination and ingenuity, and "aha" brilliance :-)

Thread Thread
 
adrian271 profile image
Adrian

"I thought the concept of retrograde motion of planets was something that every astronomy students are well aware of."

The concept is taught but visual representations like this were not abundant 20 years ago. Most of class was lecture and text book and lab. There's a lot of ground to cover in astronomy and most of what I remember is about measuring light. I watched CGP Gray's "which planet is the closest?" and similarly the concepts of planet movement or there but often not realized.

Thread Thread
 
jithinks profile image
Jithin KS • Edited

Do you think there is sufficient space for this kind of visualizations in other topics in subjects like astronomy??? I'm asking this because I'm working on a project which is all about making use of interactive visualizations to improve STEM education???

Thread Thread
 
adrian271 profile image
Adrian

I totally do but I may be a bit biased as my wife is an educator and I feel like there is so much potential to improve learning. Things are progressing but not always at the right speed and across the board. So I think there is a place for them but it's hard when schools only think of things like Chromebooks as something to replace paper pencil instead of thinking how to make learning more interactive and customized to a students need. Is there a need for this stuff? absolutely.

Thread Thread
 
leob profile image
leob

Removing the teacher and just putting the pupils behind a screen isn't gonna work ... but neither is the opposite, the old style drill method where pupils sit silently for hours while the teacher is "drilling" them with endless lists of facts and boring stuff ... I'm no expert but I suppose it's gotta be a healthy mix :-)

Thread Thread
 
jithinks profile image
Jithin KS

Yes definitely, there should be some facility for the teacher to make use of this kind of interactive visualization while they teach.

dev.to/jithinks97/dynamic-learning...

This project that I'm doing has this goal in mind.

Thread Thread
 
leob profile image
leob

Got it, very nice project!