Visualizing Asteroid 2012 DA14

This week’s middle school programming class takes a slight detour into astronomy, using Python to visualize the path of asteroid 2012 DA14 as it buzzes Earth this Friday 15 February, approaching within less than 28,000 kilometers (about 17,000 miles) of our planet, “the closest ever predicted Earth approach for an object this large.”

How close is this?  What I found interesting during discussion about this fly-by was the sense of scale when comparing the “close shave” of the asteroid’s path to the orbits of various satellites, natural and artificial.  With just a few dozen lines of code, we can visually compare the size of these orbits with the path of the asteroid.  A still screenshot of the result is shown below, showing the asteroid passing inside of geostationary orbit, with a view of the orbits of GPS satellites and the International Space Station for comparison.

The asteroid's path compared with various satellite orbits.  The asteroid itself is shown at 20,000 times its actual size ("only" about half a football field in diameter).

The asteroid’s path compared with various satellite orbits. The asteroid itself is shown at 20,000 times its actual size (“only” about half a football field in diameter).

Following is the source code, which animates the rotating earth and the very simplified motion of the asteroid.

from visual import *

# Draw earth.
earth = sphere(radius=6378, material=materials.BlueMarble)

# Draw DA14 asteroid at 20000x size.
da14 = sphere(pos=[34100, -30000, 0], radius=450)

# Draw geostationary orbit.
r_geo = 42164
ring(radius=r_geo, thickness=200, axis=[0, 1, 0], color=color.yellow)
label(pos=[r_geo, 0, 0], text='GEO')

# Draw GPS orbits.
r_gps = 26600
for angle in range(0, 360, 60):
    axis = rotate(
        rotate([0, 1, 0], radians(55), [0, 0, 1]), radians(angle), [0, 1, 0])
    ring(radius=r_gps, thickness=200, axis=axis, color=color.yellow)
label(pos=[r_gps, 0, 0], text='GPS')

# Draw ISS orbit.
r_iss = 6378 + 410
axis = rotate([0, 1, 0], radians(51.6), [0, 0, 1])
ring(radius=r_iss, thickness=200, axis=axis, color=color.yellow)
label(pos=[r_iss, r_iss, 0], text='ISS')

# Animate asteroid and rotating earth at 500x speed.
fps = 10
ff = 500
while True:
    rate(fps)
    da14.pos.y = da14.pos.y + 7.82 / fps * ff
    earth.rotate(angle=radians(360.0 / 86400 / fps * ff), axis=[0, 1, 0])
    if da14.pos.y > 30000:
        da14.pos.y = -30000
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to Visualizing Asteroid 2012 DA14

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s