Python mayavi.mlab.quiver3d() Examples
The following are 4
code examples of mayavi.mlab.quiver3d().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
mayavi.mlab
, or try the search function
.
Example #1
Source File: grasp_sampler.py From PointNetGPD with MIT License | 6 votes |
def show_grasp_norm_oneside(self, grasp_bottom_center, grasp_normal, grasp_axis, minor_pc, scale_factor=0.001): # un1 = grasp_bottom_center + 0.5 * grasp_axis * self.gripper.max_width un2 = grasp_bottom_center # un3 = grasp_bottom_center + 0.5 * minor_pc * self.gripper.max_width # un4 = grasp_bottom_center # un5 = grasp_bottom_center + 0.5 * grasp_normal * self.gripper.max_width # un6 = grasp_bottom_center self.show_points(grasp_bottom_center, color='g', scale_factor=scale_factor * 4) # self.show_points(un1, scale_factor=scale_factor * 4) # self.show_points(un3, scale_factor=scale_factor * 4) # self.show_points(un5, scale_factor=scale_factor * 4) # self.show_line(un1, un2, color='g', scale_factor=scale_factor) # binormal/ major pc # self.show_line(un3, un4, color='b', scale_factor=scale_factor) # minor pc # self.show_line(un5, un6, color='r', scale_factor=scale_factor) # approach normal mlab.quiver3d(un2[0], un2[1], un2[2], grasp_axis[0], grasp_axis[1], grasp_axis[2], scale_factor=.03, line_width=0.25, color=(0, 1, 0), mode='arrow') mlab.quiver3d(un2[0], un2[1], un2[2], minor_pc[0], minor_pc[1], minor_pc[2], scale_factor=.03, line_width=0.1, color=(0, 0, 1), mode='arrow') mlab.quiver3d(un2[0], un2[1], un2[2], grasp_normal[0], grasp_normal[1], grasp_normal[2], scale_factor=.03, line_width=0.05, color=(1, 0, 0), mode='arrow')
Example #2
Source File: forward.py From conpy with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _plot_coord_system(points, dim1, dim2, dim3, scale=0.001, n_ori=3): """Useful for checking the results of _make_radial_coord_system. Usage: >>> _, origin = _fit_sphere(fwd['source_rr']) ... rad, tan1, tan2 = _make_radial_coord_system(fwd['source_rr'], origin) ... _plot_coord_system(fwd['source_rr'], rad, tan1, tan2) Use ``scale`` to control the size of the arrows. """ from mayavi import mlab f = mlab.figure(size=(600, 600)) red, blue, black = (1, 0, 0), (0, 0, 1), (0, 0, 0) if n_ori == 3: mlab.quiver3d(points[:, 0], points[:, 1], points[:, 2], dim1[:, 0], dim1[:, 1], dim1[:, 2], scale_factor=scale, color=red) if n_ori > 1: mlab.quiver3d(points[:, 0], points[:, 1], points[:, 2], dim2[:, 0], dim2[:, 1], dim2[:, 2], scale_factor=scale, color=blue) mlab.quiver3d(points[:, 0], points[:, 1], points[:, 2], dim3[:, 0], dim3[:, 1], dim3[:, 2], scale_factor=scale, color=black) return f
Example #3
Source File: test_horseshoe.py From OpenModes with GNU General Public License v3.0 | 5 votes |
def test_surface_normals(plot=False, skip_asserts=False, write_reference=False): "Test the surface normals of a horseshoe mesh" sim = openmodes.Simulation() mesh = sim.load_mesh(osp.join(mesh_dir, 'horseshoe_rect.msh')) part = sim.place_part(mesh) basis = sim.basis_container[part] r, rho = basis.integration_points(mesh.nodes, triangle_centres) normals = mesh.surface_normals r = r.reshape((-1, 3)) if write_reference: write_2d_real(osp.join(reference_dir, 'surface_r.txt'), r) write_2d_real(osp.join(reference_dir, 'surface_normals.txt'), normals) r_ref = read_2d_real(osp.join(reference_dir, 'surface_r.txt')) normals_ref = read_2d_real(osp.join(reference_dir, 'surface_normals.txt')) if not skip_asserts: assert_allclose(r, r_ref) assert_allclose(normals, normals_ref) if plot: from mayavi import mlab mlab.figure() mlab.quiver3d(r[:, 0], r[:, 1], r[:, 2], normals[:, 0], normals[:, 1], normals[:, 2], mode='cone') mlab.view(distance='auto') mlab.show()
Example #4
Source File: correspondence.py From cmm with GNU General Public License v2.0 | 4 votes |
def show_correspondence(verts1, tris1, verts2, tris2, ij, points=5, show_spheres=True, scalars=None, colormap='gist_rainbow', blend_factor=0.9, compute_blend_weights=compute_fake_weights, color_only_correspondences=1, color_no_correspondence=(0,0,0), offset_factor=(1.5, 0., 0.), block=True, ): mlab.figure(bgcolor=(1,1,1)) # select sparse points to visualize if type(points) is int: i_sel = [0] geo = GeodesicDistanceComputation(verts1, tris1) for n in xrange(points-1): d = geo(ij[i_sel,0])[ij[:,0]] i_sel.append(d.argmax()) else: i_sel = points #i_sel = np.random.randint(0, len(ij), 10) ij_sel = np.column_stack((ij[i_sel,0], ij[i_sel, 1])) # color per marker - value between 0 and 1 which is passed through a color map later on color = np.linspace(0, 1, len(ij_sel)) # prepare visualization offset = verts2.ptp(axis=0) * offset_factor#(verts2[:,0].ptp() * offset_factor, 0, 0) p1 = verts1[ij_sel[:,0]] p2 = verts2[ij_sel[:,1]] + offset v = p2 - p1 # visualize! # correspondence arrows quiv = mlab.quiver3d(p1[:,0], p1[:,1], p1[:,2], v[:,0], v[:,1], v[:,2], scale_factor=1, line_width=2, mode='2ddash', scale_mode='vector', scalars=color, colormap=colormap) quiv.glyph.color_mode = 'color_by_scalar' # show sparse points as spheres if show_spheres: h = veclen(verts1[tris1[:,0]] - verts1[tris1[:,1]]).mean() * 2 mlab.points3d(p1[:,0], p1[:,1], p1[:,2], color, scale_mode='none', scale_factor=h, colormap=colormap, resolution=32) mlab.points3d(p2[:,0], p2[:,1], p2[:,2], color, scale_mode='none', scale_factor=h, colormap=colormap, resolution=32) # make colors for the meshes if scalars is None: H = compute_blend_weights(verts1, tris1, ij_sel[:,0]) # interpolate colors lut = quiv.module_manager.scalar_lut_manager.lut.table.to_array() lut_colors_rgb = lut[(color * (lut.shape[0]-1)).astype(np.int), :3].astype(np.float) scalars = ((1 - blend_factor) * lut_colors_rgb[H.argmax(axis=1)] + \ blend_factor * (H[:,:,np.newaxis] * lut_colors_rgb[np.newaxis,:,:]).sum(1)) scalars = np.uint8(scalars) if color_only_correspondences: scalars_filtered = np.zeros((len(verts1), 3)) scalars_filtered[:] = np.array(color_no_correspondence)[np.newaxis] * 255 scalars_filtered[ij[:,0]] = scalars[ij[:,0]] scalars = scalars_filtered scalars2 = np.zeros((len(verts2), 3)) scalars2[:] = np.array(color_no_correspondence)[np.newaxis] * 255 scalars2[ij[:,1]] = scalars[ij[:,0]] # show meshes vismesh(verts1, tris1, scalars=scalars) vismesh(verts2 + offset, tris2, scalars=scalars2) if block: mlab.show()