Skip to content

Commit 575bf39

Browse files
feat: Turtle.get/set_Precision ( Fixes #225 )
Adjusting defaults and rounding later
1 parent e47b95c commit 575bf39

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

Types/Turtle/Forward.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ $Distance = 10
1414

1515
$precision = if ($this.Precision -ge 0) { $this.Precision } else { 4 }
1616

17-
$x = $Distance * ([Math]::Round([math]::cos($this.Heading * [Math]::PI / 180), $precision))
18-
$y = $Distance * ([Math]::Round([math]::sin($this.Heading * [Math]::PI / 180), $precision))
17+
$x = [Math]::Round(
18+
$Distance * [math]::cos($this.Heading * [Math]::PI / 180),
19+
$precision
20+
)
21+
$y = [Math]::Round(
22+
$Distance * [math]::sin($this.Heading * [Math]::PI / 180),
23+
$precision
24+
)
25+
1926

2027
return $this.Step($x, $y)

Types/Turtle/get_Precision.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
1111
They will have difficulty rendering stepwise animations and take up more file space per point.
1212
13-
The default value for `Precision` is currently `4`
13+
The default value for `Precision` is currently `6`
1414
#>
1515
if (-not $this.'.Precision') {
16-
$this | Add-Member NoteProperty '.Precision' 4 -Force
16+
$this | Add-Member NoteProperty '.Precision' 6 -Force
1717
}
1818
return $this.'.Precision'

Types/Turtle/set_Precision.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ param(
1414
# The number of decimal places used in rounding.
1515
[ValidateRange(1,28)]
1616
[int]
17-
$Precision = 4
17+
$Precision = 6
1818
)
1919

2020
$this | Add-Member NoteProperty '.Precision' $Precision -Force

0 commit comments

Comments
 (0)