neu_lib.vec

A 3D coordinate that does arithmetic: Vec3, for positions, offsets and extents.

offset = Vec3.of(other.bbox.lo) - Vec3.of(mesh.bbox.lo) mesh.translate(offset)

Unlike a (3,) numpy array, a Vec3 cannot be broadcast against an (N, 3) point array by accident: building one from anything but three components raises. It works anywhere a length-3 sequence is accepted, since it supports len, indexing, iteration and np.asarray. Components are zyx; Vec3.xyz gives the reversed order.

Classes

Vec3

Three components, zyx. Frozen and hashable.

Module Contents

class neu_lib.vec.Vec3

Three components, zyx. Frozen and hashable.

+, -, *, / and unary - take another Vec3, a length-3 sequence, or a scalar (applied to all three). Any other operand is left to its own type, so Vec3(...) * np.zeros((5, 3)) gives the (5, 3) array numpy would.

norm() → float

Euclidean length.

classmethod of(value: Any) → Vec3

From a Vec3, a length-3 sequence, or a scalar applied to all three.

rounded() → Vec3

Each component to the nearest integer, halves away from zero (not to even, as round() would).

classmethod zero() → Vec3
property array: numpy.ndarray

A new (3,) float64 array.

x: float
property xyz: tuple[float, float, float]

The components reversed, as renderers and the precomputed format expect.

y: float
z: float
property zyx: tuple[float, float, float]