# points.vectors¶

Contains the Vector class.

class points.vectors.Vector(*values)[source]

A Vector is a sequence of numbers. They can represent a point in space, or the attributes of an object.

Vectors can be added and subtracted with + and -, but * is reserved for scalar multiplication - you can use it to multiply the vector by a number but not by another vector (there are special methods for this).

Parameters: values – The numbers that make up the Vector. If a single sequence is given, that sequence will be unpacked to make the vector.
length()[source]

Returns the length of the vector. This is the number of values it contains, not its magnitude().

Return type: int
values()[source]

Returns the values in the vector.

Return type: tuple
magnitude()[source]

Returns the magnitude of the vector - the length of the line it represents in space.

Return type: float
append(value)[source]

Adds a value to the end of the vector.

Parameters: value – the value to add.
insert(index, value)[source]

Insertes a value into the vector.

Parameters: index (int) – The location to insert to. value – the value to add.
remove(value)[source]

Removes a value from the vector.

Parameters: value – the value to remove.
pop(index=-1)[source]

Removes a value from the vector and returns it.

Parameters: index – the index to remove, default being -1. the removed value.
components()[source]

Returns the individual components that sum to make up the vector.

Returns: tuple of Vector
linearly_dependent_on(*vectors)[source]

Checks if this Vector is linearly dependent on a set of other vectors - that is, whether it is possible to construct this vector from a linear combination of the other vectors.

Parameters: *vectors – The vectors to check against. bool
linearly_independent_of(*vectors)[source]

Checks if this Vector is linearly independent of a set of other vectors - that is, whether it is impossible to construct this Vector from a linear combination of the other Vectors.

Parameters: *vectors – The vectors to check against. bool
span()[source]

Returns the vector’s span - the set of all vectors that can be constructed by scaling this vector.

Return type: VectorSpan
span_with(*vectors)[source]

Returns the span of this vector and others - the set of all vectors that can be constructed by scaling and adding the vectors.

Return type: VectorSpan
dot(other)[source]

Returns the dot product between this vector and another.

Parameters: other (Vector) – The other Vector. TypeError – If a non-Vector is given. ValueError – If the Vectors are of different lengths. float
cross(other)[source]

Returns the cross product between this vector and another. Only three-dimensional Vectors can do this (vectors of length 3).

Parameters: other (Vector) – The other Vector. TypeError – if a non-Vector is given. ValueError – if the Vectors are not three-dimensional. Vector
distance_to(other)[source]

Returns the distance between this and another vector, when originating at the origin.

Parameters: other (Vector) – the other Vector. float
angle_with(other, degrees=False)[source]

Returns the angle between this vector and another, in radians.

Parameters: other (Vector) – The other Vector. degrees (bool) – If True, the angle will be returned in degrees. TypeError – If a non-Vector is given. float
class points.vectors.VectorSpan(*vectors)[source]

A VectorSpan represents all the vectors that can be obtained by performing linear combinations of some starter set of vectors.

A Vector is in this span if it can be constructed from a linear combination of the defining Vectors. This is calculated using Gaussian elimination.

Parameters: *vectors – The vectors which define the span. Any vectors that are linearly dependent on the others will be discarded. ValueError – if vectors of different dimensions are provided.
dimension()[source]

The vector space that the span inhabits - any vectors of a different vector will never be in this span.

Return type: int
rank()[source]

The dimensions of the space the VectorSpan spans - regardless of the overall Vector Space it inhabits.

For example a Vector Span in three dimensional space might have a rank of 2 if it only spans a plane within that space.

Return type: int