Skip to content

Commit 7c1141a

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: Turtle.Distance ( Fixes #99 )
1 parent 743227d commit 7c1141a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Turtle.types.ps1xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,30 @@ $this.ViewBox = 0
245245
return $this
246246
</Script>
247247
</ScriptMethod>
248+
<ScriptMethod>
249+
<Name>Distance</Name>
250+
<Script>
251+
&lt;#
252+
.SYNOPSIS
253+
Determines the distance to a point
254+
.DESCRIPTION
255+
Determines the distance from the turtle's current position to a point.
256+
#&gt;
257+
param(
258+
# The X-coordinate
259+
[double]$X = 0,
260+
# The Y-coordinate
261+
[double]$Y = 0
262+
)
263+
264+
# Determine the delta from the turtle's current position to the specified point
265+
$deltaX = $this.Position.X - $X
266+
$deltaY = $this.Position.Y - $Y
267+
# Calculate the distance using the Pythagorean theorem
268+
return [Math]::Sqrt($deltaX * $deltaX + $deltaY * $deltaY)
269+
270+
</Script>
271+
</ScriptMethod>
248272
<ScriptMethod>
249273
<Name>FillColor</Name>
250274
<Script>

0 commit comments

Comments
 (0)