primitive#
Module dedicated for basic primitives.
This module provides functions to create basic geometric primitives like spheres, boxes, cylinders, etc. that can be used for visualization.
|
Triangulate a set of vertices on the sphere. |
|
Repeat vertices and triangles of a specific primitive function. |
|
Repeat vertices and triangles of a specific primitive shape. |
Return vertices and triangles for a square geometry. |
|
|
Return vertices and triangles for a box geometry. |
|
Provide vertices and triangles of the spheres. |
|
Provide vertices and triangles of a superquadric. |
Return vertices and triangles for a tetrahedron. |
|
Return vertices and triangles for an icosahedron. |
|
Return vertices and triangles for a rhombicuboctahedron. |
|
|
Return vertices and triangles for a 5-pointed star (2D or 3D). |
Return vertices and triangle for a regular triangular prism. |
|
Return vertices and triangles for a pentagonal prism. |
|
Return vertices and triangle for an octagonal prism. |
|
Return vertices and triangles for a square frustum prism. |
|
|
Return vertices and triangles for a cylinder. |
|
Return vertices and triangles for arrow geometry. |
|
Return vertices and triangles of a cone. |
|
Return vertices and triangles for a disk. |
Return vertices and triangles for a triangle geometry. |
|
|
Return vertices and triangles for a ring geometry. |
faces_from_sphere_vertices#
repeat_primitive_function#
- fury.primitive.repeat_primitive_function(func, centers, *, func_args=None, directions=(1, 0, 0), colors=(1, 0, 0), scales=1)[source]#
Repeat vertices and triangles of a specific primitive function.
It could be seen as a glyph. The primitive function should generate and return vertices and faces.
- Parameters:
func (callable) – Primitive function.
centers (ndarray, shape (N, 3)) – Positions for repeated primitives.
func_args (list or None, optional) – Primitive function arguments/parameters.
directions (ndarray, shape (N, 3) or tuple (3,), optional) – Orientation vectors for the primitives.
colors (ndarray, shape (N, 3) or (N, 4) or tuple (3,) or tuple (4,), optional) – RGB or RGBA (for opacity) colors for the primitives. R, G, B and A should be in the range [0, 1].
scales (ndarray, shape (N,) or (N, 3) or float or int, optional) – Scaling factors for the primitives.
- Returns:
big_vertices (ndarray) – Expanded vertices at the centers positions.
big_triangles (ndarray) – Expanded triangles that compose the repeated primitives.
big_colors (ndarray) – Expanded colors applied to all vertices/faces.
repeat_primitive#
- fury.primitive.repeat_primitive(vertices, faces, centers, *, directions=None, colors=(1, 0, 0), scales=1, have_tiled_verts=False)[source]#
Repeat vertices and triangles of a specific primitive shape.
It could be seen as a glyph.
- Parameters:
vertices (ndarray) – Vertices coordinates to duplicate at the centers positions.
faces (ndarray) – Triangles that compose the shape to duplicate.
centers (ndarray, shape (N, 3)) – Positions for repeated primitives.
directions (ndarray, shape (N, 3) or tuple (3,), optional) – Orientation vectors for the primitives.
colors (ndarray, shape (N, 3) or (N, 4) or tuple (3,) or tuple (4,), optional) – RGB or RGBA (for opacity) colors for the primitives. R, G, B and A should be in the range [0, 1].
scales (ndarray, shape (N,) or (N, 3) or float or int, optional) – Scaling factors for the primitives.
have_tiled_verts (bool, optional) – Option to control if vertices need to be duplicated or not.
- Returns:
big_vertices (ndarray) – Expanded vertices at the centers positions.
big_triangles (ndarray) – Expanded triangles that compose the repeated primitives.
big_colors (ndarray) – Expanded colors applied to all vertices/faces.
big_centers (ndarray) – Expanded centers for all vertices/faces.
prim_square#
prim_box#
- fury.primitive.prim_box(detailed=True)[source]#
Return vertices and triangles for a box geometry.
- Parameters:
detailed (bool, optional) – If True, returns 24 vertices (no shared vertices between orthogonal faces). If False, returns 8 unique vertices.
- Returns:
vertices (ndarray) – Array of vertex coordinates.
triangles (ndarray) – Array of triangle indices.
prim_sphere#
- fury.primitive.prim_sphere(*, name='symmetric362', gen_faces=False, phi=None, theta=None)[source]#
Provide vertices and triangles of the spheres.
- Parameters:
name (str, optional) – Which sphere to use, one of: * ‘symmetric362’ * ‘symmetric642’ * ‘symmetric724’ * ‘repulsion724’ * ‘repulsion100’ * ‘repulsion200’
gen_faces (bool, optional) – If True, triangulate a set of vertices on the sphere to get the faces. Otherwise, load the saved faces from a file.
phi (int, optional) – Number of points in the latitude direction.
theta (int, optional) – Number of points in the longitude direction.
- Returns:
vertices (ndarray) – Vertices coordinates that compose the sphere.
triangles (ndarray) – Triangles that compose the sphere.
Examples
>>> import numpy as np >>> from fury.primitive import prim_sphere >>> verts, faces = prim_sphere(name='symmetric362') >>> verts.shape == (362, 3) True >>> faces.shape == (720, 3) True
prim_superquadric#
- fury.primitive.prim_superquadric(roundness=(1, 1), sphere_name='symmetric362')[source]#
Provide vertices and triangles of a superquadric.
- Parameters:
- Returns:
vertices (ndarray) – Vertices coordinates that compose the superquadric.
triangles (ndarray) – Triangles that compose the superquadric.
Examples
>>> import numpy as np >>> from fury.primitive import prim_superquadric >>> verts, faces = prim_superquadric(roundness=(1, 1)) >>> verts.shape == (362, 3) True >>> faces.shape == (720, 3) True
prim_tetrahedron#
- fury.primitive.prim_tetrahedron()[source]#
Return vertices and triangles for a tetrahedron.
This shape has a side length of two units.
- Returns:
vertices (ndarray, shape (4, 3)) – Coordinates of the 4 vertices.
triangles (ndarray, shape (4, 3)) – Indices of the 4 triangles representing the tetrahedron.
prim_icosahedron#
prim_rhombicuboctahedron#
- fury.primitive.prim_rhombicuboctahedron()[source]#
Return vertices and triangles for a rhombicuboctahedron.
- Returns:
vertices (ndarray, shape (24, 3)) – Coordinates of the 24 vertices of the rhombicuboctahedron.
triangles (ndarray, shape (44, 3)) – Indices of the 44 triangles representing the rhombicuboctahedron.
prim_star#
- fury.primitive.prim_star(*, dim=2)[source]#
Return vertices and triangles for a 5-pointed star (2D or 3D).
- Parameters:
dim (int, optional) – Dimension of the star, either 2 or 3.
- Returns:
vertices (ndarray) – Vertices coordinates that compose the star.
triangles (ndarray) – Triangles that compose the star.
prim_triangularprism#
prim_pentagonalprism#
prim_octagonalprism#
prim_frustum#
prim_cylinder#
- fury.primitive.prim_cylinder(*, radius=0.5, height=1, sectors=36, capped=True)[source]#
Return vertices and triangles for a cylinder.
- Parameters:
- Returns:
vertices (ndarray) – Vertices coordinates that compose the cylinder.
triangles (ndarray) – Triangles that compose the cylinder.
- Raises:
TypeError – If sectors is not an integer.
ValueError – If sectors is not greater than 7.
prim_arrow#
prim_cone#
- fury.primitive.prim_cone(*, radius=0.5, height=1, sectors=10)[source]#
Return vertices and triangles of a cone.
- Parameters:
- Returns:
vertices (ndarray) – Vertices coordinates that compose the cone.
triangles (ndarray) – Triangles that compose the cone.
- Raises:
ValueError – If sectors is less than 3.
prim_disk#
- fury.primitive.prim_disk(*, radius=0.5, sectors=36)[source]#
Return vertices and triangles for a disk.
- Parameters:
- Returns:
vertices (ndarray) – Vertices coordinates that compose the disk.
triangles (ndarray) – Triangles that compose the disk.
- Raises:
TypeError – If sectors is not an integer.
ValueError – If sectors is not greater than 7.
prim_triangle#
prim_ring#
- fury.primitive.prim_ring(*, inner_radius=0.5, outer_radius=1, radial_segments=1, circumferential_segments=32)[source]#
Return vertices and triangles for a ring geometry.
- Parameters:
inner_radius (float, optional) – The inner radius of the ring (radius of the hole).
outer_radius (float, optional) – The outer radius of the ring.
radial_segments (int, optional) – Number of segments along the radial direction.
circumferential_segments (int, optional) – Number of segments around the circumference.
- Returns:
vertices (ndarray, shape (3, 3)) – Coordinates of the 3 vertices that compose the triangle.
triangles (ndarray, shape (1, 3)) – Indices of the 1 triangle that composes the geometry.
- Raises:
ValueError – If radial_segments is less than 1. If circumferential_segments is less than 3. If inner_radius is not between 0 and outer_radius.