Chipmunk's 2D vector type.
Constructors
Returns the unit length vector for the given angle (in radians).
Sourcelerp(v1 :
Vect, v2 :
Vect, t :
Number) :
Vect Linearly interpolate between v1 and v2.
Sourcelerpconst(v1 :
Vect, v2 :
Vect, d :
Number) :
Vect Linearly interpolate between v1 towards v2 by distance d.
Sourceslerp(v1 :
Vect, v2 :
Vect, t :
Number) :
Vect Spherical linearly interpolate between v1 and v2.
Sourceslerpconst(v1 :
Vect, v2 :
Vect, a :
Number) :
Vect Spherical linearly interpolate between v1 towards v2 by no more than angle a radians
SourceInstance methods
Check if two vectors are equal.
(Be careful when comparing floating point numbers!)
SourceClamp the vector to length len.
Sourceclosest_point_on_segment(a : Vect, b : Vect) : Vect
Returns the closest point on the line segment a b, to the point stored in this Vect.
Source2D vector cross product analog.
The cross product of 2D vectors results in a 3D vector with only a z component.
This function returns the magnitude of the z value.
SourceReturns the distance between this vector and v2.
SourceReturns the squared distance between this vector and v2.
Faster than dist when you only need to compare distances.
Sourcelength
Returns the length of the vector.
Sourcelengthsq
Returns the squared length of the vector.
Faster than length when you only need to compare lengths.
SourceReturns true if the distance between this vector and v2 is less than dist.
Sourcenormalize
Returns a normalized copy of the vector (unit vector).
Sourceperp
Returns a perpendicular vector. (90 degree rotation)
Sourceproject(v2 : Vect) : Vect
Returns the vector projection of the vector onto v2.
Sourcerotate(v2 : Vect) : Vect
Uses complex number multiplication to rotate the vector by v2.
Scaling will occur if the vector is not a unit vector.
Sourcerperp
Returns a perpendicular vector. (-90 degree rotation)
Sourceto_angle
Returns the angular direction the vector is pointing in (in radians).
Sourceunrotate(v2 : Vect) : Vect
Source