コード例 #1
0
    def _show_one_gaussian(self, gauss, engine, scale=1.0):
        """Plot one of the gaussians."""
        from mayavi.sources.api import ParametricSurface
        from mayavi.modules.api import Surface

        source = ParametricSurface()
        source.function = 'ellipsoid'
        engine.add_source(source)

        eigval, eigvec = np.linalg.eig(gauss.sigma)

        angles = rotationMatrixToEulerAngles(eigvec.T) * 180.0 / np.pi
        surface = Surface()
        source.add_module(surface)
        actor = surface.actor

        actor.property.opacity = 0.5
        actor.property.color = tuple(np.random.rand(3))
        actor.mapper.scalar_visibility = False
        actor.property.backface_culling = True
        actor.actor.orientation = np.array([0.0, 0.0, 0.0])
        actor.actor.origin = np.array([0.0, 0.0, 0.0])
        actor.actor.position = np.array(gauss.mu)
        actor.actor.scale = np.array(scale * np.sqrt(eigval))
        actor.actor.rotate_x(angles[0])
        actor.actor.rotate_y(angles[1])
        actor.actor.rotate_z(angles[2])
        return surface
コード例 #2
0
ファイル: visualization.py プロジェクト: zjmorgan/rmc-discord
 def atomic_displacement_ellipsoids(self, ux, uy, uz, 
                                    Uxx, Uyy, Uzz, Uyz, Uxz, Uxy,
                                    colors, p=0.99):
 
     self.fig.scene.disable_render = True 
     
     n_atm = ux.shape[0]
             
     for i in range(n_atm):
         
         s, a = self.__probability_ellipsoid(Uxx[i], Uyy[i], Uzz[i], 
                                             Uyz[i], Uxz[i], Uxy[i], p)
         
         source = ParametricSurface()
         source.function = 'ellipsoid'
         
         self.engine.add_source(source)
         
         surface = Surface()
         source.add_module(surface)
         
         actor = surface.actor 
         actor.property.opacity = 1.0
         actor.property.color = colors[i]
         
         actor.mapper.scalar_visibility = False 
         actor.property.backface_culling = True 
         
         actor.property.diffuse = 1.0
         actor.property.specular = 0.0
         
         actor.actor.origin = np.array([0,0,0])
         actor.actor.position = np.array([ux[i],uy[i],uz[i]])
         
         actor.actor.scale = np.array([s[0],s[1],s[2]])
         actor.actor.orientation = np.array([a[0],a[1],a[2]]) #ZXY
 
         actor.enable_texture = True
         actor.property.representation = 'surface'
         
     self.fig.scene.disable_render = False 
コード例 #3
0
def tresdeizar(X, Y, anchox, anchoy, angulo):
    engine = Engine()
    engine.start()
    scene = engine.new_scene()
    scene.scene.disable_render = True  # for speed

    visual.set_viewer(scene)

    surfaces = []
    for k in range(0, len(X)):
        source = ParametricSurface()
        source.function = 'ellipsoid'
        engine.add_source(source)

        surface = Surface()
        source.add_module(surface)

        actor = surface.actor  # mayavi actor, actor.actor is tvtk actor

        actor.property.opacity = 0.7
        actor.property.color = (0, 0, 1)  # tuple(np.random.rand(3))
        actor.mapper.scalar_visibility = False  # don't colour ellipses by their scalar indices into colour map

        actor.actor.orientation = np.array([90, angulo[k], 0
                                            ])  #* 90 #(angulo[k]) # in degrees

        actor.actor.position = np.array([X[k], Y[k], 0])
        actor.actor.scale = np.array(
            [anchox[k] / 2, anchox[k] / 2, anchoy[k] / 2])

        surfaces.append(surface)

        source.scene.background = (1.0, 1.0, 1.0)

    CellScann.set_img_3deizada(mlab)
    return mlab.show()