Guest User

Untitled

a guest
Apr 23rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. public Vector2 Lerp(Vector2 v1, Vector2 v3, float x2) {
  2.  
  3.     // Ensure the xValue is between the two vectors
  4.     if (!(v1.x < x2) || !(x2 < v3.x))
  5.         return new Vector2(0, 0);
  6.  
  7.     // Get slope
  8.     float m = ((v3.x - v1.x) / (v1.y - v3.y));
  9.     System.out.println("Slope is " + m);
  10.  
  11.     // Determine Y value
  12.     float y2 = ((x2 - v1.x) * (v3.y - v1.y) / (v3.x - v1.x)) + v1.y;
  13.  
  14.     return new Vector2(x2, y2);
  15.     }
Add Comment
Please, Sign In to add comment