orb.math.Vector module

class orb.math.Vector.Vector(x=0, y=0)

Bases: object

The Vector class is a 2D object. It is used to store points in 2D space and perform common Vector maths.

dist(other)

Return the distance between two points.

>>> Vector(5, 5).dist(Vector(10, 10))
7.0710678118654755
dot(other)

Return the dot product of two vectors

>>> Vector(0, 1).dot(Vector(1, 0))
0
mid(other)

Return the mid-point between two points

>>> mid = Vector(0, 0).mid(Vector(10, 10))
>>> (mid.x, mid.y)
(5.0, 5.0)
norm()

Return the normalized dot product.

>>> Vector(0, 1).norm()
1.0
normalized()

Return the normalized Vector

>>> v = Vector(10, 0).normalized()
>>> (v.x, v.y)
(1.0, 0.0)
perp()

Return a perpendicular Vector

>>> v = Vector(1, 1).perp()
>>> (v.x, v.y)
(1, -1.0)