Ejemplo n.º 1
0
 def __init__(self, center = [0,0,0], normal = [0,0,1], radius = 1):
     '''
     Constructor
     
     Parameters:
         center: center location of circle
         normal: surface normal of circle
         radius: radius of circle
     '''
     # normal should be length 1
     normal = normal/norm(normal)
     
     # create rectangular dimensions
     if normal[0] == 0 and normal[2] == 0: # normal is in y direction
         sign = normal[1] # 1 or -1
         ax1 = sign*np.array((0,0,1),dtf)
         ax2 = sign*np.array((0,1,0),dtf)
     else:
         ax1 = np.cross([0,1,0],normal) # parallel to xz-plane
         ax2 = np.cross(normal,ax1)
     
     Plane.__init__(self,origin=center,ax1=ax1,ax2=ax2)
     self.center = np.array(center,dtf)
     self.normal = np.array(normal,dtf)
     self.radius = radius
Ejemplo n.º 2
0
    def __init__(self,
                 center=[0, 0, -10],
                 width=10.302,  # 2*5.151 (max radius of default module)
                 height=10.302,
                 normal=[0, 0, 1],
                 type='atinf',
                 color=[1, 1, 1],
                 pixels=None,
                 spectrum=None
                 ):
        '''
        Constructor

        Parameters:
            center:    the center location of the source
            width:     the width of the projection rectangle (atinf or nonpoint)
            height:    the height of the projection rectangle (atinf or nonpoint)
            normal:    direction the projection rectangle is facing
            type:      'atinf', 'point', or 'nonpoint'
            color:     color of projected rays
            pixels:    optional numpy array of pixel colors (W x H x 3)
            spectrum:  optional numpy array (2xN) of energy spectrum 
        '''
        # normal should be length 1
        normal = normal / norm(normal)

        # check type
        if type not in ['atinf', 'point', 'nonpoint']:
            raise ValueError('invalid source type')

        # check dims
        if type is not 'point' and (width <= 0 or height <= 0):
            raise ValueError('atinf or nonpoint source must have positive area')

        # create rectangular dimensions
        if normal[0] == 0 and normal[2] == 0:  # normal is in y direction
            sign = normal[1]  # 1 or -1
            ax1 = sign * np.array((0, 0, width), dt)
            ax2 = sign * np.array((0, height, 0), dt)
        else:
            ax1 = np.cross([0, 1, 0], normal)  # parallel to xz-plane
            ax2 = height * np.cross(normal, ax1)
            ax1 *= width

        # calc origin
        origin = np.array(center) - (0.5 * ax1 + 0.5 * ax2)

        # instantiate
        Plane.__init__(self, origin, ax1, ax2)
        self.center = np.array(center, dt)
        self.type = type
        self.color = np.array(color, np.dtype('f4'))
        self.pixels = pixels
        self._spectrum = spectrum
        self._maximum_energy = 1000  # this is the maximum energy considered
Ejemplo n.º 3
0
    def __init__(self,
                 center=[0, 0, 230],
                 width=2,
                 height=2,
                 normal=[0, 0, 1],
                 reso=[256, 256],
                 pixels=None,
                 freqs=None,
                 ):
        '''
        Constructor

        Parameters:
            center:    the center location of the source
            width:     the width of the projection rectangle
            height:    the height of the projection rectangle
            normal:    direction the projection rectangle is facing
            reso:      resolution of pixels (W,H)
            pixels:    optional numpy array to hold pixel colors (W x H x 3)
            freqs:     optional array to count the number of times a pixel is
                       hit (W x H)
        '''
        # normal should be length 1
        normal = normal / norm(normal)

        # create rectangular dimensions
        if normal[0] == 0 and normal[2] == 0:  # normal is in y direction
            sign = normal[1]  # 1 or -1
            ax1 = sign * np.array((0, 0, width), dtf)
            ax2 = sign * np.array((0, height, 0), dtf)
        else:
            ax1 = np.cross([0, 1, 0], normal)  # parallel to xz-plane
            ax2 = height * np.cross(normal, ax1)
            ax1 *= width

        # calc origin
        origin = np.array(center) - (0.5 * ax1 + 0.5 * ax2)

        # instantiate
        Plane.__init__(self, origin, ax1, ax2)
        self.center = np.array(center, dtf)
        self.reso = reso
        self.pixels = pixels
        self.freqs = freqs
        self.rays = []

        # bring in pixels
        if pixels is None:
            self._initDetectorImage()
        elif freqs is None:
            raise ValueError('must pass freqs when passing pixels')
        elif pixels.shape[0:2] != freqs.shape:
            raise ValueError('pixels and freqs arrays do not correspond')
Ejemplo n.º 4
0
 def __init__(self, p1, p2, p3, clr, kd=0.0, ks=0.0, se=6, kr=0.0):
     """ When passing in the 3 points of the triangle, it is important that you
         specifiy the ponits in a clockwise order.
     """
     Plane.__init__(self, p1, p2, p3, clr, kd, ks, se,
                    kr)  # Call parent init