def prism_points(np_verts_c, sides): ang = np.arctan2(np_verts_c[:, 1], np_verts_c[:, 0]) ang2 = angle_between(np_verts_c, [[0, 0, 1]]) div2 = np.cos((ang2 + pi / 4) % (pi / 2) - pi / 4) div = np.cos((ang + pi / sides) % (2 * pi / sides) - pi / sides) * div2 div[sides < 2] = 1 x_co = np.cos(ang) * np.sin(ang2) / div y_co = np.sin(ang) * np.sin(ang2) / div z_co = np.cos(ang2) / div2 return np.stack((x_co, y_co, z_co)).T
def uv_sphere_points(np_verts_c, u_sides, v_sides): ang = np.arctan2(np_verts_c[:, 1], np_verts_c[:, 0]) ang2 = angle_between(np_verts_c, [[0, 0, 1]]) div2 = np.cos((ang2) % (pi/v_sides) - pi/v_sides/2) / np.cos(pi/v_sides/2) div2[v_sides < 1] = 1 div = np.cos((ang)%(2*pi/u_sides)-pi/u_sides) *div2 / np.cos(pi/u_sides) div[u_sides < 2] = 1 x_co = np.cos(ang)*np.sin(ang2)/div y_co = np.sin(ang)*np.sin(ang2)/div z_co = np.cos(ang2)/div2 return np.stack((x_co, y_co, z_co)).T
def numpy_cartesian_to_polar(vs, coordinates, angles_mode, out_numpy): vecs = array(vs) x = vecs[:, 0] y = vecs[:, 1] z = vecs[:, 2] if coordinates == 'z': rho = sqrt(x*x + y*y) if angles_mode == "degrees": phi = degrees(arctan2(y, x)) else: phi = arctan2(y, x) else: rho = linalg.norm(vecs, axis=1) if angles_mode == "degrees": phi = degrees(arctan2(y, x)) z = degrees(angle_between(vecs, [[0, 0, 1]])) else: phi = arctan2(y, x) z = angle_between(vecs, [[0, 0, 1]]) return [rho, phi, z] if out_numpy else [rho.tolist(), phi.tolist(), z.tolist()]