chipmunk.cpVect

Members

Static functions

cpMat2x2New
cpMat2x2 cpMat2x2New(cpFloat a, cpFloat b, cpFloat c, cpFloat d)

@} @defgroup cpMat2x2 cpMat2x2 2x2 matrix type used for tensors and such. @{

cpv
cpVect cpv(const cpFloat x, const cpFloat y)

Convenience constructor for cpVect structs.

cpvadd
cpVect cpvadd(const cpVect v1, const cpVect v2)

Add two vectors

cpvclamp
cpVect cpvclamp(const cpVect v, const cpFloat len)

Clamp v to length len.

cpvcross
cpFloat cpvcross(const cpVect v1, const cpVect v2)

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.

cpvdist
cpFloat cpvdist(const cpVect v1, const cpVect v2)

Returns the distance between v1 and v2.

cpvdistsq
cpFloat cpvdistsq(const cpVect v1, const cpVect v2)

Returns the squared distance between v1 and v2. Faster than cpvdist() when you only need to compare distances.

cpvdot
cpFloat cpvdot(const cpVect v1, const cpVect v2)

Vector dot product.

cpveql
cpBool cpveql(const cpVect v1, const cpVect v2)

Check if two vectors are equal. (Be careful when comparing floating point numbers!)

cpvforangle
cpVect cpvforangle(const cpFloat a)

Returns the unit length vector for the given angle (in radians).

cpvlength
cpFloat cpvlength(const cpVect v)

Returns the length of v.

cpvlengthsq
cpFloat cpvlengthsq(const cpVect v)

Returns the squared length of v. Faster than cpvlength() when you only need to compare lengths.

cpvlerp
cpVect cpvlerp(const cpVect v1, const cpVect v2, const cpFloat t)

Linearly interpolate between v1 and v2.

cpvlerpconst
cpVect cpvlerpconst(cpVect v1, cpVect v2, cpFloat d)

Linearly interpolate between v1 towards v2 by distance d.

cpvmult
cpVect cpvmult(const cpVect v, const cpFloat s)

Scalar multiplication.

cpvnear
cpBool cpvnear(const cpVect v1, const cpVect v2, const cpFloat dist)

Returns true if the distance between v1 and v2 is less than dist.

cpvneg
cpVect cpvneg(const cpVect v)

Negate a vector.

cpvnormalize
cpVect cpvnormalize(const cpVect v)

Returns a normalized copy of v.

cpvperp
cpVect cpvperp(const cpVect v)

Returns a perpendicular vector. (90 degree rotation)

cpvproject
cpVect cpvproject(const cpVect v1, const cpVect v2)

Returns the vector projection of v1 onto v2.

cpvrotate
cpVect cpvrotate(const cpVect v1, const cpVect v2)

Uses complex number multiplication to rotate v1 by v2. Scaling will occur if v1 is not a unit vector.

cpvrperp
cpVect cpvrperp(const cpVect v)

Returns a perpendicular vector. (-90 degree rotation)

cpvslerp
cpVect cpvslerp(const cpVect v1, const cpVect v2, const cpFloat t)

Spherical linearly interpolate between v1 and v2.

cpvslerpconst
cpVect cpvslerpconst(const cpVect v1, const cpVect v2, const cpFloat a)

Spherical linearly interpolate between v1 towards v2 by no more than angle a radians

cpvsub
cpVect cpvsub(const cpVect v1, const cpVect v2)

Subtract two vectors.

cpvtoangle
cpFloat cpvtoangle(const cpVect v)

Returns the angular direction v is pointing in (in radians).

cpvunrotate
cpVect cpvunrotate(const cpVect v1, const cpVect v2)

Inverse of cpvrotate().

Meta