def create_rainbow_sun_angle(droplet_centre_z=100.0, droplet_radius=40.0, sun_angle=45.0, lambda_no=10):
    """
    droplet_centre_z - float argument, determines droplet centre.
    droplet_radius - float argument, determines droplet radius.
    sun_angle - float argument, given in degrees, determines the angle the sun 
    makes with a point a radius of the droplet behind of the droplet.
    lambda_no - integer argument, determines the number of component wavelengths
    in the white light sent into the droplet.
    
    Plots a 2D x-z plane of the white light refracting and reflecting through
    the water droplet to form a rainbow.
    """
    if sun_angle >= 30.0 or sun_angle <= -30.0:
        raise Exception("Rays must be sent into the droplet to form rainbow.")
    px_init = np.absolute((droplet_centre_z + 2 * droplet_radius) * np.tan(np.radians(sun_angle)))
    k_init = [-px_init, 0, (droplet_centre_z + 2 * droplet_radius)]

    droplet = opt.Droplet([0, 0, droplet_centre_z], droplet_radius)

    colour_generator = iter(plt.cm.rainbow(np.linspace(0, 1, lambda_no)))
    for ray in white_light(px_init, k_init, lambda_no):
        colour = next(colour_generator)
        while ray._reachedOutputPlane is False:
            ray.propagate([droplet], True, colour)
    rtplot.plotDroplet2D(droplet_centre_z, 0.0, droplet_radius)
def create_rainbow(droplet_centre_z=100.0, droplet_radius=40.0, px=35, lambda_no=10):
    """
    droplet_centre_z - float argument, determines droplet centre.
    droplet_radius - float argument, determines droplet radius.
    px - float argument, determines initial x position of white light ray.
    lambda_no - integer argument, determines the number of component wavelengths
    in the white light sent into the droplet.
    
    Plots a 2D x-z plane of the white light refracting and reflecting through
    the water droplet to form a rainbow. The ray sent into the droplet is always
    parallel to the z axis.
    """
    if px >= droplet_radius or px <= -droplet_radius:
        raise Exception("Rays must be sent into the droplet to form rainbow.")
    droplet = opt.Droplet([0, 0, droplet_centre_z], droplet_radius)

    colour_generator = iter(plt.cm.rainbow(np.linspace(1, 0, lambda_no)))
    for ray in white_light(px, [0, 0, 1], lambda_no):
        colour = next(colour_generator)
        while ray._reachedOutputPlane is False:
            ray.propagate([droplet], True, colour)
    rtplot.plotDroplet2D(droplet_centre_z, 0.0, droplet_radius)