geometry#

Geometry utilities for FURY.

buffer_to_geometry(positions, **kwargs)

Convert a buffer to a geometry object.

line_buffer_separator(line_vertices[, color])

Create a line buffer with separators between segments.

rotate_vector(v, axis, angle)

Rotate a vector v around an axis axis by an angle angle.

prune_colinear(arr[, colinear_threshold])

Prune colinear points from the array.

axes_for_dir(d[, prev_x])

Compute the axes for a given direction vector.

buffer_to_geometry#

fury.geometry.buffer_to_geometry(positions, **kwargs)[source]#

Convert a buffer to a geometry object.

Parameters:
  • positions (array_like) – The positions buffer.

  • **kwargs (dict) – A dict of attributes to define on the geometry object. Keys can be “colors”, “normals”, “texcoords”, “indices”, etc.

Returns:

The geometry object.

Return type:

Geometry

Raises:

ValueError – If positions array is empty or None.

line_buffer_separator#

fury.geometry.line_buffer_separator(line_vertices, color=None)[source]#

Create a line buffer with separators between segments.

Parameters:
  • line_vertices (list of array_like) – The line vertices as a list of segments (each segment is an array of points).

  • color (array_like, optional) – The color of the line segments.

Returns:

  • positions (array_like) – The positions buffer with NaN separators.

  • colors (array_like, optional) – The colors buffer with NaN separators (if color is provided).

rotate_vector#

fury.geometry.rotate_vector(v, axis, angle)[source]#

Rotate a vector v around an axis axis by an angle angle.

Parameters:
  • v (array_like) – The vector to be rotated.

  • axis (array_like) – The axis of rotation.

  • angle (float) – The angle of rotation in radians.

Returns:

The rotated vector.

Return type:

array_like

prune_colinear#

fury.geometry.prune_colinear(arr, colinear_threshold=0.9999)[source]#

Prune colinear points from the array.

Parameters:
  • arr (ndarray, shape (N, 3)) – The input array of points.

  • colinear_threshold (float, optional) – The threshold for colinearity. Points are considered colinear if the cosine of the angle between them is greater than or equal to this value.

Returns:

The pruned array with colinear points removed.

Return type:

ndarray, shape (3,)

axes_for_dir#

fury.geometry.axes_for_dir(d, prev_x=None)[source]#

Compute the axes for a given direction vector.

Parameters:
  • d (ndarray, shape (3,)) – The direction vector.

  • prev_x (ndarray, shape (3,), optional) – The previous x-axis vector.

Returns:

  • x (ndarray, shape (3,)) – The x-axis vector.

  • y (ndarray, shape (3,)) – The y-axis vector.