Skip to content

Commit a081100

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: Turtle.Spirolateral ( Fixes #120 )
Tracking total turn instead of heading
1 parent 2ea3c9a commit a081100

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Turtle.types.ps1xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,23 +1398,27 @@ $LeftTurnSteps
13981398

13991399
$stepNumber = 1
14001400
$majorStepCount = 0
1401+
$totalTurn = 0
14011402
do {
14021403
$null = for ($stepNumber = 1; $stepNumber -le [Math]::Abs($StepCount); $stepNumber++) {
14031404
$null = $this.Forward($side * $stepNumber)
14041405
if ($LeftTurnSteps) {
14051406
if ($LeftTurnSteps -contains $stepNumber) {
1407+
$totalTurn -= $angle
14061408
$this.Left($angle)
14071409
} else {
1410+
$totalTurn += $angle
14081411
$this.Right($angle)
14091412
}
14101413
} else {
1414+
$totalTurn += $angle
14111415
$this.Right($angle)
14121416
}
14131417
}
14141418
$majorStepCount++
14151419
} until (
1416-
(-not ([Math]::Round($this.Heading, 5) % 360 )) -or
1417-
$majorStepCount -gt $StepCount
1420+
(-not ([Math]::Round($totalTurn, 5) % 360 )) -and
1421+
$majorStepCount -le [Math]::Abs($StepCount)
14181422
)
14191423

14201424
return $this

0 commit comments

Comments
 (0)