File tree Expand file tree Collapse file tree 2 files changed +39
-12
lines changed Expand file tree Collapse file tree 2 files changed +39
-12
lines changed Original file line number Diff line number Diff line change
1
+ <#
2
+ . SYNOPSIS
3
+ Draws a binary tree
4
+ . DESCRIPTION
5
+ Draws a binary tree using an L-system.
6
+ . LINK
7
+ https://en.wikipedia.org/wiki/L-system#Example_2:_fractal_(binary)_tree
8
+ #>
1
9
param (
2
- [double ]$Size = 20 ,
3
- [int ]$Order = 4 ,
4
- [double ]$Angle = 45
10
+ # The size of each segment
11
+ [double ]$Size = 42 ,
12
+ # The order of magnitude (the number of times the L-system is expanded)
13
+ [int ]$Order = 4 ,
14
+ # The angle
15
+ [double ]$Angle = 45
5
16
)
6
17
return $this.Rotate (-90 ).LSystem(' 0' , [Ordered ]@ {
7
18
' 1' = ' 11'
8
19
' 0' = ' 1[0]0'
9
20
}, $Order , [Ordered ]@ {
10
21
' [01]' = { $this.Forward ($Size ) }
11
- ' \[' = { $this.Rotate ($Angle * -1 ).Push( ) }
22
+ ' \[' = { $this.Push (). Rotate($Angle * -1 ) }
12
23
' \]' = { $this.Pop ().Rotate($Angle ) }
13
24
})
14
25
Original file line number Diff line number Diff line change
1
+ <#
2
+ . SYNOPSIS
3
+ Draws a Fractal Plant
4
+ . DESCRIPTION
5
+ Draws a Fractal Plant as an L-System
6
+ . LINK
7
+ https://en.wikipedia.org/wiki/L-system#Example_7:_fractal_plant
8
+ . EXAMPLE
9
+ turtle FractalPlant save ./FractalPlant.svg
10
+ . EXAMPLE
11
+ turtle FractalPlant morph save ./FractalPlantMorph.svg
12
+ #>
1
13
param (
2
- [double ]$Size = 20 ,
14
+ # The size of each segment
15
+ [double ]$Size = 42 ,
16
+ # The order of magnitude (the number of times the L-system is expanded)
3
17
[int ]$Order = 4 ,
4
- [double ]$Angle = 25
18
+ # The angle of each segment
19
+ [double ]$Angle = -25
5
20
)
6
21
return $this.Rotate (-90 ).LSystem(' -X' , [Ordered ]@ {
7
22
' X' = ' F+[[X]-X]-F[-FX]+X'
8
- ' F' = ' FF'
23
+ ' F' = ' FF'
9
24
}, $Order , [Ordered ]@ {
10
- ' F' = { $this.Forward ($Size ) }
11
- ' \[' = { $this.Rotate ($Angle * -1 ).Push() }
12
- ' \]' = { $this.Pop ().Rotate($Angle ) }
13
- })
14
-
25
+ ' F' = { $this.Forward ($Size ) }
26
+ ' \+' = { $this.Rotate ($angle )}
27
+ ' \-' = { $this.Rotate ($angle * -1 )}
28
+ ' \[' = { $this.Push () }
29
+ ' \]' = { $this.Pop () }
30
+ })
You can’t perform that action at this time.
0 commit comments