Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Solved, Java, Generate a direct path of points between two points
- f(start,end,nPoints) -> (path)
- delta = (end-start) / nPoints //Find the best difference vector.
- current = start //Set the current point to the start.
- i = 0
- while(|current-end| < epsilon)
- current += delta
- path[i] = current
- i = i + 1
- float ratio = (y2 - y1) / (x2 - x1);
- width = x2 - x1;
- for(int i = 0; i < width; i++) {
- float x = x1 + i;
- float y = y1 + (ratio * i);
- points.add(new Point(x,y));
- }
- double dist = Math.sqr((x2 - x1)^2 + (y2 - y1)^2); //obviously wont compile but you get the idea.
Advertisement
Add Comment
Please, Sign In to add comment