Advertisement
Guest User

Untitled

a guest
May 16th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. def plane(p1,p2,p3):
  2. v1=VminusV((p2[0],p2[1],heights[p2[0],p2[1]]),(p1[0],p1[1],heights[p1[0],p1[1]]))
  3. v2=VminusV((p3[0],p3[1],heights[p3[0],p3[1]]),(p1[0],p1[1],heights[p1[0],p1[1]]))
  4. n=VxV(v1,v2)
  5. point=(p1[0],p1[1],heights[p1[0],p1[1]])
  6. d=-(VdotV(n,point))
  7. return (*n,d)
  8.  
  9. def getappl(x,y):
  10. if (int(x)+int(y))%2==0:
  11. if x%1<y%1:
  12. pl = plane((int(x),int(y)),(int(x),int(y+1)),(int(x+1),int(y+1)))
  13. else:
  14. pl = plane((int(x),int(y)),(int(x+1),int(y+1)),(int(x+1),int(y)))
  15. else:
  16. if (1-x%1)<y%1:
  17. pl = plane((int(x+1),int(y)),(int(x),int(y+1)),(int(x+1),int(y+1)))
  18. else:
  19. pl = plane((int(x),int(y)),(int(x),int(y+1)),(int(x+1),int(y)))
  20. return -(pl[0]*x+pl[1]*y+pl[3])/pl[2]
  21.  
  22. def hor(p1,p2):
  23. d = VminusV(p2,p1)
  24. k=int(max(abs(d[0]),abs(d[1])))
  25. step = 1/k
  26. for i in range(k):
  27. cur = VplusV(p1,VxR(d,i*step))
  28. if cur[2]<getappl(cur[0],cur[1]):
  29. return False
  30. return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement