Add job for filling in a volume of blocks

This commit is contained in:
2020-12-05 10:56:56 +00:00
parent b8952db742
commit e0c5c3a6b9
8 changed files with 294 additions and 7 deletions
+10
View File
@@ -33,6 +33,16 @@ def phyp_king(p1, p2):
def pint(p):
return (floor(p[0]), floor(p[1]), floor(p[2]))
def pboundingbox(p1, p2):
b1 = (min(p1[0], p2[0]), min(p1[1], p2[1]), min(p1[2], p2[2]))
b2 = (max(p1[0], p2[0]), max(p1[1], p2[1]), max(p1[2], p2[2]))
return b1, b2
def pvolume(p1, p2):
b1, b2 = pboundingbox(p1, p2)
box = psub(b2, b1)
return (box[0]+1) * (box[1]+1) * (box[2]+1)
def cap(x, amount):
sign = 1 if x >= 0 else -1
return sign * min(abs(x), amount)