Skip to content

Commit bfe8e8b

Browse files
StartAutomatingStartAutomating
authored andcommitted
feat: Turtle.Towards ( Fixes #98 )
1 parent 5331444 commit bfe8e8b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Turtle.types.ps1xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,32 @@ return $this.LSystem('F', [Ordered]@{
11891189
return "$($this.SVG.OuterXml)"
11901190
</Script>
11911191
</ScriptMethod>
1192+
<ScriptMethod>
1193+
<Name>Towards</Name>
1194+
<Script>
1195+
&lt;#
1196+
.SYNOPSIS
1197+
Determines the angle towards a point
1198+
.DESCRIPTION
1199+
Determines the angle from the turtle's current position towards a point.
1200+
#&gt;
1201+
param(
1202+
# The X-coordinate
1203+
[double]$X = 0,
1204+
# The Y-coordinate
1205+
[double]$Y = 0
1206+
)
1207+
1208+
# Determine the delta from the turtle's current position to the specified point
1209+
$deltaX = $this.Position.X - $X
1210+
$deltaY = $this.Position.Y - $Y
1211+
# Calculate the angle in radians and convert to degrees
1212+
$angle = [Math]::Atan2($deltaY, $deltaX) * 180 / [Math]::PI
1213+
# Return the angle rotate by 90 to account for the turtle's coordinate system
1214+
return $angle + 90
1215+
1216+
</Script>
1217+
</ScriptMethod>
11921218
<ScriptMethod>
11931219
<Name>TwinDragonCurve</Name>
11941220
<Script>

0 commit comments

Comments
 (0)