The motion of Earth around the Sun can be understood using basic principles of physics and mathematics. Instead of assuming a fixed circular path, the orbit naturally emerges by applying gravitational laws step by step.
At the core of this simulation is the idea that the Earth is continuously pulled toward the Sun due to gravity. This force depends on the distance between the Earth and the Sun — the farther the Earth is, the weaker the pull, and the closer it is, the stronger the pull.
To model this, we calculate:
- The distance between Earth and Sun
- The resulting gravitational acceleration
- The updated velocity of the Earth
- The new position after a small time step
These calculations are repeated many times in small increments. This method, called a numerical simulation, allows the path of the Earth to gradually form. Instead of forcing the orbit shape, the elliptical motion appears naturally from the balance between gravity and motion.
Gravity constantly pulls the Earth inward, while its velocity pushes it forward. This balance creates a stable orbit. If the speed is increased, the orbit becomes larger or may even break. If reduced, the Earth may spiral inward.
To better visualize the motion, a trailing path can be added, showing how the orbit evolves over time. This helps in understanding how continuous small updates lead to a smooth and realistic trajectory.
Video Explanation
Python Program
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
from matplotlib.collections import LineCollection
from matplotlib.patches import Circle
# --- Figure setup ---
fig, ax = plt.subplots()
ax.set_xlim(-1.5, 1.5)
ax.set_ylim(-1.5, 1.5)
ax.set_aspect("equal")
ax.axis("off")
fig.patch.set_facecolor('black')
# --- Sun (core + glow) ---
sun_glow = Circle((0, 0), 0.25, color='yellow', alpha=0.2)
sun = Circle((0, 0), 0.12, color='orange')
ax.add_patch(sun_glow)
ax.add_patch(sun)
# --- Earth (core + glow) ---
earth_glow = Circle((1, 0), 0.08, color='cyan', alpha=0.2)
earth = Circle((1, 0), 0.04, color='blue')
ax.add_patch(earth_glow)
ax.add_patch(earth)
# --- Trail ---
trail = LineCollection([], linewidths=2)
ax.add_collection(trail)
# --- Initial conditions (elliptical orbit) ---
x, y = 1.0, 0.0
vx, vy = 0.0, 0.8
dt = 0.02
points = []
MAX_POINTS = 300
def update(frame):
global x, y, vx, vy, points
# --- Gravity ---
r = np.sqrt(x**2 + y**2)
ax_g = -x / r**3
ay_g = -y / r**3
vx += ax_g * dt
vy += ay_g * dt
x += vx * dt
y += vy * dt
# --- Save path ---
points.append([x, y])
if len(points) > MAX_POINTS:
points = points[-MAX_POINTS:]
# --- Build fading trail ---
segments = []
colors = []
widths = []
for i in range(len(points) - 1):
segments.append([points[i], points[i + 1]])
alpha = i / len(points)
# Glow color (reddish near planet feel)
colors.append((1, alpha, alpha, alpha))
# Thickness grows toward planet
widths.append(0.5 + 2 * alpha)
trail.set_segments(segments)
trail.set_color(colors)
trail.set_linewidth(widths)
# --- Move Earth + glow ---
earth.center = (x, y)
earth_glow.center = (x, y)
return trail, earth, earth_glow
ani = FuncAnimation(fig, update, frames=2000, interval=20)
plt.show()
Output

