Advertisement
Guest User

Untitled

a guest
May 12th, 2021
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. corners = [(0,3), (1,5), (3,3), (2,1)]
  5.  
  6. my_ranges = 10
  7. my_rows = 30
  8.  
  9. ulx, uly = corners[0]
  10. urx, ury = corners[1]
  11. lrx, lry = corners[2]
  12. llx, lly = corners[3]
  13.  
  14. rax, ray = ulx, uly
  15. rbx, rby = urx, ury
  16. wax, way = ulx, uly
  17. wbx, wby = llx, lly
  18.  
  19. rdirection = -1 if rax > rbx else 1
  20. wdirection = -1 if way > wby else 1
  21.  
  22. rxdist = abs(rax-rbx)
  23. rydist = abs(ray-rby)
  24. wxdist = abs(wax-wbx)
  25. wydist = abs(way-wby)
  26.  
  27. rxstep = rxdist/my_ranges
  28. rystep = rydist/my_ranges
  29. wxstep = wxdist/my_rows
  30. wystep = wydist/my_rows
  31.  
  32. range_points = []
  33. for i in range(my_ranges):
  34. x = rax + i*rxstep * rdirection
  35. y = ray + i*rystep
  36. range_points.append((x,y))
  37.  
  38. row_points = []
  39. for i in range(my_rows):
  40. x = wax + i*wystep
  41. y = way + i*wystep * wdirection
  42. row_points.append((x,y))
  43.  
  44. fig, axs = plt.subplots(1,1, figsize=(10,10))
  45. axs.plot([i[0] for i in corners], [i[1] for i in corners], 'o')
  46. axs.plot([i[0] for i in range_points], [i[1] for i in range_points], 'o')
  47. axs.plot([i[0] for i in row_points], [i[1] for i in row_points], 'o')
  48. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement