MCPcopy
hub / github.com/franciscop/ola / position

Function position

ola.js:3–9  ·  view source on GitHub ↗
(x0, v0, t1, t)

Source from the content-addressed store, hash-verified

1// Calculate the position based on the current position, speed and time:
2// https://www.wolframalpha.com/input/?i=x+%3D+2+*+t+%5E+3+-+3+*+t+%5E+2+%2B+1+from+t+%3D+0+to+t+%3D+1
3const position = (x0, v0, t1, t) => {
4 const a = (v0 * t1 + 2 * x0) / t1 ** 3;
5 const b = -(2 * v0 * t1 + 3 * x0) / t1 ** 2;
6 const c = v0;
7 const d = x0;
8 return a * t ** 3 + b * t ** 2 + c * t + d;
9};
10
11// Calculate the speed based on the current position, speed and time:
12const speed = (x0, v0, t1, t) => {

Callers 1

ola.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected