Convenience constructor for cpVect structs.
2x2 matrix type used for tensors and such. Create a 2x2 matrix.
Transform a 2x2 matrix.
Add two vectors
Clamp v to length len.
2D 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.
Returns the distance between v1 and v2.
Returns the squared distance between v1 and v2. Faster than cpvdist() when you only need to compare distances.
Vector dot product.
Check if two vectors are equal. (Be careful when comparing floating point numbers!)
Returns the unit length vector for the given angle (in radians).
Returns the length of v.
Returns the squared length of v. Faster than cpvlength() when you only need to compare lengths.
Linearly interpolate between v1 and v2.
Linearly interpolate between v1 towards v2 by distance d.
Scalar multiplication.
Returns true if the distance between v1 and v2 is less than dist.
Negate a vector.
Returns a normalized copy of v.
@deprecated Just an alias for cpvnormalize() now.
Returns a perpendicular vector. (90 degree rotation)
Returns the vector projection of v1 onto v2.
Uses complex number multiplication to rotate v1 by v2. Scaling will occur if v1 is not a unit vector.
Returns a perpendicular vector. (-90 degree rotation)
Spherical linearly interpolate between v1 and v2.
Spherical linearly interpolate between v1 towards v2 by no more than angle a radians
Returns a string representation of v. Intended mostly for debugging purposes and not production use. Note: The string points to a static local and is reset every time the function is called. If you want to print more than one vector you will have to split up your printing onto separate lines.
Subtract two vectors.
Returns the angular direction v is pointing in (in radians).
Inverse of cpvrotate().
Chipmunk's 2D vector type along with a handy 2D vector math lib. Constant for the zero vector.