title: ray caster, cast_ray function incorrectly accounts for obscured light
body: <p>I am getting an error that says I am not accounting for obscured light and that my specular is getting added when the light is obscured.  This is what the specular part that is being added onto is with x representing r, g, orb of my Color class: light.color.x * s.finish.specular * specIntense</p>
  
  <pre><code>def in_shadow (sphere_list, sphere, ray_to_light, light):
      new_list = list()
      for s in sphere_list:
          if sphere != s:
              new_list.append(s)
      for s in new_list:
          if sphere_intersection_point(ray_to_light, s):
              x1 = ray_to_light.pt.x - light.pt.x
              y1 = ray_to_light.pt.y - light.pt.y
              z1 = ray_to_light.pt.z - light.pt.z
              dist1 = math.sqrt(x1 + y1 + z1)
              x2 = ray_to_light.pt.x - s.center.x
              y2 = ray_to_light.pt.y - s.center.y
              z2 = ray_to_light.pt.z - s.center.z
              dist2 = math.sqrt(x2 + y2 + z2)
              # distance to light, distance to sphere
              # check if distance to sphere &lt; distance to light
              # if so return 0
              if dist2 &lt; dist1:
                  return 0
      return 1
  
  def cast_ray(ray, sphere_list, color, light, point):
          # count = 0
      dist = -1
      cp = Color(1.0, 1.0, 1.0)
      for s in sphere_list:
          if sphere_intersection_point(ray, s):
              # count += 1
              p = sphere_intersection_point(ray, s)
              vec = vector_from_to(s.center, p)
              N = normalize_vector(vec)
              norm_scaled = scale_vector(N, 0.01)
              pe = translate_point(p, norm_scaled)
              l = vector_from_to(pe, light.pt)
              l_dir = normalize_vector(l)
              dot = dot_vector(N, l_dir)
              r = Ray(pe, l_dir)
              dotNScaled = dot * 2
              reflecVec = difference_vector(l_dir, scale_vector(N, dotNScaled))
              V = vector_from_to(point, pe)
              Vdir = normalize_vector(V)
              spec = dot_vector(reflecVec, Vdir)
              m = in_shadow(sphere_list, s, r, light)
              if (dot &lt;= 0):
                  m = 0
              x = (ray.pt.x - p.x) ** 2
              y = (ray.pt.y - p.y) ** 2
              z = (ray.pt.z - p.z) ** 2
              curdist = math.sqrt(x + y + z)
              # print curdist
              if (dist &lt; 0) or (dist &gt; curdist):
                  dist = curdist
                  if (spec &lt;= 0 ):
                      r =  ( s.color.r * s.finish.ambient * color.r ) \
                          + ( light.color.r * s.finish.diffuse * dot * s.color.r * m )
                      g =  ( s.color.g * s.finish.ambient * color.g ) \
                          + (light.color.g * s.finish.diffuse * dot * s.color.g * m ) 
                      b =  ( s.color.b * s.finish.ambient * color.b ) \
                          + (light.color.b * s.finish.diffuse * dot * s.color.b * m )
                      cp = Color(r, g, b)
                  if ( spec &gt;= 0 ):
                      specIntense = spec ** (1/s.finish.roughness)
                      print type(s.finish.diffuse)
                      r = (s.color.r * s.finish.ambient * color.r) \
                          + (light.color.r * s.finish.diffuse * dot * s.color.r * m) \
                          + (light.color.r * s.finish.specular * specIntense)
                      g = (s.color.g * s.finish.ambient * color.g) \
                          + (light.color.g * s.finish.diffuse * dot * s.color.g * m) \
                          + (light.color.g * s.finish.specular * specIntense)
                      b = (s.color.b * s.finish.ambient * color.b) \
                          + (light.color.b * s.finish.diffuse * dot * s.color.b * m) \
                          + (light.color.b * s.finish.specular * specIntense)
                      cp = Color(r, g, b)
      # if count &gt; 1:
          # print 'intersects two!'
      return cp
  </code></pre>
  
  <p>I think somewhere I am not accounting for the case where the sphere has another one in front of it therefore the specular part is being added to it when it shouldn't, creating this weird white light behind the first sphere that isn't supposed to be there.  I'm sure there is a bug in this code somewhere but I cannot find it.</p>