#lerp(f1 : Number, f2 : Number, t : Number) : Number#
Linearly interpolate (or extrapolate) between f1 and f2 by t percent.
#lerpconst(f1 : Number, f2 : Number, d : Number) : Number#
Linearly interpolate from f1 to f2 by no more than d.
Chipmunk's 2D vector type.
.angle(a : Number) : self#
Returns the unit length vector for the given angle (in radians).
Linearly interpolate between v1 towards v2 by distance d.
Spherical linearly interpolate between v1 and v2.
Spherical linearly interpolate between v1 towards v2 by no more than angle a radians
Check if two vectors are equal.
(Be careful when comparing floating point numbers!)
Returns the closest point on the line segment
b, to the point stored in this
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 squared distance between this vector and v2.
dist when you only need to compare distances.
#lengthsq : Float64#
Returns the squared length of the vector.
length when you only need to compare lengths.
Returns true if the distance between this vector and v2 is less than dist.
Uses complex number multiplication to rotate the vector by v2.
Scaling will occur if the vector is not a unit vector.
#to_angle : Float64#
Returns the angular direction the vector is pointing in (in radians).
Chipmunk's axis-aligned 2D bounding box type. (left, bottom, right, top)
BB fitting a circle with the position p and radius r.
BB centered on a point with the given extents (half sizes).
Returns true if the other
BB lies completely within this one.
Returns the minimal bounding box that contains both this
BB and the point.
Return true if the bounding box intersects the line segment with ends a and b.
Returns the fraction along the segment query the
BB is hit.
Returns INFINITY if it doesn't hit.
2x2 matrix type used for tensors and such.
[[a b][c d]])
Column major 2x3 affine transform.
IDENTITY = new#
Identity transform matrix.
.new(a : Number = 1, b : Number = 0, c : Number = 0, d : Number = 1, tx : Number = 0, ty : Number = 0)#
Construct a new transform matrix.
- (a, b) is the x basis vector.
- (c, d) is the y basis vector.
- (tx, ty) is the translation.
.new_transpose(a : Number, c : Number, tx : Number, b : Number, d : Number, ty : Number) : self#
Construct a new transform matrix in transposed order.
Create a rigid transformation matrix. (translation + rotation)