Skip to content

Instantly share code, notes, and snippets.

@fuzzy-focus
Created August 20, 2019 12:55
Show Gist options
  • Save fuzzy-focus/4ed06c16aad0b2f5b5f9690be77139d4 to your computer and use it in GitHub Desktop.
Save fuzzy-focus/4ed06c16aad0b2f5b5f9690be77139d4 to your computer and use it in GitHub Desktop.
Minecraft Planer
import math
import itertools
from collections import namedtuple
point = namedtuple("point", "x y z")
a,b,c = 10,10,5
dx,dy,dz = 10,10,5
points = set()
for x,y in itertools.product(range(0,dx+1), range(0, dy+1)):
try:
z = c*math.sqrt(1-x*x/a/a-y*y/b/b)
points.add(point(x,y,int(z)))
except ValueError:
pass
for z in range(0, dz+1):
print(f"layer z={z}")
s = '\n'.join(''.join(('#' if point(x,y,z) in points else '.') for x in range(0, dx+1)) for y in range(0,dy+1))
print(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment