UNPKG

@jscad/modeling

Version:

Constructive Solid Geometry (CSG) Library for JSCAD

20 lines (18 loc) 482 B
/** * Performs a linear interpolation between two vectors. * * @param {vec2} out - receiving vector * @param {vec2} a - first operand * @param {vec2} b - second operand * @param {Number} t - interpolation amount between the two vectors * @returns {vec2} out * @alias module:modeling/maths/vec2.lerp */ const lerp = (out, a, b, t) => { const ax = a[0] const ay = a[1] out[0] = ax + t * (b[0] - ax) out[1] = ay + t * (b[1] - ay) return out } module.exports = lerp