File: Koch.m4

package info (click to toggle)
texlive-base 2020.20210202-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 791,092 kB
  • sloc: perl: 45,038; sh: 4,926; makefile: 4,655; ansic: 2,266; ruby: 2,231; tcl: 2,156; xml: 1,874; python: 822; cpp: 695; awk: 606; lisp: 199; sed: 8
file content (32 lines) | stat: -rw-r--r-- 489 bytes parent folder | download | duplicates (4)
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
28
29
30
31
32
.PS
# Koch snowflake
gen_init

  leng = 4
  X: 3,5
  nsides = 3; rot[1] = 0; rot[2] = -120; rot[3] = -120
  depth=4

  for i=1 to depth do {
    for j=1 to nsides do { tmp[j] = rot[j] } 
    leng = leng/3
    k = 0
    for j=1 to nsides do {
      rot[k+1] = tmp[j]
      rot[k+2] = 60
      rot[k+3] = -120
      rot[k+4] = 60
      k += 4
      }
    nsides = k
    }

  a = 0
  line from X to X
  for i=1 to nsides do {
   a += rot[i]
   X: X+(Rect_(leng,a))
   continue to X
   }

.PE