Created
May 10, 2016 14:41
-
-
Save hamukazu/bb5051b5be72760a56d3c5f18510d3bb to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
import numpy as np | |
import mcpi | |
import mcpi.block | |
import mcpi.minecraft | |
def line(mc, v1, v2): | |
v = v2 - v1 | |
norm = np.sqrt((v**2).sum()) | |
v = v / norm | |
for d in np.arange(0, norm, 0.2): | |
x, y, z = v1 + v * d | |
mc.setBlock(x, y, z, mcpi.block.WOOL) | |
a = (np.sqrt(5) + 1) / 2 | |
t = np.pi * 2 / 5 | |
u = np.pi * 1 / 5 | |
vertices = np.zeros((20, 3)) | |
for i in range(5): | |
vertices[i, :] = np.cos(i * t), 0, np.sin(i * t) | |
for i in range(5): | |
vertices[i + 5, :] = a * np.cos(i * t), 1, a * np.sin(i * t) | |
for i in range(5): | |
vertices[i + 10, :] = a * np.cos(i * t + u), a, a * np.sin(i * t + u) | |
for i in range(5): | |
vertices[i + 15, :] = np.cos(i * t + u), 1 + a, np.sin(i * t + u) | |
center = np.array([0, (1 + a) / 2, 0]) | |
vertices *= 20. | |
mc = mcpi.minecraft.Minecraft() | |
x, y, z = mc.player.getPos() | |
base = np.array([x + 50, y, z]) | |
vertices += base | |
for i in range(5): | |
j = (i + 1) % 5 | |
k = (i + 4) % 5 | |
line(mc, vertices[i, :], vertices[j, :]) | |
line(mc, vertices[i, :], vertices[i + 5, :]) | |
line(mc, vertices[i + 5, :], vertices[i + 10, :]) | |
line(mc, vertices[i + 5, :], vertices[k + 10, :]) | |
line(mc, vertices[i + 10, :], vertices[i + 15, :]) | |
line(mc, vertices[i + 15, :], vertices[j + 15, :]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment