Created
August 20, 2019 12:55
-
-
Save fuzzy-focus/4ed06c16aad0b2f5b5f9690be77139d4 to your computer and use it in GitHub Desktop.
Minecraft Planer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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