Skip to content

webknossos.geometry

Vec3Float

Bases: Sequence[float]

A three-dimensional vector of floats, e.g. a voxel size or a position with sub-voxel precision. Use Vec3Int where only whole voxels are meaningful.

Examples:

Basic vector creation and operations:

vector_1 = Vec3Float(1.0, 2.0, 3.0)
vector_2 = Vec3Float.full(1.0)
assert vector_2.x == vector_2.y == vector_2.z
assert vector_1 + vector_2 == (2.0, 3.0, 4.0)

Instances compare, order and hash like the equivalent plain tuple, so they can be used interchangeably with (x, y, z) in comparisons, sorting, sets and as dict keys.

x property

x: float

y property

y: float

z property

z: float

from_str classmethod

from_str(string: str) -> Vec3Float

Parses a Vec3Float from a string such as "1.0,2.0,3.0" or "(1.0,2.0,3.0)".

from_xyz classmethod

from_xyz(x: float, y: float, z: float) -> Vec3Float

Creates a Vec3Float from three floats, skipping the general parsing.

full classmethod

full(value: float) -> Vec3Float

Creates a Vec3Float with all three components set to value.

ones classmethod

ones() -> Vec3Float

pairmax

pairmax(other: Union[float, Vec3FloatLike]) -> Vec3Float

Returns the element-wise maximum of the two vectors.

pairmin

pairmin(other: Union[float, Vec3FloatLike]) -> Vec3Float

Returns the element-wise minimum of the two vectors.

prod

prod() -> float

Returns the product of the three components.

to_list

to_list() -> list[float]

to_np

to_np() -> ndarray

to_tuple

to_tuple() -> tuple[float, float, float]

to_vec3_int

to_vec3_int() -> Vec3Int

Converts to a Vec3Int, truncating each component towards zero.

with_x

with_x(new_x: float) -> Vec3Float

with_y

with_y(new_y: float) -> Vec3Float

with_z

with_z(new_z: float) -> Vec3Float

zeros classmethod

zeros() -> Vec3Float