Beispiel #1
0
def collides_with_spheres(ray, list, pE, light):
    l = collisions.find_intersection_points(list, ray)
    d = vector_math.distance(pE, light.pt)
    s = False
    if len(l) > 0:
        for x in l:
            if vector_math.distance(x[1], pE) < d:
                s = True
    return s
Beispiel #2
0
def collides_with_spheres(ray, list, pE, light):
   l = collisions.find_intersection_points(list, ray)
   d = vector_math.distance(pE, light.pt)
   s = False
   if len(l) > 0:
      for x in l:
         if vector_math.distance(x[1], pE) < d:
            s = True
   return s
Beispiel #3
0
def find_closest_sphere(point, sphere_pair_list):
   if sphere_pair_list == []:
      return None
   closest = sphere_pair_list[0]
   distance = vector_math.distance(point, closest[1])
   for i in range(len(sphere_pair_list)):
      if vector_math.distance(point, sphere_pair_list[i][1]) < distance:
         closest = sphere_pair_list[i]
         distance = vector_math.distance(point, sphere_pair_list[i][1])
   return closest
Beispiel #4
0
def smallest_point_distance(ray, sphere_list):
    smallest = vector_math.distance(ray.pt, sphere_list[0][1])
    place = sphere_list[0]
    for x in sphere_list:
        d = vector_math.distance(ray.pt, x[1])
        if d < smallest:
            smallest = d
            place = x

    return place
Beispiel #5
0
def smallest_point_distance(ray, sphere_list):
   smallest = vector_math.distance(ray.pt, sphere_list[0][1])
   place = sphere_list[0]
   for x in sphere_list: 
      d = vector_math.distance(ray.pt, x[1])
      if d < smallest:
         smallest = d
         place = x

   return place
Beispiel #6
0
 def test_distance_1(self):
     p1 = data.Point(0, 0, 0)
     p2 = data.Point(1, 2, 2)
     self.assertAlmostEqual(vector_math.distance(p1, p2), 3)