def test_vertices_primitives(): # Tests the default vertices of all the built in primitive shapes. l_primitives = [(fp.prim_square, (4, 3)), (fp.prim_box, (8, 3)), (fp.prim_star, np.shape(fp.prim_star()), -3, 3, -0.666666666667), (fp.prim_rhombicuboctahedron, np.shape(fp.prim_rhombicuboctahedron()), -4, 4, 0)] for func, shape, min, max, mean in l_primitives: vertices, _ = func() npt.assert_equal(vertices.shape, shape) npt.assert_equal(np.mean(vertices), mean) npt.assert_equal(vertices.min(), min) npt.assert_equal(vertices.max(), max) vertices, _ = fp.prim_star(3) npt.assert_equal(vertices.shape, (12, 3)) npt.assert_equal(np.mean(vertices), .11111111) npt.assert_equal(vertices.min(), -3) npt.assert_equal(vertices.max(), 3)
def test_vertices_primitives(): # Tests the default vertices of all the built in primitive shapes. l_primitives = [(fp.prim_square, (4, 3), -.5, .5, 0), (fp.prim_box, (8, 3), -.5, .5, 0), (fp.prim_tetrahedron, (4, 3), -.5, .5, 0), (fp.prim_star, (10, 3), -3, 3, -0.0666666666), (fp.prim_rhombicuboctahedron, (24, 3), -4, 4, 0)] for func, shape, e_min, e_max, e_mean in l_primitives: vertices, _ = func() npt.assert_equal(vertices.shape, shape) npt.assert_almost_equal(np.mean(vertices), e_mean) npt.assert_equal(vertices.min(), e_min) npt.assert_equal(vertices.max(), e_max) vertices, _ = fp.prim_star(3) npt.assert_equal(vertices.shape, (12, 3)) npt.assert_almost_equal(abs(np.mean(vertices)), .11111111) npt.assert_equal(vertices.min(), -3) npt.assert_equal(vertices.max(), 3)
import numpy as np from fury import window, utils, actor, primitive import itertools vertices, triangles = primitive.prim_star() colors = 255 * np.random.rand(*vertices.shape) point_actor = actor.point(vertices, point_radius=0.01, colors=colors / 255.) # this does not work #colors = np.array([255, 0. , 0.]) # this does work colors = np.array([[255, 0., 0.], [255, 0., 0.], [255, 0., 0.], [255, 0., 0.], [255, 0., 0.], [255, 0., 0.], [255, 0., 0.], [255, 0., 0.]]) frustum_actor = utils.get_actor_from_primitive(vertices=vertices, triangles=triangles, colors=colors, backface_culling=False) scene = window.Scene() scene.add(point_actor) scene.add(actor.axes()) scene.add(frustum_actor) # frustum_actor.GetProperty().SetOpacity(0.3) scene.set_camera(position=(10, 5, 7), focal_point=(0, 0, 0)) window.show(scene, size=(600, 600), reset_camera=False)