File: knot.py

package info (click to toggle)
minetest-mod-pycraft 0.22-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,744 kB
  • sloc: python: 79,282; makefile: 10
file content (27 lines) | stat: -rw-r--r-- 614 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#
# Code under the MIT license by Alexander Pruss
#

#
# Draw a knot
#

from mc import *

mc = Minecraft()
playerPos = mc.player.getPos()
scale = 10
x0 = int(playerPos.x)
y0 = int(playerPos.y+5*scale)
z0 = int(playerPos.z)
t = 0
done = set()
while t < 2*pi:
# cinquefoil from http://www.maa.org/sites/default/files/images/upload_library/23/stemkoski/knots/page6.html
  x = x0+int( scale * cos(2*t) * (3 + cos(5*t)) )
  y = y0+5*scale+int( scale * sin(2*t) * (3 + cos(5*t)) )
  z = z0+int( scale * sin(5*t) )
  if (x,y,z) not in done:
      mc.setBlock(x,y,z,GOLD_BLOCK)
      done.add((x,y,z))
  t += 2*pi / 10000