Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Vector2 Lerp(Vector2 v1, Vector2 v3, float x2) {
- // Ensure the xValue is between the two vectors
- if (!(v1.x < x2) || !(x2 < v3.x))
- return new Vector2(0, 0);
- // Get slope
- float m = ((v3.x - v1.x) / (v1.y - v3.y));
- System.out.println("Slope is " + m);
- // Determine Y value
- float y2 = ((x2 - v1.x) * (v3.y - v1.y) / (v3.x - v1.x)) + v1.y;
- return new Vector2(x2, y2);
- }
Add Comment
Please, Sign In to add comment