If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

## NASA

### Unit 2: Lesson 3

Orbital mechanics

# Circular orbits

## Animated circles

If we assume that a planet is traveling in a perfect circle, how could we simulate this motion? First, let's assume that our circle is centered at coordinates left parenthesis, 0, comma, 0, right parenthesis and has a radius, r.
Planet radius r away from the center of the circle (0,0)
How can we simulate the motion of a planet orbiting around the perimeter of a circle?
Sweeping a planet around the circumference
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, comma, y coordinates. These are known as cartesian coordinates.
Cartesian coordinates of the planet's position (x,y)
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:
\begin{aligned} x = t \times cos(\theta) \\ y = t \times sin(\theta) \\ \end{aligned}
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!