# 10.1.4.17. Vector¶

Module to implement vector.

Example of usage:

v = Vector2D(10, 20)
v = Vector2D((10, 20))
v = Vector2D([10, 20])
v = Vector2D(iterable)
v = Vector2D(v)

v.x
v.y

# array interface
v[0], v[1]
iter(v)

-v

v + v
v += v

v - v
v -= v

v * 2
2 * v
v *= 2

v / 2
v /= 2

class Patro.GeometryEngine.Vector.HomogeneousVector2D(vector)[source]

2D Homogeneous Coordinate Vector

__init__(vector)[source]

Initialize self. See help(type(self)) for accurate signature.

to_vector()[source]
v
w
class Patro.GeometryEngine.Vector.NormalisedVector2D(*args)[source]

2D Normalised Vector

__init__(*args)[source]

Initialize self. See help(type(self)) for accurate signature.

__mul__(scale)[source]

Return a new vector equal to the self scaled by scale

__rmul__(scale)[source]

Return a new vector equal to the self scaled by scale

class Patro.GeometryEngine.Vector.Vector2D(*args)[source]

2D Vector

__imul__(scale)[source]

Scale self by scale

__itruediv__(scale)[source]

Scale self by 1/scale

__mul__(scale)[source]

Return a new vector equal to the self scaled by scale

__rmul__(scale)[source]

Return a new vector equal to the self scaled by scale

__truediv__(scale)[source]

Return a new vector equal to the self dvivided by scale

divide(scale_x, scale_y)[source]

Scale self by 1/scale

static from_angle(angle)[source]

Create the unitary vector (cos(angle), sin(angle)). angle is in degree.

classmethod from_coordinates(*coordinates)[source]
static from_ellipse(radius_x, radius_y, angle)[source]

classmethod from_list(coordinates)[source]
static from_polar(radius, angle)[source]

static middle(p0, p1)[source]

Return the middle point.

normalise()[source]

Normalise the vector

rint()[source]
scale(scale_x, scale_y)[source]

Scale self by scale

to_normalised()[source]

Return a normalised vector

class Patro.GeometryEngine.Vector.Vector2DBase(*args)[source]
__abs__()[source]

Return a new vector equal to abs of self

__add__(other)[source]

Return a new vector equal to the addition of self and other

__data_type__ = None
__eq__(v2)[source]

self == other

__getitem__(a_slice)[source]
__hash__ = None
__iadd__(other)[source]

__init__(*args)[source]

Initialize self. See help(type(self)) for accurate signature.

__isub__(other)[source]

Return a new vector equal to the subtraction of self and other

__iter__()[source]
__len__()[source]
__neg__()[source]

Return a new vector equal to the negation of self

__nonzero__()[source]
__pos__()[source]

Return a new vector equal to self

__repr__()[source]

Return repr(self).

__setitem__(index, value)[source]
__sub__(other)[source]

Return a new vector

_check_arguments(args)[source]
clone()[source]

Return a copy of self

to_int_list()[source]
v
x
y
class Patro.GeometryEngine.Vector.Vector2DFloatBase(*args)[source]
__data_type__

alias of builtins.float

almost_equal(v2, rtol=1e-05, atol=1e-08, equal_nan=False)[source]

self ~= other

angle_with(direction)[source]

Return the angle of self on direction

anti_normal

Return a new vector equal to self rotated of 90 degree in the clockwise direction

bounding_box

Bounding box of the primitive.

Return None if primitive is infinite.

cos_with(direction)[source]

Return the cosinus of self with direction

cross(other)[source]

Return the cross product of self with other

deviation_with(direction)[source]

Return the deviation of self with other

dot(other)[source]

Return the dot product of self with other

inverse_tan

Return the inverse tangent

is_orthogonal(other)[source]

Self is orthogonal with other

is_parallel(other, return_cross=False)[source]

Self is parallel with other

magnitude

Return the magnitude of the vector

magnitude_square

Return the square of the magnitude of the vector

normal

Return a new vector equal to self rotated of 90 degree in the counter clockwise direction

orientation

Return the orientation in degree

orientation_with(direction)

Return the angle of self on direction

parity

Return a new vector equal to self rotated of 180 degree

permute

Return a new vector where x and y are permuted.

perp_dot(other)

Return the cross product of self with other

projection_on(direction)[source]

Return the projection of self on direction

rotate(angle, counter_clockwise=True)[source]

Return a new vector equal to self rotated of angle degree in the counter clockwise direction

sin_with(direction)[source]

Return the sinus of self with other

tan

Return the tangent

class Patro.GeometryEngine.Vector.Vector2DInt(*args)[source]
__data_type__

alias of builtins.int

bounding_box

Bounding box of the primitive.

Return None if primitive is infinite.