Guest User

Untitled

a guest
May 27th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. let getInterpolatedValue = (currentPoint, nextPoint, mouseVector) => {
  2. let projection = getVectorProjection(currentPoint, nextPoint, mouseVector);
  3. let dist = linedist(currentPoint, nextPoint);
  4. if (projection === 0) {
  5. return {
  6. value: currentPoint,
  7. projection: 0
  8. };
  9. }
  10.  
  11. let t = projection / dist;
  12. let x0 = currentPoint.x,
  13. y0 = currentPoint.y,
  14. y1 = nextPoint.y,
  15. x1 = nextPoint.x;
  16.  
  17. let value = {
  18. x: (1 - t) * x0 + t * x1,
  19. y: (1 - t) * y0 + t * y1
  20. };
  21.  
  22. return {
  23. value,
  24. projection
  25. };
  26. };
Add Comment
Please, Sign In to add comment