File tree Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Original file line number Diff line number Diff line change
1
+ <#
2
+ . SYNOPSIS
3
+ Draws a spirolateral
4
+ . DESCRIPTION
5
+ Draws a spirolateral
6
+ . LINK
7
+ https://en.wikipedia.org/wiki/Spirolateral
8
+ . EXAMPLE
9
+ turtle spirolateral save ./Spirolateral.svg
10
+ . EXAMPLE
11
+ turtle spirolateral 50 144 8 save ./Spirolateral-144-8.svg
12
+ . EXAMPLE
13
+ turtle spirolateral 50 60 10 save ./Spirolateral-60-10.svg
14
+ . EXAMPLE
15
+ turtle spirolateral 50 120 6 @(1,3) save ./Spirolateral-120-6-1_3.svg
16
+ . EXAMPLE
17
+ turtle spirolateral 50 90 11 @(3,4,5) save ./Spirolateral-90-11-3_4_5.svg
18
+ #>
19
+ param (
20
+ # The base length of each side (this will be multiplied by the step number)
21
+ [double ]
22
+ $Side = 10 ,
23
+
24
+ # The angle of the turn
25
+ [double ]
26
+ $Angle = 90 ,
27
+
28
+ # The step count.
29
+ # This is the number of times the steps will be repeated.
30
+ # This is also the maximum number of iterations the shape will complete.
31
+ [int ]
32
+ $StepCount = 10 ,
33
+
34
+ # The step numbers that are left turns (counter-clockwise).
35
+ # This allows the creation of general spirolaterals
36
+ [Parameter (ValueFromRemainingArguments )]
37
+ [int []]
38
+ $LeftTurnSteps
39
+ )
40
+
41
+ $stepNumber = 1
42
+ $majorStepCount = 0
43
+ do {
44
+ $null = for ($stepNumber = 1 ; $stepNumber -le [Math ]::Abs($StepCount ); $stepNumber ++ ) {
45
+ $null = $this.Forward ($side * $stepNumber )
46
+ if ($LeftTurnSteps ) {
47
+ if ($LeftTurnSteps -contains $stepNumber ) {
48
+ $this.Left ($angle )
49
+ } else {
50
+ $this.Right ($angle )
51
+ }
52
+ } else {
53
+ $this.Right ($angle )
54
+ }
55
+ }
56
+ $majorStepCount ++
57
+ } until (
58
+ (-not ([Math ]::Round($this.Heading , 5 ) % 360 )) -or
59
+ $majorStepCount -gt $StepCount
60
+ )
61
+
62
+ return $this
You can’t perform that action at this time.
0 commit comments