Skip to content

vector

vector module contains Vector class used to represent 2D coordinates.

Vector

Bases: ModelType

Represents a point in cartesian coordinate space.

xy property

Return point as tuple of Units.

unit

Bases: Namespace

Namespace containing unit vectors.

from_tuple classmethod

from_tuple(data: tuple[float, float]) -> Self

Create a new point from a tuple.

__add__

__add__(other: object) -> Vector

Add two points.

__sub__

__sub__(other: object) -> Vector

Subtract two points.

__mul__

__mul__(other: object) -> Vector

Multiply two points.

__truediv__

__truediv__(other: object) -> Vector

Divide two points.

__eq__

__eq__(other: object) -> bool

Check if two points are equal.

__lt__

__lt__(other: object) -> bool

Check if point is less than other point.

__gt__

__gt__(other: object) -> bool

Check if point is greater than other point.

__ge__

__ge__(other: object) -> bool

Check if point is greater than or equal to other point.

__le__

__le__(other: object) -> bool

Check if point is less than or equal to other point.

__neg__

__neg__() -> Vector

Negate vector values.

angle_between

angle_between(other: Vector) -> float

Calculate clockwise angle between two vectors in degrees.

Value returned is always between 0 and 360 (can be 0, never 360).

self is the starting vector, other is the ending vector.

from math import * s = Vector(x=sin(pi / 4) * 1, y=-sin(pi / 4) * 1) e = Vector(x=-sin(pi / 4) * 1, y=-sin(pi / 4) * 1) s.angle_between(e) 90.0 e.angle_between(s) 270.0

angle_between_cc

angle_between_cc(other: Vector) -> float

Calculate counter clockwise angle between two vectors in degrees.

Value returned is always between 0 and 360 (can be 0, never 360).

normalized

normalized() -> Vector

Return normalized (unit length) vector.

length

length() -> float

Return length of vector.

transform

transform(matrix: Matrix3x3) -> Vector

Transform vector by matrix.