primitive#

Module dedicated for basic primitive.

faces_from_sphere_vertices(vertices)

Triangulate a set of vertices on the sphere.

repeat_primitive_function(func, centers, *)

Repeat Vertices and triangles of a specific primitive function.

repeat_primitive(vertices, faces, centers, *)

Repeat Vertices and triangles of a specific primitive shape.

prim_square()

Return vertices and triangles for a square geometry.

prim_box()

Return vertices and triangle for a box geometry.

prim_sphere(*[, name, gen_faces, phi, theta])

Provide vertices and triangles of the spheres.

prim_superquadric([roundness, sphere_name])

Provide vertices and triangles of a superquadrics.

prim_tetrahedron()

Return vertices and triangles for a tetrahedron.

prim_icosahedron()

Return vertices and triangles for icosahedron.

prim_rhombicuboctahedron()

Return vertices and triangles for rhombicuboctahedron.

prim_star(*[, dim])

Return vertices and triangle for star geometry.

prim_triangularprism()

Return vertices and triangle for a regular triangular prism.

prim_pentagonalprism()

Return vertices and triangles for a pentagonal prism.

prim_octagonalprism()

Return vertices and triangle for an octagonal prism.

prim_frustum()

Return vertices and triangle for a square frustum prism.

prim_cylinder(*[, radius, height, sectors, ...])

Return vertices and triangles for a cylinder.

prim_arrow(*[, height, resolution, ...])

Return vertices and triangle for arrow geometry.

prim_cone(*[, radius, height, sectors])

Return vertices and triangle of a Cone.

faces_from_sphere_vertices#

fury.primitive.faces_from_sphere_vertices(vertices)[source]#

Triangulate a set of vertices on the sphere.

Parameters:

vertices ((M, 3) ndarray) – XYZ coordinates of vertices on the sphere.

Returns:

faces – Indices into vertices; forms triangular faces.

Return type:

(N, 3) ndarray

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 functions

  • centers (ndarray, shape (N, 3)) – Superquadrics positions

  • func_args (args) – primitive functions arguments/parameters

  • directions (ndarray, shape (N, 3) or tuple (3,), optional) – The orientation vector of the cone.

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,)) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • scales (ndarray, shape (N) or (N,3) or float or int, optional) – The height of the cone.

Returns:

  • big_vertices (ndarray) – Expanded vertices at the centers positions

  • big_triangles (ndarray) – Expanded triangles that composed our shape to duplicate

  • 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 coords to duplicate at the centers positions

  • triangles (ndarray) – triangles that composed our shape to duplicate

  • centers (ndarray, shape (N, 3)) – Superquadrics positions

  • directions (ndarray, shape (N, 3) or tuple (3,), optional) – The orientation vector of the cone.

  • colors (ndarray (N,3) or (N, 4) or tuple (3,) or tuple (4,)) – RGB or RGBA (for opacity) R, G, B and A should be at the range [0, 1]

  • scales (ndarray, shape (N) or (N,3) or float or int, optional) – The height of the cone.

  • have_tiled_verts (bool) – option to control if we need to duplicate vertices of a shape or not

Returns:

  • big_vertices (ndarray) – Expanded vertices at the centers positions

  • big_triangles (ndarray) – Expanded triangles that composed our shape to duplicate

  • big_colors (ndarray) – Expanded colors applied to all vertices/faces

  • big_centers (ndarray) – Expanded centers for all vertices/faces

prim_square#

fury.primitive.prim_square()[source]#

Return vertices and triangles for a square geometry.

Returns:

  • vertices (ndarray) – 4 vertices coords that composed our square

  • triangles (ndarray) – 2 triangles that composed our square

prim_box#

fury.primitive.prim_box()[source]#

Return vertices and triangle for a box geometry.

Returns:

  • vertices (ndarray) – 8 vertices coords that composed our box

  • triangles (ndarray) – 12 triangles that composed our box

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 - 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, we load the saved faces from a file. Default: False

  • phi (int, optional) – Set the number of points in the latitude direction

  • theta (int, optional) – Set the number of points in the longitude direction

Returns:

  • vertices (ndarray) – vertices coords that composed our sphere

  • triangles (ndarray) – triangles that composed our sphere

Examples

>>> import numpy as np
>>> from fury.primitive import prim_sphere
>>> verts, faces = prim_sphere('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 superquadrics.

Parameters:
  • roundness (tuple, optional) – parameters (Phi and Theta) that control the shape of the superquadric

  • sphere_name (str, optional) – which sphere - one of: * ‘symmetric362’ * ‘symmetric642’ * ‘symmetric724’ * ‘repulsion724’ * ‘repulsion100’ * ‘repulsion200’

Returns:

  • vertices (ndarray) – vertices coords that composed our sphere

  • triangles (ndarray) – triangles that composed our sphere

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:

  • pyramid_vert (numpy.ndarray) – 4 vertices coordinates

  • triangles (numpy.ndarray) – 4 triangles representing the tetrahedron

prim_icosahedron#

fury.primitive.prim_icosahedron()[source]#

Return vertices and triangles for icosahedron.

Returns:

  • icosahedron_vertices (numpy.ndarray) – 12 vertices coordinates to the icosahedron

  • icosahedron_mesh (numpy.ndarray) – 20 triangles representing the tetrahedron

prim_rhombicuboctahedron#

fury.primitive.prim_rhombicuboctahedron()[source]#

Return vertices and triangles for rhombicuboctahedron.

Returns:

  • vertices (numpy.ndarray) – 24 vertices coordinates to the rhombicuboctahedron

  • triangles (numpy.ndarray) – 44 triangles representing the rhombicuboctahedron

prim_star#

fury.primitive.prim_star(*, dim=2)[source]#

Return vertices and triangle for star geometry.

Parameters:

dim (int) – Represents the dimension of the wanted star

Returns:

  • vertices (ndarray) – vertices coords that composed our star

  • triangles (ndarray) – Triangles that composed our star

prim_triangularprism#

fury.primitive.prim_triangularprism()[source]#

Return vertices and triangle for a regular triangular prism.

Returns:

  • vertices (ndarray) – vertices coords that compose our prism

  • triangles (ndarray) – triangles that compose our prism

prim_pentagonalprism#

fury.primitive.prim_pentagonalprism()[source]#

Return vertices and triangles for a pentagonal prism.

Returns:

  • vertices (ndarray) – vertices coords that compose our prism

  • triangles (ndarray) – triangles that compose our prism

prim_octagonalprism#

fury.primitive.prim_octagonalprism()[source]#

Return vertices and triangle for an octagonal prism.

Returns:

  • vertices (ndarray) – vertices coords that compose our prism

  • triangles (ndarray) – triangles that compose our prism

prim_frustum#

fury.primitive.prim_frustum()[source]#

Return vertices and triangle for a square frustum prism.

Returns:

  • vertices (ndarray) – vertices coords that compose our prism

  • triangles (ndarray) – triangles that compose our prism

prim_cylinder#

fury.primitive.prim_cylinder(*, radius=0.5, height=1, sectors=36, capped=True)[source]#

Return vertices and triangles for a cylinder.

Parameters:
  • radius (float) – Radius of the cylinder

  • height (float) – Height of the cylinder

  • sectors (int) – Sectors in the cylinder

  • capped (bool) – Whether the cylinder is capped at both ends or open

Returns:

  • vertices (ndarray) – vertices coords that compose our cylinder

  • triangles (ndarray) – triangles that compose our cylinder

prim_arrow#

fury.primitive.prim_arrow(*, height=1.0, resolution=10, tip_length=0.35, tip_radius=0.1, shaft_radius=0.03)[source]#

Return vertices and triangle for arrow geometry.

Parameters:
  • height (float) – The height of the arrow (default: 1.0).

  • resolution (int) – The resolution of the arrow.

  • tip_length (float) – The tip size of the arrow (default: 0.35)

  • tip_radius (float) – the tip radius of the arrow (default: 0.1)

  • shaft_radius (float) – The shaft radius of the arrow (default: 0.03)

Returns:

  • vertices (ndarray) – vertices of the Arrow

  • triangles (ndarray) – Triangles of the Arrow

prim_cone#

fury.primitive.prim_cone(*, radius=0.5, height=1, sectors=10)[source]#

Return vertices and triangle of a Cone.

Parameters:
  • radius (float, optional) – Radius of the cone

  • height (float, optional) – Height of the cone

  • sectors (int, optional) – Sectors in the cone

Returns:

  • vertices (ndarray) – vertices coords that compose our cone

  • triangles (ndarray) – triangles that compose our cone