Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let getInterpolatedValue = (currentPoint, nextPoint, mouseVector) => {
- let projection = getVectorProjection(currentPoint, nextPoint, mouseVector);
- let dist = linedist(currentPoint, nextPoint);
- if (projection === 0) {
- return {
- value: currentPoint,
- projection: 0
- };
- }
- let t = projection / dist;
- let x0 = currentPoint.x,
- y0 = currentPoint.y,
- y1 = nextPoint.y,
- x1 = nextPoint.x;
- let value = {
- x: (1 - t) * x0 + t * x1,
- y: (1 - t) * y0 + t * y1
- };
- return {
- value,
- projection
- };
- };
Add Comment
Please, Sign In to add comment