Vector lerp
vector-lerp · version 1.0.0 · Vectors & matrices · free, no key needed
Linearly interpolate (or extrapolate) between two equal-length finite-number vectors.
Use when you need to: vector linear interpolation · lerp between two vectors · vector extrapolation.
Supported
- vector linear interpolation
- lerp between two vectors
- vector extrapolation
Not supported
- vectors of different lengths
- spherical (slerp) interpolation
- non-linear interpolation curves
Behavior
- Inputs a and b are arrays of finite JSON numbers with the same length, from 1 to 64 entries, magnitude bounded to at most 1000000.
- Input t is a finite number with magnitude at most 1000; t is not clamped to [0, 1], so values outside that range extrapolate.
- The result is result[i] = a[i] + t * (b[i] - a[i]), computed in IEEE-754 double precision. t=0 returns a; t=1 returns b.
- A result entry of -0 is normalized to 0.
Input
a(array of number, required): min items 1; max items 64b(array of number, required): min items 1; max items 64t(number, required)
Output
result(array of number, required)
Limits
- max dim: 64
- max abs value: 1000000
- max abs t: 1000
Example
Request input:
{
"a": [
0,
0
],
"b": [
10,
20
],
"t": 0.5
}
Response:
{
"result": {
"result": [
5,
10
]
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "vector-lerp",
"version": "1.0.0",
"input": {
"a": [
0,
0
],
"b": [
10,
20
],
"t": 0.5
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/vector-lerp/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"a":[0,0],"b":[10,20],"t":0.5}'
The machine-readable contract is at /v1/tools/vector-lerp/versions/1.0.0.
CLI
node cli.mjs run vector-lerp 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Vector add: Add two equal-length finite-number vectors elementwise.
- Vector angle: Compute the angle in radians between two equal-length finite-number vectors.
- Vector dot: Compute the dot (scalar) product of two equal-length finite-number vectors.
- Vector outer product: Compute the outer product of two finite-number vectors, producing a matrix.
- Matrix vector multiply: Multiply an MxN finite-number matrix by a length-N finite-number vector, producing a length-M vector.
- Vector approx equal: Compare two equal-length finite-number vectors for approximate equality within an absolute tolerance.