File tree Expand file tree Collapse file tree 1 file changed +68
-0
lines changed Expand file tree Collapse file tree 1 file changed +68
-0
lines changed Original file line number Diff line number Diff line change @@ -1285,6 +1285,74 @@ return $this.LSystem('F-G-G', [Ordered]@{
1285
1285
1286
1286
</Script >
1287
1287
</ScriptMethod >
1288
+ <ScriptMethod >
1289
+ <Name >Spirolateral</Name >
1290
+ <Script >
1291
+ < #
1292
+ .SYNOPSIS
1293
+ Draws a spirolateral
1294
+ .DESCRIPTION
1295
+ Draws a spirolateral
1296
+ .LINK
1297
+ https://en.wikipedia.org/wiki/Spirolateral
1298
+ .EXAMPLE
1299
+ turtle spirolateral save ./Spirolateral.svg
1300
+ .EXAMPLE
1301
+ turtle spirolateral 50 144 8 save ./Spirolateral-144-8.svg
1302
+ .EXAMPLE
1303
+ turtle spirolateral 50 60 10 save ./Spirolateral-60-10.svg
1304
+ .EXAMPLE
1305
+ turtle spirolateral 50 120 6 @(1,3) save ./Spirolateral-120-6-1_3.svg
1306
+ .EXAMPLE
1307
+ turtle spirolateral 50 90 11 @(3,4,5) save ./Spirolateral-90-11-3_4_5.svg
1308
+ #>
1309
+ param(
1310
+ # The base length of each side (this will be multiplied by the step number)
1311
+ [double]
1312
+ $Side = 10,
1313
+
1314
+ # The angle of the turn
1315
+ [double]
1316
+ $Angle = 90,
1317
+
1318
+ # The step count.
1319
+ # This is the number of times the steps will be repeated.
1320
+ # This is also the maximum number of iterations the shape will complete.
1321
+ [int]
1322
+ $StepCount = 10,
1323
+
1324
+ # The step numbers that are left turns (counter-clockwise).
1325
+ # This allows the creation of general spirolaterals
1326
+ [Parameter(ValueFromRemainingArguments)]
1327
+ [int[]]
1328
+ $LeftTurnSteps
1329
+ )
1330
+
1331
+ $stepNumber = 1
1332
+ $majorStepCount = 0
1333
+ do {
1334
+ $null = for ($stepNumber = 1; $stepNumber -le [Math]::Abs($StepCount); $stepNumber++) {
1335
+ $null = $this.Forward($side * $stepNumber)
1336
+ if ($LeftTurnSteps) {
1337
+ if ($LeftTurnSteps -contains $stepNumber) {
1338
+ $this.Left($angle)
1339
+ } else {
1340
+ $this.Right($angle)
1341
+ }
1342
+ } else {
1343
+ $this.Right($angle)
1344
+ }
1345
+ }
1346
+ $majorStepCount++
1347
+ } until (
1348
+ (-not ([Math]::Round($this.Heading, 5) % 360 )) -or
1349
+ $majorStepCount -gt $StepCount
1350
+ )
1351
+
1352
+ return $this
1353
+
1354
+ </Script >
1355
+ </ScriptMethod >
1288
1356
<ScriptMethod >
1289
1357
<Name >Square</Name >
1290
1358
<Script >
You can’t perform that action at this time.
0 commit comments