Example #1
0
    def draw(self, time, line_width=None):
        if self.hidden:
            return
        time = time * 1e-9
        if time <= self.time:
            return

        pos_start = self.pos + (self.speed * (-self.time) * self.dir)
        path = self.speed * (time - self.time) * self.dir
        if self.length:
            max_path = self.length * self.dir
            if np.linalg.norm(max_path) <= np.linalg.norm(path):
                path = max_path
        pos_end = self.pos + path

        glPushMatrix()
        if line_width:
            glLineWidth(line_width)
        else:
            glLineWidth(self.line_width)
        glColor3f(*self.color)
        glBegin(GL_LINES)
        glVertex3f(*pos_start)
        glVertex3f(*pos_end)
        glEnd()
        glPopMatrix()

        if self.cherenkov_cone_enabled and self.colourist.cherenkov_cone_enabled:

            height = np.linalg.norm(pos_end - pos_start)
            position = pos_end - self.dir * height

            glEnable(GL_LIGHTING)
            glEnable(GL_DEPTH_TEST)
            glShadeModel(GL_FLAT)
            glColor4f(0.0, 0.0, 0.8, 0.3)

            glPushMatrix()
            glTranslated(*position)
            glPushMatrix()

            v = np.array(self.dir)
            glMultMatrixf(transform(v))

            glutSolidCone(0.6691 * height, height, 128, 64)
            glPopMatrix()
            glPopMatrix()

            glDisable(GL_LIGHTING)
Example #2
0
 def draw(self, line_width=1, color=(1.0, 0.0, 0.0)):
     glEnable(GL_DEPTH_TEST)
     glEnable(GL_LINE_SMOOTH)
     glShadeModel(GL_FLAT)
     glPushMatrix()
     glLineWidth(line_width)
     glColor3f(*color)
     glBegin(GL_LINES)
     glVertex3f(-1.0, 0.0, 0.0)
     glVertex3f(1.0, 0.0, 0.0)
     glEnd()
     glPushMatrix()
     glTranslated(1.0, 0.0, 0.0)
     glRotated(90, 0.0, 1.0, 0.0)
     glutSolidCone(0.05, 0.2, 16, 16)
     glPopMatrix()
     glBegin(GL_LINES)
     glVertex3f(0.0, -1.0, 0.0)
     glVertex3f(0.0, 1.0, 0.0)
     glEnd()
     glPushMatrix()
     glTranslated(0.0, 1.0, 0.0)
     glRotated(-90, 1.0, 0.0, 0.0)
     glutSolidCone(0.05, 0.2, 16, 16)
     glPopMatrix()
     glBegin(GL_LINES)
     glVertex3f(0.0, 0.0, -1.0)
     glVertex3f(0.0, 0.0, 1.0)
     glEnd()
     glPushMatrix()
     glTranslated(0.0, 0.0, 1.0)
     glutSolidCone(0.05, 0.2, 16, 16)
     glPopMatrix()
     glPopMatrix()
Example #3
0
 def paintArrow(self, direction, color):
     d = 0.01
     length = 0.5
     glPushMatrix()
     glColor3fv(color)
     if direction == 'n':
         glTranslatef(0., -1.1, 2.)
     elif direction == 'gamma':
         glTranslatef(1.2, -1.1, 0.)
     else:
         glTranslatef(-1., -1., 1.)
     quadric = gluNewQuadric()
     if direction in ('x', 'gamma'):
         glRotatef(90., 0., 1., 0.)
     elif direction == 'y':
         glRotatef(90, -1., 0., 0.)
     elif direction in ('z', 'n'):
         glRotatef(180, -1, 0, 0)
     gluCylinder(quadric, d, d, length, 48, 48)
     glTranslatef(0, 0, length)
     glutSolidCone(2. * d, 0.1, 48, 48)
     glPopMatrix()