# lec07.py
# Lillian Lee (LJL2) and Steve Marschner (SRM2)
# Feb 13, 2014

"""Demo for lecture 7, reinforcing frame concepts and associated notation"""

import tuple3d # for the 'rescale' example

lt_speed = 3e8 #speed o' light

def v_p_try1():
    """Changes lt_speed, supposedly"""
    lt_speed = 42.0


def v_p_try2(new):
    """Changes lt_speed to new, supposedly"""
    lt_speed = new


def v_p_try3(lt_speed):
    """Changes lt_speed to 42.0, supposedly"""
    lt_speed = 42.0

def boring(new):
    """Returns new"""
    return new


def rescale(pt):
    """Shift pt to lie on the unit sphere.

    Precond: pt is a Point object"""
    norm  = pt.distanceTo(tuple3d.Point(0,0,0))
    pt.x = pt.x / norm
    pt.y = pt.y / norm
    pt.z = pt.z / norm


if __name__ == '__main__':
    """Show the effect of the various functions we've written"""

    print "lt_speed starts:", lt_speed

    v_p_try1()
    raw_input("Press return to see lt_speed after v_p_try1().")
    print lt_speed

    n = 42.0
    v_p_try2(n)
    raw_input("Press return to see lt_speed after v_p_try2(" + str(n) + ").")
    print lt_speed

    v_p_try3(lt_speed)
    raw_input("Press return to see lt_speed after v_p_try3(lt_speed).")
    print lt_speed

    n = -42
    lt_speed = boring(n)
    raw_input("Press return to see lt_speed after lt_speed = boring(" + str(n) + ").")
    print str(lt_speed)

    p = tuple3d.Point(0,3,4)
    print '\nP before rescale is called:', p
    raw_input("Press return to see what happens after rescale is called.")
    p_new = rescale(p) # don't need to say "lec07.rescale" inside the module lec07
    print 'p after rescale is called:', p
    print 'p_new is', p_new