Ejemplo n.º 1
0
 def addPolygon(self, polygon, colour=None, opacity=1.):
     if not Visualiser.VISUALISER_ON:
         return
     if isinstance(polygon, Polygon):
         if colour == None:
             visual.convex(pos=polygon.pts, color=norm([0.1,0.1,0.1]))
         else:
             visual.convex(pos=polygon.pts, color=norm(colour))
Ejemplo n.º 2
0
 def addConvex(self, convex, colour=None, opacity=1.):
     """docstring for addConvex"""
     if not Visualiser.VISUALISER_ON:
         return
     if isinstance(convex, Convex):
         if colour == None:
             print("Color is none")
             visual.convex(pos=convex.points, color=norm([0.1,0.1,0.1]))
         else:
             #import pdb; pdb.set_trace()
             print("Colour is", norm(colour))
             visual.convex(pos=convex.points, color=norm(colour))
Ejemplo n.º 3
0
    def photon(self):
        photon = Photon()
        photon.source = self.source_id
        photon.position = np.array(self.position)
        photon.direction = np.array(self.direction)
        photon.active = True
        photon.wavelength = self.wavelength

        # If use_polarisation is set generate a random polarisation vector of the photon
        if self.use_random_polarisation:

            # Randomise rotation angle around xy-plane, the transform from +z to the direction of the photon
            vec = random_spherical_vector()
            vec[2] = 0.
            vec = norm(vec)
            r = rotation_matrix_from_vector_alignment(self.direction,
                                                      [0., 0., 1.])
            photon.polarisation = transform_direction(vec, r)

        else:
            photon.polarisation = None

        photon.id = self.throw
        self.log.debug('Emitted photon (pid: ' + str(self.throw) + ')')
        self.throw += 1
        return photon
Ejemplo n.º 4
0
    def photon(self):
        photon = Photon()
        photon.source = self.source_id
        photon.position = np.array(self.position)
        photon.direction = np.array(self.direction)
        photon.active = True
        photon.wavelength = self.wavelength

        # If use_polarisation is set generate a random polarisation vector of the photon
        if self.use_random_polarisation:

            # Randomise rotation angle around xy-plane, the transform from +z to the direction of the photon
            vec = random_spherical_vector()
            vec[2] = 0.
            vec = norm(vec)
            r = rotation_matrix_from_vector_alignment(self.direction, [0., 0., 1.])
            photon.polarisation = transform_direction(vec, r)

        else:
            photon.polarisation = None

        photon.id = self.throw
        self.log.debug('Emitted photon (pid: ' + str(self.throw)+')')
        self.throw += 1
        return photon
Ejemplo n.º 5
0
 def addRay(self, ray, colour=None, opacity=1.):
     if not Visualiser.VISUALISER_ON:
         return
     if isinstance(ray, Ray):
         if colour == None:
             colour = visual.color.white
         pos = ray.position
         axis = ray.direction * 5
         visual.cylinder(pos=pos, axis=axis, radius=0.0001, color=norm(colour), opacity=opacity)
Ejemplo n.º 6
0
 def addLine(self, start, stop, colour=None, opacity=1.):
     if not Visualiser.VISUALISER_ON:
         return
     if colour is None:
         colour = visual.color.white
     colour = visual.vec(*colour)
     axis = np.array(stop) - np.array(start)
     axis = visual.vec(*axis.tolist())
     start = visual.vec(*tuple(start))
     visual.cylinder(pos=start, axis=axis, radius=0.0001, color=norm(colour), opacity=opacity)
Ejemplo n.º 7
0
 def addSmallSphere(self, point, colour=None, opacity=1.0):
     if not Visualiser.VISUALISER_ON:
         return
     if colour is None:
         colour = visual.color.blue
     try:
         colour = visual.vec(*colour)
     except TypeError:
         pass
     point = tuple(point)
     pos = visual.vec(*point)
     visual.sphere(pos=pos, radius=0.00012, color=norm(colour), opacity=opacity)
Ejemplo n.º 8
0
 def addSphere(self, sphere, colour=None, opacity=1.):
     """docstring for addSphere"""
     if not Visualiser.VISUALISER_ON:
         return
     
     if isinstance(sphere, Sphere):
         if colour == None:
             colour = visual.color.red
         if np.allclose(np.array(colour), np.array([0,0,0])):
             visual.sphere(pos=visual.vec(sphere.centre), radius=sphere.radius, opacity=opacity)
         else:
             visual.sphere(pos=visual.vec(sphere.centre), radius=sphere.radius, color=norm(colour), opacity=opacity)