Vec2¶
from kurbopy import Vec2
vec = Vec2(50.0, 100.0)
- class kurbopy.Vec2¶
A 2D vector.
This is intended primarily for a vector in the mathematical sense, but it can be interpreted as a translation, and converted to and from a point (vector relative to the origin) and size.
- ZERO()¶
The vector (0, 0).
- atan2()¶
Angle of vector.
If the vector is interpreted as a complex number, this is the argument. The angle is expressed in radians.
- ceil()¶
Returns a new Vec2, with x and y rounded up to the nearest integer, unless they are already an integer.
- cross(other)¶
Cross product of two vectors.
This is signed so that (0, 1) × (1, 0) = 1.
- dot(other)¶
Dot product of two vectors.
- expand()¶
Returns a new Vec2, with x and y rounded away from zero to the nearest integer, unless they are already an integer.
- floor()¶
Returns a new Vec2, with x and y rounded down to the nearest integer, unless they are already an integer.
- from_angle(th)¶
A unit vector of the given angle.
With th at zero, the result is the positive X unit vector, and at π/2, it is the positive Y unit vector. The angle is expressed in radians.
Thus, in a Y-down coordinate system (as is common for graphics), it is a clockwise rotation, and in Y-up (traditional for math), it is anti-clockwise. This convention is consistent with Affine.rotate.
- hypot()¶
Magnitude of vector.
- hypot2()¶
Magnitude squared of vector.
- is_finite()¶
Is this Vec2 finite?
- is_nan()¶
Is this Vec2 NaN?
- lerp(other, t)¶
Linearly interpolate between two vectors.
- normalize()¶
Returns a vector of magnitude 1.0 with the same angle as self; i.e. a unit/direction vector.
This produces NaN values when the magnitutde is 0.
- round()¶
Returns a new Vec2, with x and y rounded to the nearest integer.
- trunc()¶
Returns a new Vec2, with x and y rounded towards zero to the nearest integer, unless they are already an integer.
- x¶
- y¶