How to use the mayavi.mlab.quiver3d function in mayavi

To help you get started, we’ve selected a few mayavi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TAMS-Group / TeachNet_Teleoperation / ros / src / shadow_teleop / scripts / human_robot_mappingfile.py View on Github external
mf_palm = points[3] - points[0]
    rf_palm = points[4] - points[0]
    lf_palm = points[5] - points[0]
    # palm = np.array([tf_palm, ff_palm, mf_palm, rf_palm, lf_palm])
    palm = np.array([ff_palm, mf_palm, rf_palm, lf_palm])

    # local wrist frame build
    wrist_z = np.mean(palm, axis=0)
    wrist_z /= np.linalg.norm(wrist_z)
    wrist_y = np.cross(lf_palm, rf_palm)
    wrist_y /= np.linalg.norm(wrist_y)
    wrist_x = np.cross(wrist_y, wrist_z)
    if np.linalg.norm(wrist_x) != 0:
        wrist_x /= np.linalg.norm(wrist_x)

    mlab.quiver3d(points[0][0], points[0][1], points[0][2], wrist_x[0], wrist_x[1], wrist_x[2],
                  scale_factor=50, line_width=0.5, color=(1, 0, 0), mode='arrow')
    mlab.quiver3d(points[0][0], points[0][1], points[0][2], wrist_y[0], wrist_y[1], wrist_y[2],
                  scale_factor=50, line_width=0.5, color=(0, 1, 0), mode='arrow')
    mlab.quiver3d(points[0][0], points[0][1], points[0][2], wrist_z[0], wrist_z[1], wrist_z[2],
                  scale_factor=50, line_width=0.5, color=(0, 0, 1), mode='arrow')
github mne-tools / mne-python / mne / viz.py View on Github external
if labels is None:
            c = six.advance_iterator(colors)
        else:
            # if vertex is in different stcs than take label from first one
            c = colors[labels[ind[0]][vertnos[ind[0]] == v]]

        mode = modes[1] if is_common else modes[0]
        scale_factor = scale_factors[1] if is_common else scale_factors[0]

        if (isinstance(scale_factor, (np.ndarray, list, tuple))
            and len(unique_vertnos) == len(scale_factor)):
            scale_factor = scale_factor[idx]

        x, y, z = points[v]
        nx, ny, nz = normals[v]
        mlab.quiver3d(x, y, z, nx, ny, nz, color=color_converter.to_rgb(c),
                      mode=mode, scale_factor=scale_factor)

        for k in ind:
            vertno = vertnos[k]
            mask = (vertno == v)
            assert np.sum(mask) == 1
            linestyle = linestyles[k]
            plt.plot(1e3 * stc.times, 1e9 * stcs[k].data[mask].ravel(), c=c,
                     linewidth=linewidth, linestyle=linestyle)

    plt.xlabel('Time (ms)', fontsize=18)
    plt.ylabel('Source amplitude (nAm)', fontsize=18)

    if fig_name is not None:
        plt.title(fig_name)
github jeffmahler / GPIS / src / grasp_selection / grasp.py View on Github external
def visualize(self, obj, arrow_len=0.01, line_width=20.0):
        """ Display point grasp as arrows on the contact points of the mesh """
        contacts_found, contacts = self.close_fingers(obj)

        if contacts_found:
            c1_world = contacts[0].point
            c2_world = contacts[1].point
            v = c2_world - c1_world
            v = arrow_len * v / np.linalg.norm(v)
            mv.quiver3d(c1_world[0] - v[0], c1_world[1] - v[1], c1_world[2] - v[2], v[0], v[1], v[2], scale_factor=1.0,
                        mode='arrow', line_width=line_width)
            mv.quiver3d(c2_world[0] + v[0], c2_world[1] + v[1], c2_world[2] + v[2], -v[0], -v[1], -v[2], scale_factor=1.0,
                        mode='arrow', line_width=line_width)
github obspy / obspy / obspy / imaging / source.py View on Github external
norms /= np.max(np.abs(norms))

    # make sphere to block view to the other side of the beachball
    rad = 0.8
    pi = np.pi
    cos = np.cos
    sin = np.sin
    phi, theta = np.mgrid[0:pi:101j, 0:2 * pi:101j]

    x = rad * sin(phi) * cos(theta)
    y = rad * sin(phi) * sin(theta)
    z = rad * cos(phi)

    # p wave radiation pattern
    mlab.figure(size=(800, 800), bgcolor=(0, 0, 0))
    pts1 = mlab.quiver3d(points[0], points[1], points[2],
                         dispp[0], dispp[1], dispp[2],
                         scalars=normp, vmin=-1., vmax=1.)
    pts1.glyph.color_mode = 'color_by_scalar'
    mlab.plot3d(*neg_nodalline, color=(0, 0.5, 0), tube_radius=0.01)
    mlab.plot3d(*pos_nodalline, color=(0, 0.5, 0), tube_radius=0.01)
    mlab.mesh(x, y, z, color=(0, 0, 0))

    # s wave radiation pattern
    mlab.figure(size=(800, 800), bgcolor=(0, 0, 0))
    pts2 = mlab.quiver3d(points[0], points[1], points[2],
                         disps[0], disps[1], disps[2], scalars=norms,
                         vmin=-0., vmax=1.)
    pts2.glyph.color_mode = 'color_by_scalar'
    mlab.plot3d(*neg_nodalline, color=(0, 0.5, 0), tube_radius=0.01)
    mlab.plot3d(*pos_nodalline, color=(0, 0.5, 0), tube_radius=0.01)
    mlab.mesh(x, y, z, color=(0, 0, 0))
github espressomd / espresso / src / python / espressomd / visualization.py View on Github external
def __init__(self, system):
		"""Constructor.
		**Arguments**

		:system: instance of espressomd.System
		"""
		self.system = system

		# objects drawn
		self.points = mlab.quiver3d([],[],[], [],[],[], scalars=[], mode="sphere", scale_factor=1, name="Particles")
		self.points.glyph.color_mode = 'color_by_scalar'
		self.points.glyph.glyph_source.glyph_source.center = [0, 0, 0]
		self.box = mlab.outline(extent=(0,0,0,0,0,0), color=(1,1,1), name="Box")
		self.arrows = mlab.quiver3d([],[],[], [],[],[], scalars=[], mode="2ddash", scale_factor=1, name="Bonds")
		self.arrows.glyph.color_mode = 'color_by_scalar'

		# state
		self.data = None
		self.last_N = 1
		self.last_Nbonds = 1
		self.last_boxl = [0,0,0]
		self.running = False
		self.last_T = None

		# GUI window
		self.gui = GUI()
		self.timers = [Timer(100, self._draw)]
github the-virtual-brain / tvb-library / tvb / simulator / plot / mayavi_tools.py View on Github external
def surface_orientation(surface, normals="triangles", name=None):
        """
        """
        fig = mlab.figure(figure=name, fgcolor=(0.5, 0.5, 0.5))
        surf_mesh = mlab.triangular_mesh(surface.vertices[:, 0],
                                         surface.vertices[:, 1],
                                         surface.vertices[:, 2],
                                         surface.triangles,
                                         color=(0.7, 0.67, 0.67),
                                         figure=fig)
        surf_orient = None
        if normals == "triangles":
            surf_orient = mlab.quiver3d(surface.triangle_centres[:, 0],
                                        surface.triangle_centres[:, 1],
                                        surface.triangle_centres[:, 2],
                                        surface.triangle_normals[:, 0],
                                        surface.triangle_normals[:, 1],
                                        surface.triangle_normals[:, 2])
        elif normals == "vertices":
            surf_orient = mlab.quiver3d(surface.vertices[:, 0],
                                        surface.vertices[:, 1],
                                        surface.vertices[:, 2],
                                        surface.vertex_normals[:, 0],
                                        surface.vertex_normals[:, 1],
                                        surface.vertex_normals[:, 2])
        else:
            LOG.error("normals must be either 'triangles' or 'vertices'")

        return surf_mesh, surf_orient
github martinling / imusim / imusim / visualisation / rendering.py View on Github external
def renderSnapshot(self, t):
        px,py,pz,vx,vy,vz = self._generateDataVector(t)
        return mlab.quiver3d(px,py,pz,vx,vy,vz, scale_factor=1,
                *self._mlab_args, **self._mlab_kwargs).mlab_source
github treverhines / RBF / example / 3DFault.py View on Github external
G = G.tocsc()

out = jacobi_preconditioned_solve(G,data)
out = np.reshape(out,(dim,N))
out[:,ix['fault_foot']] = out[:,ix['fault_foot']] - slip
out[:,ix['fault_hanging']] = out[:,ix['fault_foot']] + 2*slip
out = out.T

idx = ix['fault_foot'] + ix['fault_hanging'] + ix['interior'] + ix['fixed'] + ix['free']
modest.toc('forming G')

import matplotlib.pyplot as plt
plt.quiver(nodes[ix['free'],0],nodes[ix['free'],1],out[ix['free'],0],out[ix['free'],1])
plt.show()

mayavi.mlab.quiver3d(nodes[idx,0],nodes[idx,1],nodes[idx,2],out[idx,0],out[idx,1],out[idx,2],mode='arrow',color=(0,1,0))


mayavi.mlab.triangular_mesh(vert[:,0],vert[:,1],vert[:,2],smp,opacity=0.2,color=(1,1,1))
mayavi.mlab.triangular_mesh(vert_f[:,0],vert_f[:,1],vert_f[:,2],smp_f,opacity=0.2,color=(1,0,0))

mayavi.mlab.show()
logging.basicConfig(level=logging.INFO)
summary()
github openmeeg / openmeeg / examples / view_leadfields.py View on Github external
# view EEG electrodes
mlab.points3d(ecog_electrodes[[ecog_chan_idx],0],
              ecog_electrodes[[ecog_chan_idx],1],
              ecog_electrodes[[ecog_chan_idx],2],
              opacity=0.5, scale_factor=8, color=(1,0,0))

###############################################################################
# MEG leadfield
mlab.figure(3)
mlab.clf()

meg_chan_idx = 30
cortex.plot(opacity=1, scalars=G_meg[meg_chan_idx,:])

# view MEG squids
mlab.quiver3d(squids[[meg_chan_idx], 0], squids[[meg_chan_idx], 1],
              squids[[meg_chan_idx], 2], -squids[[meg_chan_idx], 3],
              -squids[[meg_chan_idx], 4], -squids[[meg_chan_idx], 5],
              opacity=0.5, scale_factor=10, mode='cone')

###############################################################################
# EIT leadfield
mlab.figure(4)
mlab.clf()

# Generate sample current injection set up
n_electrodes = eit_electrodes.shape[0]
j_eit = np.zeros(n_electrodes)
idx_in = 10
idx_out = 13
j_eit[idx_in] = 1 # +1 current enters in idx_in electrode
j_eit[idx_out] = -1 # -1 current leaves in idx_out electrode
github ofringer / suntanspy / SUNTANS / suntvtk.py View on Github external
def windplot(self,nx=10,ny=10,scale=1e-3,**kwargs):
        """
        Overlay wind vectors on the current plots
        """  
        
        X,Y,uw,vw = self.getWind(nx=nx,ny=ny)
        
        Z = X*0+1000.0
        
        # Create a new scene if there isn't one
        if not self.__dict__.has_key('fig'):
            self.newscene()
        
        self.windobj = mlab.quiver3d(X,Y,Z,uw,vw,uw*0,scale_factor=1./scale,scale_mode='vector',\
            mode='2dthick_arrow',**kwargs)
        
        self.windobj.glyph.glyph_source.glyph_source.filled=True
        
        self._nxwind=nx
        self._nywind=ny