copapy.vector#

class copapy.vector(values)#

Bases: Generic[TNum]

Mathematical vector class supporting basic operations and interactions with values.

Create a vector with given values.

Parameters:

values (Iterable[TypeVar(TNum, int, float) | value[TypeVar(TNum, int, float)]]) – iterable of constant values

cross(other)#

3D cross product

Return type:

vector[float]

dot(other)#
Return type:

Any

homogenize()#
Return type:

vector[TypeVar(TNum, int, float)]

magnitude()#

Magnitude (length) of the vector.

Return type:

float | value[float]

map(func)#

Applies a function to each element of the vector and returns a new vector.

Parameters:

func (Callable[[Any], value[TypeVar(U, int, float)] | TypeVar(U, int, float)]) – A function that takes a single argument.

Return type:

vector[TypeVar(U, int, float)]

Returns:

A new vector with the function applied to each element.

normalize()#

Returns a normalized (unit length) version of the vector.

Return type:

vector[float]

property shape: tuple[int]#

Return the shape of the vector as (length,).

sum()#

Sum of all vector elements.

Return type:

Any