Skip to content

webknossos.geometry.vec3_int

The VecInt class is designed to represent a vector of integers. This class is a subclass of the built-in tuple class, and it extends the functionality of tuples by providing additional methods and operations.

One of the key features of the VecInt class is that it allows for the storage of axis names along with their corresponding values.

Here is a brief example demonstrating how to use the VecInt class:

from webknossos import VecInt

# Creating a VecInt instance with 4 elements and axes x, y, z, t:
vector_1 = VecInt(1, 2, 3, 4, axes=("x", "y", "z", "t"))
# Alternative ways to create the same VecInt instance:
vector_1 = VecInt([1, 2, 3, 4], axes=("x", "y", "z", "t"))
vector_1 = VecInt(x=1, y=2, z=3, t=4)

# Creating a VecInt instance with all elements set to 1 and axes x, y, z, t:
vector_2 = VecInt.full(1, axes=("x", "y", "z", "t"))
# Asserting that all elements in vector_2 are equal to 1:
assert vector_2[0] == vector_2[1] == vector_2[2] == vector_2[3]

# Demonstrating the addition operation between two VecInt instances:
assert vector_1 + vector_2 == VecInt(2, 3, 4, 5)
Vec3Int( *args: Union[Union[webknossos.geometry.vec3_int.Vec3Int, Tuple[int, int, int], numpy.ndarray, Iterable[int]], Iterable[str], int], axes: Union[Iterable[str], NoneType] = ('x', 'y', 'z'), **kwargs: int)

Class to represent a 3D vector. Inherits from tuple and provides useful methods and operations on top.

A small usage example:

from webknossos import Vec3Int

vector_1 = Vec3Int(1, 2, 3)
vector_2 = Vec3Int.full(1)
assert vector_2.x == vector_2.y == vector_2.y

assert vector_1 + vector_2 == (2, 3, 4)
x: int

Returns the x component of the vector.

y: int

Returns the y component of the vector.

z: int

Returns the z component of the vector.

def with_x(self, new_x: int) -> webknossos.geometry.vec3_int.Vec3Int:
def with_y(self, new_y: int) -> webknossos.geometry.vec3_int.Vec3Int:
def with_z(self, new_z: int) -> webknossos.geometry.vec3_int.Vec3Int:
def to_tuple(self) -> Tuple[int, int, int]:

Returns the vector as a tuple.

@staticmethod
def from_xyz(x: int, y: int, z: int) -> webknossos.geometry.vec3_int.Vec3Int:

Use Vec3Int.from_xyz for fast construction.

@staticmethod
def from_vec3_float(vec: Tuple[float, float, float]) -> webknossos.geometry.vec3_int.Vec3Int:
@staticmethod
def from_vec_or_int( vec_or_int: Union[Union[webknossos.geometry.vec3_int.Vec3Int, Tuple[int, int, int], numpy.ndarray, Iterable[int]], int]) -> webknossos.geometry.vec3_int.Vec3Int:
@staticmethod
def from_str(string: str) -> webknossos.geometry.vec3_int.Vec3Int:

Returns a new ND Vector from a string representation.

Args:

  • string (str): The string representation of the vector.

Returns:

  • VecInt: The new vector.
@classmethod
def zeros( cls, _axes: Tuple[str, ...] = ('x', 'y', 'z')) -> webknossos.geometry.vec3_int.Vec3Int:

Returns a new ND Vector with all elements set to 0.

Args:

  • axes (Tuple[str, ...]): The axes of the vector.

Returns:

  • VecInt: The new vector.
@classmethod
def ones( cls, _axes: Tuple[str, ...] = ('x', 'y', 'z')) -> webknossos.geometry.vec3_int.Vec3Int:

Returns a new ND Vector with all elements set to 1.

Args:

  • axes (Tuple[str, ...]): The axes of the vector.

Returns:

  • VecInt: The new vector.
@classmethod
def full( cls, an_int: int, _axes: Tuple[str, ...] = ('x', 'y', 'z')) -> webknossos.geometry.vec3_int.Vec3Int:

Returns a new ND Vector with all elements set to the same value.

Args:

  • an_int (int): The value to set all elements to.
  • axes (Tuple[str, ...]): The axes of the vector.

Returns:

  • VecInt: The new vector.
Vec3IntLike = typing.Union[webknossos.geometry.vec3_int.Vec3Int, typing.Tuple[int, int, int], numpy.ndarray, typing.Iterable[int]]