@@ -346,11 +346,11 @@ param(
346
346
)
347
347
348
348
# Determine the delta from the turtle's current position to the specified point
349
- $deltaX = $this.Position.X - $X
350
- $deltaY = $this.Position.Y - $Y
351
- # Calculate the distance using the Pythagorean theorem
352
- return [Math]::Sqrt($deltaX * $deltaX + $deltaY * $deltaY)
349
+ $deltaX = $X - $this.Position.X
350
+ $deltaY = $Y - $this.Position.Y
353
351
352
+ # Calculate the distance using the Pythagorean theorem
353
+ return [Math]::Sqrt($deltaX*$deltaX + $deltaY*$deltaY)
354
354
</Script >
355
355
</ScriptMethod >
356
356
<ScriptMethod >
@@ -1526,7 +1526,7 @@ return "$($this.SVG.OuterXml)"
1526
1526
.SYNOPSIS
1527
1527
Determines the angle towards a point
1528
1528
.DESCRIPTION
1529
- Determines the angle from the turtle's current position towards a point.
1529
+ Determines the angle from the turtle's current heading towards a point.
1530
1530
#>
1531
1531
param(
1532
1532
# The X-coordinate
@@ -1536,12 +1536,12 @@ param(
1536
1536
)
1537
1537
1538
1538
# Determine the delta from the turtle's current position to the specified point
1539
- $deltaX = $this.Position. X - $X
1540
- $deltaY = $this.Position. Y - $Y
1539
+ $deltaX = $X - $this.Position.X
1540
+ $deltaY = $Y - $this.Position. Y
1541
1541
# Calculate the angle in radians and convert to degrees
1542
1542
$angle = [Math]::Atan2($deltaY, $deltaX) * 180 / [Math]::PI
1543
- # Return the angle rotate by 90 to account for the turtle's coordinate system
1544
- return $angle + 90
1543
+ # Return the angle minus the current heading (modulo 360)
1544
+ return $angle - ($this.Heading % 360)
1545
1545
1546
1546
</Script >
1547
1547
</ScriptMethod >
0 commit comments