Skip to content

Vectors

geronimo.geometry.vector.Vector

Generic class to represent a vector in an n-dimensional space.

__init__(values: list[float] | None = None, dimensions: int = 3)

Initialize a new vector. If no values are given, fill it with n zeroes, where n is the number of dimensions (default: 3).

from_points(origin: Point, tip: Point) -> Vector staticmethod

Constructs a new Vector from two given points, the origin of the vector and its tip (e.g. target, where it points to).

length() -> float

Get the length of the vector.

__add__(other: Vector) -> Vector

Adds two vectors together.

__sub__(other: Vector) -> Vector

Subtracts two vectors from each other.

__mul__(other: Vector | float | int) -> Vector | float

__mul__(other: Vector) -> float
__mul__(other: float | int) -> Vector

Compute the dot product of two vectors or scale the vector by a scalar.

__repr__() -> str

Representation of the vector.

__str__() -> str

Representation of the vector as a string.

is_perpendicular(other: Vector) -> bool

Check if two vectors are perpendicular to each other.

is_parallel(other: Vector) -> bool

Check if two given vectors are parallel.

get_scalar(other: Vector, check_uniform_scalar: bool = True) -> float

Gets the scalar λ (also known as k or r) for two given vectors. If check_uniform_scalar is set to True, the function will check if the two vectors actually have a uniform scalar λ before returning it, otherwise raising a ValueError.

It is recommended to leave check_uniform_scalar set to True at the expense of slightly more computational effort.

dimensions() -> int

Get the dimensionality of the vector.

normalize() -> Vector

Normalise the vector and return the result. Out-of-place.