dchip.cpVect

Members

Aliases

cpv
alias cpv = cpVect

Convenience constructor for cpVect structs.

Functions

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

2x2 matrix type used for tensors and such. Create a 2x2 matrix.

cpMat2x2Transform
cpVect cpMat2x2Transform(cpMat2x2 m, cpVect v)

Transform a 2x2 matrix.

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.

cpvnormalize_safe
cpVect cpvnormalize_safe(const cpVect v)

@deprecated Just an alias for cpvnormalize() now.

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

cpvstr
string cpvstr(const cpVect v)

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.

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().

Variables

cpvzero
cpVect cpvzero;

Chipmunk's 2D vector type along with a handy 2D vector math lib. Constant for the zero vector.

Meta