Main content

# Circular orbits

## Animated circles

If we assume that a planet is traveling in a $(0,0)$ and has a radius, r.

**perfect circle, how could we****simulate this motion?**First, let's assume that our circle is centered at coordinatesHow can we simulate the motion of a planet orbiting around the perimeter of a circle?

Notice the position of the planet is based on the distance from the center (

**radius r**) and the angle it has swept around the circle (**0 to 360 degrees**). These are known as**polar coordinates.**However, in order to draw this planet we need to define the planet's position using $x,y$ coordinates. These are known as

**cartesian coordinates**.The length of the triangle is $x$ , the height is $y$ , the hypotenuse is r and the angle at the origin is the planets current angle around its orbit. Now we just need to find the distance of $x$ and $y$ using basic trigonometry:

To animate the motion of a planet we can increment the angle θ by one degree at each frame and the planet will move around the origin in a circle.

✏️ The program below is an almost-working simulation of a planet orbiting around a star. Find the line of code that is currently commented out, remove the slashes, and watch it go!

## Want to join the conversation?

- Who came up with cartesian coordinates?(4 votes)
- Rene Descartes came up with the Cartesian Coordinate System. He was a brilliant mathematician but a flawed philosopher because he tried to apply math to philosophy.(5 votes)

- Great Article!

But how can i achieve this for a elliptical orbit?

Thanks ! :D(3 votes) - i dont understand this i dont like this part in math(2 votes)
- It'd be useful to provide quick definitions of cosine and sine in the article. In a right angled triangle, the cosine of an angle is the length of the adjacent side divided by the length of the hypotenuse. In a right angled triangle, the sine of an angle is the length of the opposite side divided by the length of the hypotenuse.(2 votes)
- that is a factual statement.(1 vote)

- Why! why does this have to be so haaardddd!(1 vote)
- Could there be any chance the Mr. Khan could make a video for these concepts because it is a bit confusing just reading it.(1 vote)
- I feel like this article is very awful. I am still at a total loss of how to code a circular orbit, can anyone help me?(1 vote)
- You don't need to know how to code a circular orbit for this lesson.(1 vote)

- Is it at all possible to change the coding to get it to show the solar system in this orbit? A.K.A just to get it in a higher resolution and add things to scale?(1 vote)
- what is t in the equation(x = t x cos (0)) ?(1 vote)
- I think there may be a typo in the description before the equation. Here, _t_ should be the radius of the circle.(1 vote)

- Is there a quicker way to do this(1 vote)