fibomat.linalg.vectors.vector_base module

exception fibomat.linalg.vectors.vector_base.VectorValueError[source]

Bases: ValueError

Exception of this type is raised if any non supported value type is passed to Vector.__init__.

__init__(*args, **kwargs)
args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class fibomat.linalg.vectors.vector_base.VectorBase(x: Optional[Union[fibomat.linalg.vectors.vector_base.T, fibomat.linalg.vectors.vector_base.VectorBase, Iterable[fibomat.linalg.vectors.vector_base.T]]] = None, y: Optional[fibomat.linalg.vectors.vector_base.T] = None, r: Optional[fibomat.linalg.vectors.vector_base.T] = None, phi: Optional[fibomat.linalg.vectors.vector_base.T] = None)[source]

Bases: Sequence[fibomat.linalg.vectors.vector_base.T], abc.ABC

__init__(x: Optional[Union[fibomat.linalg.vectors.vector_base.T, fibomat.linalg.vectors.vector_base.VectorBase, Iterable[fibomat.linalg.vectors.vector_base.T]]] = None, y: Optional[fibomat.linalg.vectors.vector_base.T] = None, r: Optional[fibomat.linalg.vectors.vector_base.T] = None, phi: Optional[fibomat.linalg.vectors.vector_base.T] = None)[source]
property x: fibomat.linalg.vectors.vector_base.T

X component the vector

Access:

get

Returns:

T

property y: fibomat.linalg.vectors.vector_base.T

X component the vector

Access:

get

Returns:

T

property r: fibomat.linalg.vectors.vector_base.T

Radial component the vector.

Access:

get

Returns:

float

property phi: float

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

Access:

get

Returns:

float

property length: fibomat.linalg.vectors.vector_base.T

Length (magnitude) of vector.

Access:

get

Returns:

T

property magnitude: fibomat.linalg.vectors.vector_base.T

Magnitude of vector.

Access:

get

Returns:

T

property mag: fibomat.linalg.vectors.vector_base.T

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

Access:

get

Returns:

T

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[fibomat.linalg.vectors.vector_base.T]) bool[source]

Checks if other is close to self component wise.

Args:

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

Returns:

bool

normalized() fibomat.linalg.vectors.vector_base.SelfT[source]

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

Returns:

SelfT

normalized_to(length: fibomat.linalg.vectors.vector_base.T) fibomat.linalg.vectors.vector_base.SelfT[source]

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

Args:

length (float): new length of vector

Returns:

Vector

rotated(theta: float, origin: Optional[Iterable[fibomat.linalg.vectors.vector_base.T]] = None) fibomat.linalg.vectors.vector_base.SelfT[source]

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

mirrored(mirror_axis: Iterable[fibomat.linalg.vectors.vector_base.T]) fibomat.linalg.vectors.vector_base.SelfT[source]

Return a mirrored version of the vector.

Args:

mirror_axis (VectorLike): mirror axis

Returns:

Vector

projected(other: Iterable[fibomat.linalg.vectors.vector_base.T]) fibomat.linalg.vectors.vector_base.SelfT[source]

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

Args:

other:

Returns:

Vector

dot(other: Iterable[fibomat.linalg.vectors.vector_base.T]) fibomat.linalg.vectors.vector_base.T[source]

Calculate dot product with other vector.

Args:

other(VectorLike): other vector

Returns:

float

cross(other: Iterable[fibomat.linalg.vectors.vector_base.T]) fibomat.linalg.vectors.vector_base.T[source]

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

count(value) integer return number of occurrences of value
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.