from __future__ import division
from visual import *
from visual.graph import *
from physutil import *

#Window setup
scene.range=7e7
scene.width = 1024
scene.height = 760

#Objects
Earth = sphere(pos=vector(0,0,0), radius=6.4e6, material=materials.BlueMarble)
Satellite = sphere(pos=vector(7*Earth.radius, 0,0), radius=1e6, color=color.red, make_trail=True)

#Parameters and Initial Conditions
mSatellite = 1
pSatellite = vector(0,5000,0)

#Time and time step
t = 0
tf = 60*60*24
dt = 1

#MotionMap/Graph
SatelliteMotionMap = MotionMap(Satellite, tf, 20, markerScale=2000, labelMarkerOrder=False)

#Calculation Loop
while t < tf:
	rate(10000)

	Fnet = vector(0,0,0)

	pSatellite = pSatellite + Fnet*dt
	Satellite.pos = Satellite.pos + (pSatellite/mSatellite)*dt

	SatelliteMotionMap.update(t, pSatellite/mSatellite)

	t = t + dt

	#Earth Rotation (IGNORE)
	theta = 7.29e-5*dt
	Earth.rotate(angle=theta, axis=vector(0,0,1), origin=Earth.pos)