MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / heading

Method heading

Python/Turtle.py:1794–1807  ·  view source on GitHub ↗

Return the turtle's current heading. No arguments. Example (for a Turtle instance named turtle): >>> turtle.left(67) >>> turtle.heading() 67.0

(self)

Source from the content-addressed store, hash-verified

1792 return (self._angleOffset + self._angleOrient*result) % self._fullcircle
1793
1794 def heading(self):
1795 """ Return the turtle's current heading.
1796
1797 No arguments.
1798
1799 Example (for a Turtle instance named turtle):
1800 >>> turtle.left(67)
1801 >>> turtle.heading()
1802 67.0
1803 """
1804 x, y = self._orient
1805 result = round(math.atan2(y, x)*180.0/math.pi, 10) % 360.0
1806 result /= self._degreesPerAU
1807 return (self._angleOffset + self._angleOrient*result) % self._fullcircle
1808
1809 def setheading(self, to_angle):
1810 """Set the orientation of the turtle to to_angle.

Callers 1

setheadingMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected