fibomat.linalg.vectors.vector module#

class fibomat.linalg.vectors.vector.Vector(*args, **kwargs)[source]#

Bases: VectorBase[float]

__init__(*args, **kwargs)[source]#
property angle_about_x_axis: float#

Angle between vector and positive x axis (angle will be in [0, 2pi]).

Access:

get

Returns:

float

Raises:

RuntimeError: Raised if self is null vector.

close_to(other: Iterable[T]) bool#

Checks if other is close to self component wise.

Args:

other (Vector, Iterable[float]): other vector(like)

Returns:

bool

count(value) integer -- return number of occurrences of value#
cross(other: Iterable[T]) T#

Cross product in 2d.

a x b = a.x * b.y - a.y * b.x

a = self, b = other

Args:

other(VectorLike): other vector

Returns:

T

dot(other: Iterable[T]) T#

Calculate dot product with other vector.

Args:

other(VectorLike): other vector

Returns:

float

index(value[, start[, stop]]) integer -- return first index of value.#

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

property length: T#

Length (magnitude) of vector.

Access:

get

Returns:

T

property mag: T#

Magnitude of vector (short form of VectorBase.magnitude).

Access:

get

Returns:

T

property magnitude: T#

Magnitude of vector.

Access:

get

Returns:

T

mirrored(mirror_axis: Iterable[T]) SelfT#

Return a mirrored version of the vector.

Args:

mirror_axis (VectorLike): mirror axis

Returns:

Vector

normalized() SelfT#

Create a new vector with same Vector.phi but Vector.r = 1.

Returns:

SelfT

normalized_to(length: T) SelfT#

Create a new vector Vector.phi but Vector.r = length.

Args:

length (float): new length of vector

Returns:

Vector

property phi: float#

Angular component of vector (angle between vector and x axis in radiant between -pi and pi).

Access:

get

Returns:

float

projected(other: Iterable[T]) SelfT#

Project other onto self. https://en.wikibooks.org/wiki/Linear_Algebra/Orthogonal_Projection_Onto_a_Line

Args:

other:

Returns:

Vector

property r: T#

Radial component the vector.

Access:

get

Returns:

float

rotated(theta: float, origin: Iterable[T] | None = None) SelfT#

Return a rotated copy the vector around center with angle theta in math. positive direction.

Args:

theta (float): rotation angle in rad origin (VectorLike): rotation center, default to [0., 0.]

Returns:

Vector

property x: T#

X component the vector

Access:

get

Returns:

T

property y: T#

X component the vector

Access:

get

Returns:

T