Exemplo n.º 1
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)
Exemplo n.º 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)
Exemplo n.º 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()
Exemplo n.º 4
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()