Planar logo

Previous topic

planar – Global Definitions

Next topic

planar.Vec2Array – 2D Vector Arrays

This Page

planar.Vec2 – 2D Vectors

class planar.Vec2

Two dimensional immutable vector.

Vec2(x, y)

static polar()
Create a vector from polar coordinates.
almost_equals
Compare vectors for approximate equality.
angle
The angle the vector makes to the positive x axis in the range (-180, 180]
angle_to
Compute the smallest angle from this vector to another.
clamped
Compute a vector in the same direction with a bounded length.
cross
Compute the cross product with another vector.
distance_to
Compute the distance to another point vector.
dot
Compute the dot product with another vector.
is_null
Flag indicating if the vector is effectively zero-length.
length
The length or scalar magnitude of the vector.
length2
The square of the length of the vector.
lerp
Compute a vector by linear interpolation between this vector and another.
normalized
Return the vector scaled to unit length. If the vector is null, the null vector is returned.
perpendicular
Compute the perpendicular vector.
project
Compute the projection of another vector onto this one.
reflect
Compute the reflection of this vector against another.
rotated
Compute the vector rotated by an angle, in degrees.
scaled_to
Compute the vector scaled to a given length. If the vector is null, the null vector is returned.
x
The horizontal coordinate.
y
The vertical coordinate.
class planar.Point
An alias for Vec2. Useful for code clarity.