コード例 #1
0
ファイル: TestBoxIntersection.py プロジェクト: danhp/socs
 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)
コード例 #2
0
ファイル: TestSphereIntersection.py プロジェクト: danhp/socs
 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)
コード例 #3
0
ファイル: TestBoxIntersection.py プロジェクト: danhp/socs
 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)
コード例 #4
0
 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)
コード例 #5
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)
コード例 #6
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])
コード例 #7
0
ファイル: TestBoxIntersection.py プロジェクト: danhp/socs
 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)
コード例 #8
0
ファイル: TestPlaneIntersection.py プロジェクト: danhp/socs
 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])
コード例 #9
0
ファイル: TestSphereIntersection.py プロジェクト: danhp/socs
 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])
コード例 #10
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)
コード例 #11
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)
コード例 #12
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])                                      
コード例 #13
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)
コード例 #14
0
ファイル: TestSphereIntersection.py プロジェクト: danhp/socs
 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)
コード例 #15
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)
コード例 #16
0
ファイル: TestSphereIntersection.py プロジェクト: danhp/socs
 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)
コード例 #17
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)
コード例 #18
0
ファイル: TestBoxIntersection.py プロジェクト: danhp/socs
 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)
コード例 #19
0
ファイル: TestSphereIntersection.py プロジェクト: danhp/socs
 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)
コード例 #20
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)
コード例 #21
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)
     # 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)
コード例 #22
0
ファイル: TestSphereIntersection.py プロジェクト: danhp/socs
 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.))
コード例 #23
0
ファイル: TestSphereIntersection.py プロジェクト: danhp/socs
 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)
コード例 #24
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)
コード例 #25
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.))