Vector helpers
Vector predicates and scalar-vector operations (BOSL2 vectors.scad).
-
pybosl2.vectors.is_vector(v, length=
None, zero=None, eps=1e-09)[source]
Check if v is a list/tuple/ndarray of finite numbers.
Optionally of a given length and/or zero-ness.
- Parameters:
- v : Point | Sequence[float] | ndarray
-
- length : int | None
-
- zero : bool | None
-
- eps : float
-
- Return type:
bool
-
pybosl2.vectors.add_scalar(v, s)[source]
Return v with scalar s added to every entry.
- Parameters:
- v : Point | Sequence[float] | ndarray
-
- s : float
-
- Return type:
ndarray
-
pybosl2.vectors.unit(v, error=
None)[source]
Normalize v to unit length.
If v has (near) zero length, returns error if given, else raises
ValueError (matching BOSL2’s default assert-on-zero-vector behavior).
- Parameters:
- v : Point | Sequence[float] | ndarray
-
- error : Point | Sequence[float] | ndarray | None
-
- Return type:
ndarray