예제 #1
0
 def test_rotation(self):
     dir = N.array([0., 0, 1])
     center = N.array([0,  0, 0]).reshape(-1, 1) 
     R = 2
     
     rays = RB.solar_disk_bundle(1000,  center,  dir,  R,  N.pi/100.)
     self.assert_radius(rays.get_vertices(),  center,  R)
     
     dir = 1/math.sqrt(3)*N.ones(3)
     rays = RB.solar_disk_bundle(1000,  center,  dir,  R,  N.pi/100.)
     self.assert_radius(rays.get_vertices(),  center,  R)
예제 #2
0
 def test_location(self):
     dir = N.array([0., 0, 1])
     center = N.array([0,  0, 0]).reshape(-1, 1) 
     R = 2
     
     rays = RB.solar_disk_bundle(1000,  center,  dir,  R,  N.pi/100.)
     self.assert_radius(rays.get_vertices(),  center,  R)
     
     center = N.array([7,  7,  7]).reshape(-1, 1) 
     rays = RB.solar_disk_bundle(1000,  center,  dir,  R,  N.pi/100.)
     self.assert_radius(rays.get_vertices(),  center,  R)
예제 #3
0
 def test_ray_directions(self):
     """Test that the angle between the rays and the bundle direction is uniformly
     spaced, and that the rays are rotated around the bundle direction at uniformly
     distributed angles.
     """
     dir = N.array([0., 0, 1])
     center = N.array([0,  0, 0]).reshape(-1, 1) 
     R = 2; theta_max = N.pi/100.
     
     rays = RB.solar_disk_bundle(5000, center, dir, R, theta_max)
     directs = rays.get_directions()
     dir_dots = N.dot(dir, directs)
     self.assert_((dir_dots >= N.cos(theta_max)).all())
     self.assert_uniform(N.arccos(dir_dots), ub=theta_max)
     
     on_disk_plane = directs - N.outer(dir, dir_dots)
     angs = N.arctan2(on_disk_plane[0], on_disk_plane[1])
     self.assert_uniform(angs, lb=-N.pi, ub=N.pi)
예제 #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()
예제 #5
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()