We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Turtle.Distance
1 parent bfe8e8b commit 743227dCopy full SHA for 743227d
Types/Turtle/Distance.ps1
@@ -0,0 +1,18 @@
1
+<#
2
+.SYNOPSIS
3
+ Determines the distance to a point
4
+.DESCRIPTION
5
+ Determines the distance from the turtle's current position to a point.
6
+#>
7
+param(
8
+# The X-coordinate
9
+[double]$X = 0,
10
+# The Y-coordinate
11
+[double]$Y = 0
12
+)
13
+
14
+# Determine the delta from the turtle's current position to the specified point
15
+$deltaX = $this.Position.X - $X
16
+$deltaY = $this.Position.Y - $Y
17
+# Calculate the distance using the Pythagorean theorem
18
+return [Math]::Sqrt($deltaX * $deltaX + $deltaY * $deltaY)
0 commit comments