Beispiel #1
0
 def test_ray_intersection_back(self):
     origin = [0, 0, -10]
     direction = [0, 0, 1]
     test_intersection_with_result(self.box, origin, direction, 
                                   isect_pt = [0, 0, -0.5], 
                                   isect_normal = [0, 0, -1], 
                                   isect_dist = 9.5)
Beispiel #2
0
 def test_ray_intersection_inside_sphere(self):
     ''' eye is inside the sphere and ray intersect the inside of the sphere '''
     test_intersection_with_result(self.sphere, origin=[0, 0, 0], 
                                   direction=[0, 0, 1],
                                   isect_pt = [0, 0, 1], 
                                   isect_normal=[0, 0, 1],
                                   isect_dist = self.radius)
Beispiel #3
0
 def test_ray_intersection_left(self):
     origin = [-10, 0, 0]
     direction = [1, 0, 0]
     test_intersection_with_result(self.box, origin, direction, 
                                   isect_pt = [-0.5, 0, 0], 
                                   isect_normal = [-1, 0, 0], 
                                   isect_dist = 9.5)
 def test_basic_ray_intersection_on_zaxis(self):
     ''' shoot a ray from a point on the z-axis towards the center '''
     test_intersection_with_result(self.scene_node, origin=[0, 0, 10], 
                                   direction=[0, 0, -1],
                                   isect_pt = [0, 0, 2], 
                                   isect_normal=[0, 0, 1],
                                   isect_dist = 8.0)
 def test_ray_intersection_inside_sphere(self):
     ''' eye is inside the sphere and ray intersect the inside of the sphere '''
     test_intersection_with_result(self.sphere, origin=[0, 0, 0],
                                   direction=[0, 0, 1],
                                   isect_pt = [0, 0, 1],
                                   isect_normal=[0, 0, 1],
                                   isect_dist = self.radius)
 def test_ray_touches_sphere(self):
     ''' test when ray just touches the sphere '''
     origin = [1, 0, 5]
     test_intersection_with_result(self.sphere, origin=origin,
                                   direction=[0, 0, -1],
                                   isect_pt=[1, 0, 0],
                                   isect_normal=[1, 0, 0],
                                   isect_dist=origin[2])
Beispiel #7
0
 def test_ray_intersection_bottom(self):
     ''' intersection at the bottom of the box '''
     origin = [0, -10, 0]
     direction = [0, 1, 0]
     test_intersection_with_result(self.box, origin, direction, 
                                   isect_pt = [0, -0.5, 0], 
                                   isect_normal = [0, -1., 0], 
                                   isect_dist = 9.5)
Beispiel #8
0
 def test_parallel_to_normal_view_direction(self):
     eye = [0, 10, 0]
     viewDir = [0, -1, 0]
     test_intersection_with_result(self.plane, origin=eye, 
                                   direction=viewDir,
                                   isect_pt = [0, 0, 0], 
                                   isect_normal=self.normal,
                                   isect_dist = eye[1])
Beispiel #9
0
 def test_ray_touches_sphere(self):
     ''' test when ray just touches the sphere '''
     origin = [1, 0, 5]
     test_intersection_with_result(self.sphere, origin=origin, 
                                   direction=[0, 0, -1],
                                   isect_pt = [1, 0, 0], 
                                   isect_normal=[1, 0, 0],
                                   isect_dist = origin[2])
 def test_intersection_pos_diag_ray(self):
     ''' Shoots a ray from some point not on the axis '''
     eye = [1, 0, 1]
     viewDir = [-1, 0, -1]
     test_intersection_with_result(self.sphere, origin=eye,
                                   direction=viewDir,
                                   isect_pt = [np.cos(np.pi/4.), 0., np.sin(np.pi/4.)],
                                   isect_normal= [np.cos(np.pi/4.), 0., np.sin(np.pi/4.)],
                                   isect_dist = np.sqrt(2.) - self.radius)
 def test_basic_ray_intersection(self):
     ''' shoot a ray from a point on the z-axis towards the center '''
     eye = [0, 0, 10]
     viewDir = [0, 0, -1]
     test_intersection_with_result(self.sphere, origin=eye,
                                   direction=viewDir,
                                   isect_pt = [0., 0., 1.],
                                   isect_normal= [0., 0., 1.],
                                   isect_dist = 9.0)
 def test_basic_ray_intersection_parallel_to_zaxis(self):
     ''' shoot a ray from a point on the z-axis towards the center '''
     expected_pt = [0.0, 2.0, 0.0]
     expected_normal = GT.normalize(expected_pt)
     test_intersection_with_result(self.scene_node, origin=[0, 2, 10], 
                                   direction=[0, 0, -1],
                                   isect_pt = expected_pt, 
                                   isect_normal= expected_normal,
                                   isect_dist = 10 - expected_pt[2])                                      
 def test_ray_intersection_back(self):
     origin = [0, 0, -10]
     direction = [0, 0, 1]
     test_intersection_with_result(self.box,
                                   origin,
                                   direction,
                                   isect_pt=[0, 0, -0.5],
                                   isect_normal=[0, 0, -1],
                                   isect_dist=9.5)
Beispiel #14
0
 def test_intersection_pos_diag_ray(self):
     ''' Shoots a ray from some point not on the axis ''' 
     eye = [1, 0, 1]
     viewDir = [-1, 0, -1]
     test_intersection_with_result(self.sphere, origin=eye, 
                                   direction=viewDir,
                                   isect_pt = [np.cos(np.pi/4.), 0., np.sin(np.pi/4.)], 
                                   isect_normal= [np.cos(np.pi/4.), 0., np.sin(np.pi/4.)],
                                   isect_dist = np.sqrt(2.) - self.radius)
 def test_ray_intersection_left(self):
     origin = [-10, 0, 0]
     direction = [1, 0, 0]
     test_intersection_with_result(self.box,
                                   origin,
                                   direction,
                                   isect_pt=[-0.5, 0, 0],
                                   isect_normal=[-1, 0, 0],
                                   isect_dist=9.5)
Beispiel #16
0
 def test_basic_ray_intersection(self):
     ''' shoot a ray from a point on the z-axis towards the center '''
     eye = [0, 0, 10]
     viewDir = [0, 0, -1]
     test_intersection_with_result(self.sphere, origin=eye, 
                                   direction=viewDir,
                                   isect_pt = [0., 0., 1.], 
                                   isect_normal= [0., 0., 1.],
                                   isect_dist = 9.0)
 def test_ray_intersection_bottom(self):
     ''' intersection at the bottom of the box '''
     origin = [0, -10, 0]
     direction = [0, 1, 0]
     test_intersection_with_result(self.box,
                                   origin,
                                   direction,
                                   isect_pt=[0, -0.5, 0],
                                   isect_normal=[0, -1., 0],
                                   isect_dist=9.5)
Beispiel #18
0
 def test_ray_intersection_to_corner_maxpt(self):
     origin = [10, 10, 10]
     direction = [-1, -1, -1]
     expected_pt = [0.5, 0.5, 0.5]
     expected_normal = None
     expected_dist = 10 * np.sqrt(3) - np.linalg.norm(expected_pt)
     test_intersection_with_result(self.box, origin, direction, 
                                   isect_pt = expected_pt, 
                                   isect_normal = expected_normal, 
                                   isect_dist = expected_dist)
Beispiel #19
0
 def test_intersection_neg_diag_ray(self):
     ''' Shoots a ray from some point not on the axis from the opposite 
     direction i.e. neg eye coord. The points and normals should have
     opposite sign but the distance from eye should be the same ''' 
     eye = [-1, 0, -1]
     viewDir = [1, 0, 1]
     test_intersection_with_result(self.sphere, origin=eye, 
                                   direction=viewDir,
                                   isect_pt = [-np.cos(np.pi/4.), 0., -np.sin(np.pi/4.)], 
                                   isect_normal= [-np.cos(np.pi/4.), 0., -np.sin(np.pi/4.)],
                                   isect_dist = np.sqrt(2.) - self.radius)
 def test_intersection_neg_diag_ray(self):
     ''' Shoots a ray from some point not on the axis from the opposite
     direction i.e. neg eye coord. The points and normals should have
     opposite sign but the distance from eye should be the same '''
     eye = [-1, 0, -1]
     viewDir = [1, 0, 1]
     test_intersection_with_result(self.sphere, origin=eye,
                                   direction=viewDir,
                                   isect_pt = [-np.cos(np.pi/4.), 0., -np.sin(np.pi/4.)],
                                   isect_normal= [-np.cos(np.pi/4.), 0., -np.sin(np.pi/4.)],
                                   isect_dist = np.sqrt(2.) - self.radius)
 def test_ray_intersection_to_corner_maxpt(self):
     origin = [10, 10, 10]
     direction = [-1, -1, -1]
     expected_pt = [0.5, 0.5, 0.5]
     expected_normal = None
     expected_dist = 10 * np.sqrt(3) - np.linalg.norm(expected_pt)
     # import pdb;pdb.set_trace()
     test_intersection_with_result(self.box,
                                   origin,
                                   direction,
                                   isect_pt=expected_pt,
                                   isect_normal=expected_normal,
                                   isect_dist=expected_dist)
Beispiel #22
0
 def test_ray_originates_on_sphere_goes_inside_v2(self):
     test_intersection_with_result(self.sphere, origin=[1, 0, 0], 
                                   direction=[-1, 1, 0],
                                   isect_pt = [0, 1, 0], 
                                   isect_normal=GT.normalize([0, 1, 0]),
                                   isect_dist = np.sqrt(2.))
Beispiel #23
0
 def test_ray_originates_on_sphere_goes_inside(self):
     test_intersection_with_result(self.sphere, origin=[1, 0, 0], 
                                   direction=[-1, 0, 0],
                                   isect_pt = [-self.radius, 0, 0], 
                                   isect_normal=GT.normalize([-self.radius, 0, 0]),
                                   isect_dist = 2. * self.radius)
 def test_ray_originates_on_sphere_goes_inside(self):
     test_intersection_with_result(self.sphere, origin=[1, 0, 0],
                                   direction=[-1, 0, 0],
                                   isect_pt = [-self.radius, 0, 0],
                                   isect_normal=GT.normalize([-self.radius, 0, 0]),
                                   isect_dist = 2. * self.radius)
 def test_ray_originates_on_sphere_goes_inside_v2(self):
     test_intersection_with_result(self.sphere, origin=[1, 0, 0],
                                   direction=[-1, 1, 0],
                                   isect_pt = [0, 1, 0],
                                   isect_normal=GT.normalize([0, 1, 0]),
                                   isect_dist = np.sqrt(2.))