コード例 #1
0
ファイル: test_flat_surface.py プロジェクト: jasminef/tracer
class TestTraceProtocol(unittest.TestCase):
    def setUp(self):
        self._surf = FlatSurface()
        
        dir = N.array([[1, 1, -1], [-1, 1, -1], [-1, -1, -1], [1, -1, -1]]).T / math.sqrt(3)
        position = c_[[0,0,1], [1,-1,1], [1,1,1], [-1,1,1]]
        
        self._bund = RayBundle()
        self._bund.set_vertices(position)
        self._bund.set_directions(dir)
        
    def test_register_incoming(self):
        """A simple bundle is registered correctly"""
        correct_params = r_[[math.sqrt(3)]*3]
        params = self._surf.register_incoming(self._bund)
        
        self.failUnless(params[0] == N.inf)
        N.testing.assert_array_almost_equal(params[1:], correct_params)
コード例 #2
0
class TestTraceProtocol(unittest.TestCase):
    def setUp(self):
        self._surf = FlatSurface()

        dir = N.array([[1, 1, -1], [-1, 1, -1], [-1, -1, -1], [1, -1, -1]
                       ]).T / math.sqrt(3)
        position = c_[[0, 0, 1], [1, -1, 1], [1, 1, 1], [-1, 1, 1]]

        self._bund = RayBundle()
        self._bund.set_vertices(position)
        self._bund.set_directions(dir)

    def test_register_incoming(self):
        """A simple bundle is registered correctly"""
        correct_params = r_[[math.sqrt(3)] * 3]
        params = self._surf.register_incoming(self._bund)

        self.failUnless(params[0] == N.inf)
        N.testing.assert_array_almost_equal(params[1:], correct_params)
コード例 #3
0
import numpy as N
import pylab as P

import ray_bundle
from flat_surface import FlatSurface

# Create ray bundle
dir = N.array([0., 0, -1])
center = N.array([0, 0, 2]).reshape(-1, 1)
bund = ray_bundle.solar_disk_bundle(5000, center, dir, 2, N.pi / 1000.)

# Intersect the bundle with a flat surface
surf = FlatSurface()
inters = ~N.isinf(surf.register_incoming(bund))

# Show non-intersecting rays
v = bund.get_vertices()[:, ~inters]
d = bund.get_directions()[:, ~inters]
P.quiver(v[0], v[1], d[0], d[1], scale=0.1)

# Show returning rays.
outg = surf.get_outgoing(inters)
v = outg.get_vertices()
d = outg.get_directions()
P.quiver(v[0], v[1], d[0], d[1], scale=0.2, color='red')

P.show()
コード例 #4
0
ファイル: bundle_driver.py プロジェクト: jasminef/tracer
import numpy as N
import pylab as P

import ray_bundle
from flat_surface import FlatSurface

# Create ray bundle
dir = N.array([0., 0, -1])
center = N.array([0,  0, 2]).reshape(-1, 1)
bund = ray_bundle.solar_disk_bundle(5000,  center,  dir,  2,  N.pi/1000.)

# Intersect the bundle with a flat surface
surf = FlatSurface()
inters = ~N.isinf(surf.register_incoming(bund))

# Show non-intersecting rays
v = bund.get_vertices()[:, ~inters]
d = bund.get_directions()[:, ~inters]
P.quiver(v[0], v[1], d[0], d[1], scale=0.1)

# Show returning rays.
outg = surf.get_outgoing(inters)
v = outg.get_vertices()
d = outg.get_directions()
P.quiver(v[0], v[1], d[0], d[1],  scale=0.2, color='red')

P.show()