dchip.cpVect

Undocumented in source.

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(cpVect v1, cpVect v2)

Add two vectors

cpvclamp
cpVect cpvclamp(cpVect v, cpFloat len)

Clamp v to length len.

cpvcross
cpFloat cpvcross(cpVect v1, 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(cpVect v1, cpVect v2)

Returns the distance between v1 and v2.

cpvdistsq
cpFloat cpvdistsq(cpVect v1, cpVect v2)

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

cpvdot
cpFloat cpvdot(cpVect v1, cpVect v2)

Vector dot product.

cpveql
cpBool cpveql(cpVect v1, cpVect v2)

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

cpvforangle
cpVect cpvforangle(cpFloat a)

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

cpvlength
cpFloat cpvlength(cpVect v)

Returns the length of v.

cpvlengthsq
cpFloat cpvlengthsq(cpVect v)

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

cpvlerp
cpVect cpvlerp(cpVect v1, cpVect v2, 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(cpVect v, cpFloat s)

Scalar multiplication.

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

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

cpvneg
cpVect cpvneg(cpVect v)

Negate a vector.

cpvnormalize
cpVect cpvnormalize(cpVect v)

Returns a normalized copy of v.

cpvnormalize_safe
cpVect cpvnormalize_safe(cpVect v)

@deprecated Just an alias for cpvnormalize() now.

cpvperp
cpVect cpvperp(cpVect v)

Returns a perpendicular vector. (90 degree rotation)

cpvproject
cpVect cpvproject(cpVect v1, cpVect v2)

Returns the vector projection of v1 onto v2.

cpvrotate
cpVect cpvrotate(cpVect v1, cpVect v2)

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

cpvrperp
cpVect cpvrperp(cpVect v)

Returns a perpendicular vector. (-90 degree rotation)

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

Spherical linearly interpolate between v1 and v2.

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

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

cpvstr
string cpvstr(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(cpVect v1, cpVect v2)

Subtract two vectors.

cpvtoangle
cpFloat cpvtoangle(cpVect v)

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

cpvunrotate
cpVect cpvunrotate(cpVect v1, 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