Guest User

Untitled

a guest
Jul 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. def SampleLine(rho1, theta1, pt_min, pt_max):
  2. def get_intersect(rho2, theta2):
  3. y = (rho2 - rho1) / (math.tan(theta2) - math.tan(theta1))
  4. x = rho1 - math.tan(theta1) * y
  5. return (x, y)
  6.  
  7. x0, y0 = pt_min
  8. x1, y1 = pt_max
  9.  
  10. pts = list()
  11. pts += [ get_intersect(x0, 0.0) ]
  12. pts += [ get_intersect(x1, 0.0) ]
  13. pts += [ get_intersect(y0, math.pi / 2) ]
  14. pts += [ get_intersect(y1, math.pi / 2) ]
  15. pts.sort(key=lambda p: math.hypot(p[0], p[1]))
  16.  
  17. return pts[0], pts[1]
Add Comment
Please, Sign In to add comment