copapy.vector#
- class copapy.vector(values)#
Bases:
ArrayType[TNum]Mathematical vector class supporting basic operations and interactions with values.
- ndim#
Number of dimensions (always 1 for vector).
- Type:
int
- shape#
Shape of the vector as a tuple.
- Type:
tuple[int, …]
Create a vector with given values.
- Parameters:
values (
Iterable[TypeVar(TNum,int,float) |value[TypeVar(TNum,int,float)]]) – iterable of constant values
- cross(other)#
Calculate the cross product of this vector with another 3D vector.
- dot(other)#
- Overloads:
self (vector[int]), other (vector[int]) → int | value[int]
self, other (vector[float]) → float | value[float]
self (vector[float]), other (vector[int] | vector[float]) → float | value[float]
self, other (vector[int] | vector[float]) → float | int | value[float] | value[int]
Calculate the dot product of this vector with another.
- get_scalar(index)#
Get a single scalar value from the vector.
- Parameters:
index (
int) – The index of the element to retrieve.- Return type:
TypeVar(TNum,int,float) |value[TypeVar(TNum,int,float)]- Returns:
The scalar value at the specified index.
- homogenize()#
Convert all elements to Copapy values if any element is a Copapy value.
- Return type:
vector[TypeVar(TNum,int,float)]- Returns:
Vector with homogeneous element type.
- magnitude()#
Magnitude (length) of the vector.
- Return type:
float|value[float]- Returns:
The magnitude of the vector as a scalar value.
- map(func)#
Applies a function to each element of the vector and returns a new vector.
- normalize()#
Calculate a normalized (unit length) version of the vector.
- Return type:
vector[float]- Returns:
A normalized (unit length) vector.
- sum()#
- Overloads:
self (vector[int]) → int | value[int]
self (vector[float]) → float | value[float]
Sum of all vector elements.
- Returns:
The sum of all vector elements as a scalar value.