fibomat.linalg.vectors.vector_base module#
- exception fibomat.linalg.vectors.vector_base.VectorValueError[source]#
Bases:
ValueErrorException 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: T | VectorBase | Iterable[T] | None = None, y: T | None = None, r: T | None = None, phi: T | None = None)[source]#
-
- __init__(x: T | VectorBase | Iterable[T] | None = None, y: T | None = None, r: T | None = None, phi: T | None = None)[source]#
- property x: T#
X component the vector
- Access:
get
- Returns:
T
- property y: T#
X component the vector
- Access:
get
- Returns:
T
- property r: 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: T#
Length (magnitude) of vector.
- Access:
get
- Returns:
T
- property magnitude: T#
Magnitude of vector.
- Access:
get
- Returns:
T
- property mag: 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[T]) bool[source]#
Checks if other is close to self component wise.
- Args:
other (Vector, Iterable[float]): other vector(like)
- Returns:
bool
- normalized() SelfT[source]#
Create a new vector with same
Vector.phibutVector.r= 1.- Returns:
SelfT
- normalized_to(length: T) SelfT[source]#
Create a new vector
Vector.phibutVector.r= length.- Args:
length (float): new length of vector
- Returns:
Vector
- rotated(theta: float, origin: Iterable[T] | None = None) 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[T]) SelfT[source]#
Return a mirrored version of the vector.
- Args:
mirror_axis (VectorLike): mirror axis
- Returns:
Vector
- projected(other: Iterable[T]) 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[T]) T[source]#
Calculate dot product with other vector.
- Args:
other(VectorLike): other vector
- Returns:
float
- cross(other: Iterable[T]) 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.