def ball_ring(): os = np.random.rand(30).reshape((-1,3)) rs = np.random.rand(10)/7 cs = (np.random.rand(10)*255).astype(np.uint8) cs = myvi.linear_color('jet')[cs]/255 vts_b, fs_b, ns_b, cs_b = myvi.build_balls(list(os), list(rs), list(cs)) vts_l, fs_l, ns_l, cs_l = myvi.build_line(os[:,0], os[:,1], os[:,2], list(cs)) manager = myvi.Manager() manager.add_surf('balls', vts_b, fs_b, ns_b, cs_b) line = manager.add_surf('line', vts_l, fs_l, ns_l, cs_l) line.set_style(mode='grid') manager.show('Balls Ring Demo')
def line(): vts = np.array([(0,0,0),(1,1,0),(2,1,0),(1,0,0)], dtype=np.float32) fs = np.array([(0,1,2),(1,2,3)], dtype=np.uint32) ns = np.ones((4,3), dtype=np.float32) n_mer, n_long = 6, 11 pi = np.pi dphi = pi / 1000.0 phi = np.arange(0.0, 2 * pi + 0.5 * dphi, dphi) mu = phi * n_mer x = np.cos(mu) * (1 + np.cos(n_long * mu / n_mer) * 0.5) y = np.sin(mu) * (1 + np.cos(n_long * mu / n_mer) * 0.5) z = np.sin(n_long * mu / n_mer) * 0.5 vts, fs, ns, cs = myvi.build_line(x, y, z, (1, 0, 0)) cs[:] = myvi.auto_lookup(vts[:,2], myvi.linear_color('jet'))/255 manager = myvi.Manager() obj = manager.add_surf('line', vts, fs, ns, cs) obj.set_style(mode='grid') manager.show('Line Rings')