Skip to content

Commit 1bf9f6c

Browse files
feat: Turtle.Petal ( Fixes #119 )
2 parents 9dc7d14 + 3ac0685 commit 1bf9f6c

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

Turtle.types.ps1xml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
</PropertySet>
1616
</Members>
1717
</MemberSet>
18+
<AliasProperty>
19+
<Name>ArcL</Name>
20+
<ReferencedMemberName>ArcLeft</ReferencedMemberName>
21+
</AliasProperty>
22+
<AliasProperty>
23+
<Name>ArcR</Name>
24+
<ReferencedMemberName>ArcRight</ReferencedMemberName>
25+
</AliasProperty>
1826
<AliasProperty>
1927
<Name>Back</Name>
2028
<ReferencedMemberName>Backward</ReferencedMemberName>
@@ -83,6 +91,74 @@
8391
<Name>yPos</Name>
8492
<ReferencedMemberName>ycor</ReferencedMemberName>
8593
</AliasProperty>
94+
<ScriptMethod>
95+
<Name>ArcLeft</Name>
96+
<Script>
97+
&lt;#
98+
.SYNOPSIS
99+
Arcs the turtle to the left
100+
.DESCRIPTION
101+
Arcs the turtle to the left (counter-clockwise) a number of degrees.
102+
103+
For each degree, the turtle will move forward and rotate.
104+
.NOTES
105+
The amount moved forward will be the portion of the circumference.
106+
#&gt;
107+
param(
108+
# The radius of a the circle, were it to complete the arc.
109+
[double]
110+
$Radius = 10,
111+
112+
# The angle of the arc
113+
[double]
114+
$Angle = 60
115+
)
116+
117+
# Rather than duplicate logic, we will simply reverse the angle
118+
$angle *= -1
119+
# and arc to the "right".
120+
return $this.ArcRight($Radius, $Angle)
121+
</Script>
122+
</ScriptMethod>
123+
<ScriptMethod>
124+
<Name>ArcRight</Name>
125+
<Script>
126+
&lt;#
127+
.SYNOPSIS
128+
Arcs the turtle to the right
129+
.DESCRIPTION
130+
Arcs the turtle to the right (clockwise) a number of degrees.
131+
132+
For each degree, the turtle will move forward and rotate.
133+
.NOTES
134+
The amount moved forward will be the portion of the circumference.
135+
#&gt;
136+
param(
137+
# The radius of a the circle, were it to complete the arc.
138+
[double]
139+
$Radius = 10,
140+
141+
# The angle of the arc
142+
[double]
143+
$Angle = 60
144+
)
145+
146+
147+
# Determine the absolute angle, for this
148+
$absAngle = [Math]::Abs($angle)
149+
$circumferenceStep = ([Math]::PI * 2 * $Radius) / $absAngle
150+
151+
$iteration = $angle / [Math]::Floor($absAngle)
152+
$angleDelta = 0
153+
$null = while ([Math]::Abs($angleDelta) -lt $absAngle) {
154+
$this.Forward($circumferenceStep)
155+
$this.Rotate($iteration)
156+
$angleDelta+=$iteration
157+
}
158+
159+
return $this
160+
</Script>
161+
</ScriptMethod>
86162
<ScriptMethod>
87163
<Name>Backward</Name>
88164
<Script>

0 commit comments

Comments
 (0)