def points_to_spheres(points, radius=0.01, point_color = colors['red']): ''' :param points: Nx3 numpy array :param radius: :param vc: either a 3-element normalized RGB vector or a list of them for each point :return: ''' spheres = Mesh(v=[], f=[]) for id in range(len(points)): if isinstance(radius, float): spheres.concatenate_mesh(Sphere( center= points[id].reshape(-1,3), radius=radius ).to_mesh( color = point_color if len(point_color)==3 and not isinstance(point_color[0], list) else point_color[id])) else: spheres.concatenate_mesh(Sphere( center= points[id].reshape(-1,3), radius=radius[id] ).to_mesh( color = point_color if len(point_color)==3 and not isinstance(point_color[0], list) else point_color[id])) return spheres
def points_to_spheres(points, radius=0.1, vc=name_to_rgb['blue']): spheres = Mesh(v=[], f=[]) for pidx, center in enumerate(points): clr = vc[pidx] if len(vc) > 3 else vc spheres.concatenate_mesh(Sphere(center, radius).to_mesh(color=clr)) return spheres
def plot_points(pts, cols=None): from psbody.mesh.sphere import Sphere temp = Sphere(np.zeros((3)), 1.).to_mesh() meshes = [ Mesh(vc='SteelBlue' if cols is None else cols[n], f=temp.f, v=temp.v * 10.**-2 + p) for n, p in enumerate(pts) ] return meshes
def test_intersection_is_symmetric(self): d = 2 s0 = Sphere(np.array([0, 0, 0]), 1) for dd in np.linspace(0, d, 10): s1 = Sphere(np.array([d - dd, 0, 0]), 0.5) self.assertAlmostEqual(s0.intersection_vol(s1), s1.intersection_vol(s0))
def render(self): radius = .01 model_Mesh = Mesh(v=self.m.r, f=self.m.f) model_Joints = [ Sphere(np.array(jointPos), radius).to_mesh(np.eye(3)[0 if jointID == 0 else 1]) for jointID, jointPos in enumerate(self.m.J_transformed) ] self.mvs[0][0].set_static_meshes([model_Mesh] + model_Joints, blocking=True) self.mvs[0][1].set_static_meshes([model_Mesh], blocking=True) model_Mesh = Mesh(v=self.m.r, f=[]) self.mvs[0][2].set_static_meshes([model_Mesh] + model_Joints, blocking=True)
def create_lmk_spheres(lmks, radius, color=[255.0, 0.0, 0.0]): spheres = [] for lmk in lmks: spheres.append(Sphere(lmk, radius).to_mesh(color)) return spheres