Advertisement
here2share

# plot_points_a2b.py

Apr 26th, 2017
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. # plot_points_a2b.py
  2.  
  3. # from point A to point B
  4.  
  5. import math
  6.  
  7. def div(a,b):
  8.     try: return a / b
  9.     except: return 0
  10.  
  11. def plot(incr=25):
  12.     x,y=[aX-bX,aY-bY]
  13.     L=div(max(abs(x),abs(y)),incr*1.0)
  14.     x,y=div(x,L)*-1,div(y,L)*-1
  15.     for z in range(0,int(L)+1):
  16.         print aX+(x*z), aY+(y*z)
  17.     print
  18.  
  19. aX,aY=[600,640]
  20. bX,bY=[1000,920]
  21.  
  22. plot()
  23.  
  24. aX,aY=[1000,640]
  25. bX,bY=[600,920]
  26.  
  27. plot()
  28.  
  29. aX,aY=[600,920]
  30. bX,bY=[1000,640]
  31.  
  32. plot()
  33.  
  34. aX,aY=[1000,920]
  35. bX,bY=[600,640]
  36.  
  37. plot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement