'''
 Name : 

 PHYS 114 - Rec 1
 Angular momentum -
 
  1] The red dot is the orgin of the system, use this to
     calculate the angular momentum of the system below.
     Have it print that value to the screen in the label.
     See code for an example on how to do this.

  2] Place and update a green dot that represents the
     CM of the system.

  2] For the given system, notice anything unqiue about L?
     Why is this? Type answer here:



  3] Place a yellow dot in a different location and calculate
     the orgin around that point as well.    

  optional 4] Add a star or two and if you feel bold calculate the
              rotational angular momentum of the system.
'''
from visual import *

scene.autoscale = 0
scene.range = 3

# Origin
orgin  = sphere(pos=(0,0,0),radius=.1,color=color.red)
L_label= label (pos=(-1.5,2,0), text='Angular momentum is:')

stars = [sphere(radius=.1,m=1,F=vector(0,0,0)) for n in range(2)]

stars[0].pos = vector(1,0,0)
stars[1].pos = vector(0,0,0)

stars[0].v = vector(  0, .6 ,0)
stars[1].v = vector(  0,-.6,0)

dt = .0001; t = 0
while t < 4:
    for si in stars:
        si.F = vector(0,0,0)
        for sj in stars:
            if si != sj:
                r = sj.pos - si.pos
                si.F += (si.m*sj.m*r) / mag(r)**3
        si.v   += (si.F/si.m) * dt
        si.pos +=       si.v  * dt
    t += dt

    L = 0
    L_label.text = 'Angular momentum is ' + str(L)

