本文整理汇总了Python中tracer.tracer_engine.TracerEngine.intersect_ray方法的典型用法代码示例。如果您正苦于以下问题:Python TracerEngine.intersect_ray方法的具体用法?Python TracerEngine.intersect_ray怎么用?Python TracerEngine.intersect_ray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracer.tracer_engine.TracerEngine
的用法示例。
在下文中一共展示了TracerEngine.intersect_ray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestTraceProtocol1
# 需要导入模块: from tracer.tracer_engine import TracerEngine [as 别名]
# 或者: from tracer.tracer_engine.TracerEngine import intersect_ray [as 别名]
class TestTraceProtocol1(unittest.TestCase):
"""
Tests intersect_ray and the bundle driver with a single flat surface, not rotated, with
a single interation
"""
def setUp(self):
dir = N.array([[1,1,-1],[-1,1,-1],[-1,-1,-1],[1,-1,-1]]).T/math.sqrt(3)
position = N.c_[[0,0,1],[1,-1,1],[1,1,1],[-1,1,1]]
self._bund = RayBundle(position, dir, energy=N.ones(4))
self.assembly = Assembly()
object = AssembledObject()
object.add_surface(Surface(FlatGeometryManager(), opt.perfect_mirror))
self.assembly.add_object(object)
self.engine = TracerEngine(self.assembly)
def test_intersect_ray1(self):
surfaces = self.assembly.get_surfaces()
objects = self.assembly.get_objects()
surfs_per_obj = [len(obj.get_surfaces()) for obj in objects]
surf_ownership = N.repeat(N.arange(len(objects)), surfs_per_obj)
ray_ownership = -1*N.ones(self._bund.get_num_rays())
surfs_relevancy = N.ones((len(surfaces), self._bund.get_num_rays()), dtype=N.bool)
params = self.engine.intersect_ray(self._bund, surfaces, objects, \
surf_ownership, ray_ownership, surfs_relevancy)[0]
self.failUnless(params.all())
def test_ray_tracer(self):
"""Ray tracer after one iteration returns what the surface would have"""
params = self.engine.ray_tracer(self._bund,1,.05)[0]
correct_pts = N.zeros((3,4))
correct_pts[:2,0] = 1
N.testing.assert_array_almost_equal(params, correct_pts)
示例2: TestTraceProtocol3
# 需要导入模块: from tracer.tracer_engine import TracerEngine [as 别名]
# 或者: from tracer.tracer_engine.TracerEngine import intersect_ray [as 别名]
class TestTraceProtocol3(unittest.TestCase):
"""
Tests intersect_ray and the bundle driver with two rotated planes, with a single iteration
"""
def setUp(self):
self.x = 1/(math.sqrt(2))
dir = N.c_[[0,self.x,-self.x],[0,1,0]]
position = N.c_[[0,0,1],[0,0,1]]
self._bund = RayBundle(position, dir, energy=N.ones(2))
rot1 = general_axis_rotation([1,0,0],N.pi/4)
rot2 = general_axis_rotation([1,0,0],N.pi/(-4))
surf1 = Surface(FlatGeometryManager(), opt.perfect_mirror, rotation=rot1)
surf2 = Surface(FlatGeometryManager(), opt.perfect_mirror, rotation=rot2)
self.assembly = Assembly()
object = AssembledObject()
object.add_surface(surf1)
object.add_surface(surf2)
self.assembly.add_object(object)
self.engine = TracerEngine(self.assembly)
def test_intersect_ray(self):
surfaces = self.assembly.get_surfaces()
objects = self.assembly.get_objects()
surfs_per_obj = [len(obj.get_surfaces()) for obj in objects]
surf_ownership = N.repeat(N.arange(len(objects)), surfs_per_obj)
ray_ownership = -1*N.ones(self._bund.get_num_rays())
surfs_relevancy = N.ones((len(surfaces), self._bund.get_num_rays()), dtype=N.bool)
params = self.engine.intersect_ray(self._bund, surfaces, objects, \
surf_ownership, ray_ownership, surfs_relevancy)[0]
correct_params = N.array([[True, True],[False, False]])
N.testing.assert_array_almost_equal(params,correct_params)
def test_ray_tracer1(self):
params = self.engine.ray_tracer(self._bund, 1,.05)[0]
correct_params = N.c_[[0,.5,.5],[0,1,1]]
N.testing.assert_array_almost_equal(params,correct_params)
示例3: test_intersect_ray2
# 需要导入模块: from tracer.tracer_engine import TracerEngine [as 别名]
# 或者: from tracer.tracer_engine.TracerEngine import intersect_ray [as 别名]
def test_intersect_ray2(self):
rot = general_axis_rotation([1,0,0],N.pi/4)
surface = Surface(FlatGeometryManager(), opt.perfect_mirror, rotation=rot)
assembly = Assembly()
object = AssembledObject()
object.add_surface(surface)
assembly.add_object(object)
engine = TracerEngine(assembly)
surfaces = assembly.get_surfaces()
objects = assembly.get_objects()
surfs_per_obj = [len(obj.get_surfaces()) for obj in objects]
surf_ownership = N.repeat(N.arange(len(objects)), surfs_per_obj)
ray_ownership = -1*N.ones(self._bund.get_num_rays())
surfs_relevancy = N.ones((len(surfaces), self._bund.get_num_rays()), dtype=N.bool)
params = engine.intersect_ray(self._bund, surfaces, objects, \
surf_ownership, ray_ownership, surfs_relevancy)[0]
correct_params = N.array([[False, True, False]])
N.testing.assert_array_almost_equal(params, correct_params)