Guest User

Untitled

a guest
Aug 6th, 2012
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. Solved, Java, Generate a direct path of points between two points
  2. f(start,end,nPoints) -> (path)
  3. delta = (end-start) / nPoints //Find the best difference vector.
  4. current = start //Set the current point to the start.
  5. i = 0
  6. while(|current-end| < epsilon)
  7. current += delta
  8. path[i] = current
  9. i = i + 1
  10.  
  11. float ratio = (y2 - y1) / (x2 - x1);
  12.  
  13. width = x2 - x1;
  14. for(int i = 0; i < width; i++) {
  15. float x = x1 + i;
  16. float y = y1 + (ratio * i);
  17. points.add(new Point(x,y));
  18. }
  19.  
  20. 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