Planar logo

Previous topic

planar.Vec2 – 2D Vectors

Next topic

planar.Affine – 2D Affine Transforms

This Page

planar.Vec2Array – 2D Vector Arrays

class planar.Vec2Array(vectors=())

Sequence of 2D vectors for batch operations

almost_equals(other)
Compare for approximate equality.
append(vector)

Append a vector to the end of the array.

Parameter:vector (Vec2 or 2-number sequence.) – Vector to append.
clamp(min_length=None, max_length=None)

Clamp the length of the vectors in this array in place between min_length and max_length.

Parameters:
  • min_length (float) – Minimum length of computed vectors.
  • max_length (float) – Maximum length of computed vectors. Must be >= min_length.
clamped(min_length=None, max_length=None)

Create a new array of vectors with lengths clamped between min_length and max_length.

Parameters:
  • min_length (float) – Minimum length of computed vectors.
  • max_length (float) – Maximum length of computed vectors. Must be >= min_length.
Return type:

Vec2Array

extend(iterable)

Append all vectors in iterable to the end of the array.

Parameter:iterable – Iterable object containing vectors.
classmethod from_points(points)
Create a new 2D sequence from an iterable of points
insert(index, vector)

Insert a vector at the specified index.

Parameters:
  • index (int) – Position before-which the vector is inserted.
  • vector (Vec2 or 2-number sequence.) – Vector to insert.
longest()
Return the vector in the array with the maximum length.
normalize()
Normalize the vectors in the array in place.
normalized()

Create a new array containing normalized vectors calculated from this array.

Return type:Vec2Array
shortest()
Return the vector in the array with the minimum length.
class planar.Seq2(vectors)

Fixed length 2D point/vector sequence

Parameter:vectors – A sequence of Vec2 objects.
almost_equals(other)
Compare for approximate equality.
classmethod from_points(points)
Create a new 2D sequence from an iterable of points