Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes
turtle.TNavigator Class Reference
Inheritance diagram for turtle.TNavigator:
Inheritance graph
[legend]
Collaboration diagram for turtle.TNavigator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def reset
def degrees
def radians
def forward
def back
def right
def left
def pos
def xcor
def ycor
def goto
def home
def setx
def sety
def distance
def towards
def heading
def setheading
def circle

Public Attributes

 undobuffer
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Static Public Attributes

dictionary START_ORIENTATION
string DEFAULT_MODE = "standard"
int DEFAULT_ANGLEOFFSET = 0
int DEFAULT_ANGLEORIENT = 1

Private Member Functions

def _setmode
def _setDegreesPerAU
def _go
def _rotate
def _goto

Private Attributes

 _angleOffset
 _angleOrient
 _mode
 _position
 _orient
 _fullcircle
 _degreesPerAU

Detailed Description

Navigation part of the RawTurtle.
Implements methods for turtle movement.

Definition at line 1510 of file turtle.py.


Constructor & Destructor Documentation

def turtle.TNavigator.__init__ (   self,
  mode = DEFAULT_MODE 
)

Reimplemented in turtledemo.minimal_hanoi.Disc.

Definition at line 1522 of file turtle.py.

01522 
01523     def __init__(self, mode=DEFAULT_MODE):
01524         self._angleOffset = self.DEFAULT_ANGLEOFFSET
01525         self._angleOrient = self.DEFAULT_ANGLEORIENT
01526         self._mode = mode
01527         self.undobuffer = None
01528         self.degrees()
01529         self._mode = None
01530         self._setmode(mode)
01531         TNavigator.reset(self)

Here is the caller graph for this function:


Member Function Documentation

def turtle.TNavigator._go (   self,
  distance 
) [private]
move turtle forward by specified distance

Definition at line 1602 of file turtle.py.

01602 
01603     def _go(self, distance):
01604         """move turtle forward by specified distance"""
01605         ende = self._position + self._orient * distance
01606         self._goto(ende)

Here is the call graph for this function:

def turtle.TNavigator._goto (   self,
  end 
) [private]
move turtle to position end.

Reimplemented in turtle.RawTurtle.

Definition at line 1612 of file turtle.py.

01612 
01613     def _goto(self, end):
01614         """move turtle to position end."""
01615         self._position = end

Here is the caller graph for this function:

def turtle.TNavigator._rotate (   self,
  angle 
) [private]
Turn turtle counterclockwise by specified angle if angle > 0.

Reimplemented in turtle.RawTurtle.

Definition at line 1607 of file turtle.py.

01607 
01608     def _rotate(self, angle):
01609         """Turn turtle counterclockwise by specified angle if angle > 0."""
01610         angle *= self._degreesPerAU
01611         self._orient = self._orient.rotate(angle)

Here is the caller graph for this function:

def turtle.TNavigator._setDegreesPerAU (   self,
  fullcircle 
) [private]
Helper function for degrees() and radians()

Definition at line 1555 of file turtle.py.

01555 
01556     def _setDegreesPerAU(self, fullcircle):
01557         """Helper function for degrees() and radians()"""
01558         self._fullcircle = fullcircle
01559         self._degreesPerAU = 360/fullcircle
01560         if self._mode == "standard":
01561             self._angleOffset = 0
01562         else:
01563             self._angleOffset = fullcircle/4.

Here is the call graph for this function:

def turtle.TNavigator._setmode (   self,
  mode = None 
) [private]
Set turtle-mode to 'standard', 'world' or 'logo'.

Definition at line 1540 of file turtle.py.

01540 
01541     def _setmode(self, mode=None):
01542         """Set turtle-mode to 'standard', 'world' or 'logo'.
01543         """
01544         if mode is None:
01545             return self._mode
01546         if mode not in ["standard", "logo", "world"]:
01547             return
01548         self._mode = mode
01549         if mode in ["standard", "world"]:
01550             self._angleOffset = 0
01551             self._angleOrient = 1
01552         else: # mode == "logo":
01553             self._angleOffset = self._fullcircle/4.
01554             self._angleOrient = -1

def turtle.TNavigator.back (   self,
  distance 
)
Move the turtle backward by distance.

Aliases: back | backward | bk

Argument:
distance -- a number

Move the turtle backward by distance ,opposite to the direction the
turtle is headed. Do not change the turtle's heading.

Example (for a Turtle instance named turtle):
>>> turtle.position()
(0.00, 0.00)
>>> turtle.backward(30)
>>> turtle.position()
(-30.00, 0.00)

Definition at line 1639 of file turtle.py.

01639 
01640     def back(self, distance):
01641         """Move the turtle backward by distance.
01642 
01643         Aliases: back | backward | bk
01644 
01645         Argument:
01646         distance -- a number
01647 
01648         Move the turtle backward by distance ,opposite to the direction the
01649         turtle is headed. Do not change the turtle's heading.
01650 
01651         Example (for a Turtle instance named turtle):
01652         >>> turtle.position()
01653         (0.00, 0.00)
01654         >>> turtle.backward(30)
01655         >>> turtle.position()
01656         (-30.00, 0.00)
01657         """
01658         self._go(-distance)

Here is the call graph for this function:

def turtle.TNavigator.circle (   self,
  radius,
  extent = None,
  steps = None 
)
Draw a circle with given radius.

Arguments:
radius -- a number
extent (optional) -- a number
steps (optional) -- an integer

Draw a circle with given radius. The center is radius units left
of the turtle; extent - an angle - determines which part of the
circle is drawn. If extent is not given, draw the entire circle.
If extent is not a full circle, one endpoint of the arc is the
current pen position. Draw the arc in counterclockwise direction
if radius is positive, otherwise in clockwise direction. Finally
the direction of the turtle is changed by the amount of extent.

As the circle is approximated by an inscribed regular polygon,
steps determines the number of steps to use. If not given,
it will be calculated automatically. Maybe used to draw regular
polygons.

call: circle(radius)                  # full circle
--or: circle(radius, extent)          # arc
--or: circle(radius, extent, steps)
--or: circle(radius, steps=6)         # 6-sided polygon

Example (for a Turtle instance named turtle):
>>> turtle.circle(50)
>>> turtle.circle(120, 180)  # semicircle

Definition at line 1938 of file turtle.py.

01938 
01939     def circle(self, radius, extent = None, steps = None):
01940         """ Draw a circle with given radius.
01941 
01942         Arguments:
01943         radius -- a number
01944         extent (optional) -- a number
01945         steps (optional) -- an integer
01946 
01947         Draw a circle with given radius. The center is radius units left
01948         of the turtle; extent - an angle - determines which part of the
01949         circle is drawn. If extent is not given, draw the entire circle.
01950         If extent is not a full circle, one endpoint of the arc is the
01951         current pen position. Draw the arc in counterclockwise direction
01952         if radius is positive, otherwise in clockwise direction. Finally
01953         the direction of the turtle is changed by the amount of extent.
01954 
01955         As the circle is approximated by an inscribed regular polygon,
01956         steps determines the number of steps to use. If not given,
01957         it will be calculated automatically. Maybe used to draw regular
01958         polygons.
01959 
01960         call: circle(radius)                  # full circle
01961         --or: circle(radius, extent)          # arc
01962         --or: circle(radius, extent, steps)
01963         --or: circle(radius, steps=6)         # 6-sided polygon
01964 
01965         Example (for a Turtle instance named turtle):
01966         >>> turtle.circle(50)
01967         >>> turtle.circle(120, 180)  # semicircle
01968         """
01969         if self.undobuffer:
01970             self.undobuffer.push(["seq"])
01971             self.undobuffer.cumulate = True
01972         speed = self.speed()
01973         if extent is None:
01974             extent = self._fullcircle
01975         if steps is None:
01976             frac = abs(extent)/self._fullcircle
01977             steps = 1+int(min(11+abs(radius)/6.0, 59.0)*frac)
01978         w = 1.0 * extent / steps
01979         w2 = 0.5 * w
01980         l = 2.0 * radius * math.sin(w2*math.pi/180.0*self._degreesPerAU)
01981         if radius < 0:
01982             l, w, w2 = -l, -w, -w2
01983         tr = self._tracer()
01984         dl = self._delay()
01985         if speed == 0:
01986             self._tracer(0, 0)
01987         else:
01988             self.speed(0)
01989         self._rotate(w2)
01990         for i in range(steps):
01991             self.speed(speed)
01992             self._go(l)
01993             self.speed(0)
01994             self._rotate(w)
01995         self._rotate(-w2)
01996         if speed == 0:
01997             self._tracer(tr, dl)
01998         self.speed(speed)
01999         if self.undobuffer:
02000             self.undobuffer.cumulate = False

Here is the call graph for this function:

def turtle.TNavigator.degrees (   self,
  fullcircle = 360.0 
)
Set angle measurement units to degrees.

Optional argument:
fullcircle -  a number

Set angle measurement units, i. e. set number
of 'degrees' for a full circle. Dafault value is
360 degrees.

Example (for a Turtle instance named turtle):
>>> turtle.left(90)
>>> turtle.heading()
90

Change angle measurement unit to grad (also known as gon,
grade, or gradian and equals 1/100-th of the right angle.)
>>> turtle.degrees(400.0)
>>> turtle.heading()
100

Definition at line 1564 of file turtle.py.

01564 
01565     def degrees(self, fullcircle=360.0):
01566         """ Set angle measurement units to degrees.
01567 
01568         Optional argument:
01569         fullcircle -  a number
01570 
01571         Set angle measurement units, i. e. set number
01572         of 'degrees' for a full circle. Dafault value is
01573         360 degrees.
01574 
01575         Example (for a Turtle instance named turtle):
01576         >>> turtle.left(90)
01577         >>> turtle.heading()
01578         90
01579 
01580         Change angle measurement unit to grad (also known as gon,
01581         grade, or gradian and equals 1/100-th of the right angle.)
01582         >>> turtle.degrees(400.0)
01583         >>> turtle.heading()
01584         100
01585 
01586         """
01587         self._setDegreesPerAU(fullcircle)

Here is the call graph for this function:

Here is the caller graph for this function:

def turtle.TNavigator.distance (   self,
  x,
  y = None 
)
Return the distance from the turtle to (x,y) in turtle step units.

Arguments:
x -- a number   or  a pair/vector of numbers   or   a turtle instance
y -- a number       None                            None

call: distance(x, y)         # two coordinates
--or: distance((x, y))       # a pair (tuple) of coordinates
--or: distance(vec)          # e.g. as returned by pos()
--or: distance(mypen)        # where mypen is another turtle

Example (for a Turtle instance named turtle):
>>> turtle.pos()
(0.00, 0.00)
>>> turtle.distance(30,40)
50.0
>>> pen = Turtle()
>>> pen.forward(77)
>>> turtle.distance(pen)
77.0

Definition at line 1828 of file turtle.py.

01828 
01829     def distance(self, x, y=None):
01830         """Return the distance from the turtle to (x,y) in turtle step units.
01831 
01832         Arguments:
01833         x -- a number   or  a pair/vector of numbers   or   a turtle instance
01834         y -- a number       None                            None
01835 
01836         call: distance(x, y)         # two coordinates
01837         --or: distance((x, y))       # a pair (tuple) of coordinates
01838         --or: distance(vec)          # e.g. as returned by pos()
01839         --or: distance(mypen)        # where mypen is another turtle
01840 
01841         Example (for a Turtle instance named turtle):
01842         >>> turtle.pos()
01843         (0.00, 0.00)
01844         >>> turtle.distance(30,40)
01845         50.0
01846         >>> pen = Turtle()
01847         >>> pen.forward(77)
01848         >>> turtle.distance(pen)
01849         77.0
01850         """
01851         if y is not None:
01852             pos = Vec2D(x, y)
01853         if isinstance(x, Vec2D):
01854             pos = x
01855         elif isinstance(x, tuple):
01856             pos = Vec2D(*x)
01857         elif isinstance(x, TNavigator):
01858             pos = x._position
01859         return abs(pos - self._position)

Here is the caller graph for this function:

def turtle.TNavigator.forward (   self,
  distance 
)
Move the turtle forward by the specified distance.

Aliases: forward | fd

Argument:
distance -- a number (integer or float)

Move the turtle forward by the specified distance, in the direction
the turtle is headed.

Example (for a Turtle instance named turtle):
>>> turtle.position()
(0.00, 0.00)
>>> turtle.forward(25)
>>> turtle.position()
(25.00,0.00)
>>> turtle.forward(-75)
>>> turtle.position()
(-50.00,0.00)

Definition at line 1616 of file turtle.py.

01616 
01617     def forward(self, distance):
01618         """Move the turtle forward by the specified distance.
01619 
01620         Aliases: forward | fd
01621 
01622         Argument:
01623         distance -- a number (integer or float)
01624 
01625         Move the turtle forward by the specified distance, in the direction
01626         the turtle is headed.
01627 
01628         Example (for a Turtle instance named turtle):
01629         >>> turtle.position()
01630         (0.00, 0.00)
01631         >>> turtle.forward(25)
01632         >>> turtle.position()
01633         (25.00,0.00)
01634         >>> turtle.forward(-75)
01635         >>> turtle.position()
01636         (-50.00,0.00)
01637         """
01638         self._go(distance)

Here is the call graph for this function:

Here is the caller graph for this function:

def turtle.TNavigator.goto (   self,
  x,
  y = None 
)
Move turtle to an absolute position.

Aliases: setpos | setposition | goto:

Arguments:
x -- a number      or     a pair/vector of numbers
y -- a number             None

call: goto(x, y)         # two coordinates
--or: goto((x, y))       # a pair (tuple) of coordinates
--or: goto(vec)          # e.g. as returned by pos()

Move turtle to an absolute position. If the pen is down,
a line will be drawn. The turtle's orientation does not change.

Example (for a Turtle instance named turtle):
>>> tp = turtle.pos()
>>> tp
(0.00, 0.00)
>>> turtle.setpos(60,30)
>>> turtle.pos()
(60.00,30.00)
>>> turtle.setpos((20,80))
>>> turtle.pos()
(20.00,80.00)
>>> turtle.setpos(tp)
>>> turtle.pos()
(0.00,0.00)

Definition at line 1743 of file turtle.py.

01743 
01744     def goto(self, x, y=None):
01745         """Move turtle to an absolute position.
01746 
01747         Aliases: setpos | setposition | goto:
01748 
01749         Arguments:
01750         x -- a number      or     a pair/vector of numbers
01751         y -- a number             None
01752 
01753         call: goto(x, y)         # two coordinates
01754         --or: goto((x, y))       # a pair (tuple) of coordinates
01755         --or: goto(vec)          # e.g. as returned by pos()
01756 
01757         Move turtle to an absolute position. If the pen is down,
01758         a line will be drawn. The turtle's orientation does not change.
01759 
01760         Example (for a Turtle instance named turtle):
01761         >>> tp = turtle.pos()
01762         >>> tp
01763         (0.00, 0.00)
01764         >>> turtle.setpos(60,30)
01765         >>> turtle.pos()
01766         (60.00,30.00)
01767         >>> turtle.setpos((20,80))
01768         >>> turtle.pos()
01769         (20.00,80.00)
01770         >>> turtle.setpos(tp)
01771         >>> turtle.pos()
01772         (0.00,0.00)
01773         """
01774         if y is None:
01775             self._goto(Vec2D(*x))
01776         else:
01777             self._goto(Vec2D(x, y))

Here is the call graph for this function:

Here is the caller graph for this function:

def turtle.TNavigator.heading (   self)
Return the turtle's current heading.

No arguments.

Example (for a Turtle instance named turtle):
>>> turtle.left(67)
>>> turtle.heading()
67.0

Definition at line 1895 of file turtle.py.

01895 
01896     def heading(self):
01897         """ Return the turtle's current heading.
01898 
01899         No arguments.
01900 
01901         Example (for a Turtle instance named turtle):
01902         >>> turtle.left(67)
01903         >>> turtle.heading()
01904         67.0
01905         """
01906         x, y = self._orient
01907         result = round(math.atan2(y, x)*180.0/math.pi, 10) % 360.0
01908         result /= self._degreesPerAU
01909         return (self._angleOffset + self._angleOrient*result) % self._fullcircle

Here is the call graph for this function:

Here is the caller graph for this function:

def turtle.TNavigator.home (   self)
Move turtle to the origin - coordinates (0,0).

No arguments.

Move turtle to the origin - coordinates (0,0) and set its
heading to its start-orientation (which depends on mode).

Example (for a Turtle instance named turtle):
>>> turtle.home()

Definition at line 1778 of file turtle.py.

01778 
01779     def home(self):
01780         """Move turtle to the origin - coordinates (0,0).
01781 
01782         No arguments.
01783 
01784         Move turtle to the origin - coordinates (0,0) and set its
01785         heading to its start-orientation (which depends on mode).
01786 
01787         Example (for a Turtle instance named turtle):
01788         >>> turtle.home()
01789         """
01790         self.goto(0, 0)
01791         self.setheading(0)

Here is the call graph for this function:

def turtle.TNavigator.left (   self,
  angle 
)
Turn turtle left by angle units.

Aliases: left | lt

Argument:
angle -- a number (integer or float)

Turn turtle left by angle units. (Units are by default degrees,
but can be set via the degrees() and radians() functions.)
Angle orientation depends on mode. (See this.)

Example (for a Turtle instance named turtle):
>>> turtle.heading()
22.0
>>> turtle.left(45)
>>> turtle.heading()
67.0

Definition at line 1680 of file turtle.py.

01680 
01681     def left(self, angle):
01682         """Turn turtle left by angle units.
01683 
01684         Aliases: left | lt
01685 
01686         Argument:
01687         angle -- a number (integer or float)
01688 
01689         Turn turtle left by angle units. (Units are by default degrees,
01690         but can be set via the degrees() and radians() functions.)
01691         Angle orientation depends on mode. (See this.)
01692 
01693         Example (for a Turtle instance named turtle):
01694         >>> turtle.heading()
01695         22.0
01696         >>> turtle.left(45)
01697         >>> turtle.heading()
01698         67.0
01699         """
01700         self._rotate(angle)

Here is the call graph for this function:

Here is the caller graph for this function:

def turtle.TNavigator.pos (   self)
Return the turtle's current location (x,y), as a Vec2D-vector.

Aliases: pos | position

No arguments.

Example (for a Turtle instance named turtle):
>>> turtle.pos()
(0.00, 240.00)

Definition at line 1701 of file turtle.py.

01701 
01702     def pos(self):
01703         """Return the turtle's current location (x,y), as a Vec2D-vector.
01704 
01705         Aliases: pos | position
01706 
01707         No arguments.
01708 
01709         Example (for a Turtle instance named turtle):
01710         >>> turtle.pos()
01711         (0.00, 240.00)
01712         """
01713         return self._position

Here is the caller graph for this function:

def turtle.TNavigator.radians (   self)
Set the angle measurement units to radians.

No arguments.

Example (for a Turtle instance named turtle):
>>> turtle.heading()
90
>>> turtle.radians()
>>> turtle.heading()
1.5707963267948966

Definition at line 1588 of file turtle.py.

01588 
01589     def radians(self):
01590         """ Set the angle measurement units to radians.
01591 
01592         No arguments.
01593 
01594         Example (for a Turtle instance named turtle):
01595         >>> turtle.heading()
01596         90
01597         >>> turtle.radians()
01598         >>> turtle.heading()
01599         1.5707963267948966
01600         """
01601         self._setDegreesPerAU(2*math.pi)

Here is the call graph for this function:

Here is the caller graph for this function:

def turtle.TNavigator.reset (   self)
reset turtle to its initial values

Will be overwritten by parent class

Reimplemented in turtle.RawTurtle.

Definition at line 1532 of file turtle.py.

01532 
01533     def reset(self):
01534         """reset turtle to its initial values
01535 
01536         Will be overwritten by parent class
01537         """
01538         self._position = Vec2D(0.0, 0.0)
01539         self._orient =  TNavigator.START_ORIENTATION[self._mode]

Here is the caller graph for this function:

def turtle.TNavigator.right (   self,
  angle 
)
Turn turtle right by angle units.

Aliases: right | rt

Argument:
angle -- a number (integer or float)

Turn turtle right by angle units. (Units are by default degrees,
but can be set via the degrees() and radians() functions.)
Angle orientation depends on mode. (See this.)

Example (for a Turtle instance named turtle):
>>> turtle.heading()
22.0
>>> turtle.right(45)
>>> turtle.heading()
337.0

Definition at line 1659 of file turtle.py.

01659 
01660     def right(self, angle):
01661         """Turn turtle right by angle units.
01662 
01663         Aliases: right | rt
01664 
01665         Argument:
01666         angle -- a number (integer or float)
01667 
01668         Turn turtle right by angle units. (Units are by default degrees,
01669         but can be set via the degrees() and radians() functions.)
01670         Angle orientation depends on mode. (See this.)
01671 
01672         Example (for a Turtle instance named turtle):
01673         >>> turtle.heading()
01674         22.0
01675         >>> turtle.right(45)
01676         >>> turtle.heading()
01677         337.0
01678         """
01679         self._rotate(-angle)

Here is the call graph for this function:

Here is the caller graph for this function:

def turtle.TNavigator.setheading (   self,
  to_angle 
)
Set the orientation of the turtle to to_angle.

Aliases:  setheading | seth

Argument:
to_angle -- a number (integer or float)

Set the orientation of the turtle to to_angle.
Here are some common directions in degrees:

 standard - mode:          logo-mode:
-------------------|--------------------
   0 - east                0 - north
  90 - north              90 - east
 180 - west              180 - south
 270 - south             270 - west

Example (for a Turtle instance named turtle):
>>> turtle.setheading(90)
>>> turtle.heading()
90

Definition at line 1910 of file turtle.py.

01910 
01911     def setheading(self, to_angle):
01912         """Set the orientation of the turtle to to_angle.
01913 
01914         Aliases:  setheading | seth
01915 
01916         Argument:
01917         to_angle -- a number (integer or float)
01918 
01919         Set the orientation of the turtle to to_angle.
01920         Here are some common directions in degrees:
01921 
01922          standard - mode:          logo-mode:
01923         -------------------|--------------------
01924            0 - east                0 - north
01925           90 - north              90 - east
01926          180 - west              180 - south
01927          270 - south             270 - west
01928 
01929         Example (for a Turtle instance named turtle):
01930         >>> turtle.setheading(90)
01931         >>> turtle.heading()
01932         90
01933         """
01934         angle = (to_angle - self.heading())*self._angleOrient
01935         full = self._fullcircle
01936         angle = (angle+full/2.)%full - full/2.
01937         self._rotate(angle)

Here is the call graph for this function:

Here is the caller graph for this function:

def turtle.TNavigator.setx (   self,
  x 
)
Set the turtle's first coordinate to x

Argument:
x -- a number (integer or float)

Set the turtle's first coordinate to x, leave second coordinate
unchanged.

Example (for a Turtle instance named turtle):
>>> turtle.position()
(0.00, 240.00)
>>> turtle.setx(10)
>>> turtle.position()
(10.00, 240.00)

Definition at line 1792 of file turtle.py.

01792 
01793     def setx(self, x):
01794         """Set the turtle's first coordinate to x
01795 
01796         Argument:
01797         x -- a number (integer or float)
01798 
01799         Set the turtle's first coordinate to x, leave second coordinate
01800         unchanged.
01801 
01802         Example (for a Turtle instance named turtle):
01803         >>> turtle.position()
01804         (0.00, 240.00)
01805         >>> turtle.setx(10)
01806         >>> turtle.position()
01807         (10.00, 240.00)
01808         """
01809         self._goto(Vec2D(x, self._position[1]))

Here is the call graph for this function:

def turtle.TNavigator.sety (   self,
  y 
)
Set the turtle's second coordinate to y

Argument:
y -- a number (integer or float)

Set the turtle's first coordinate to x, second coordinate remains
unchanged.

Example (for a Turtle instance named turtle):
>>> turtle.position()
(0.00, 40.00)
>>> turtle.sety(-10)
>>> turtle.position()
(0.00, -10.00)

Definition at line 1810 of file turtle.py.

01810 
01811     def sety(self, y):
01812         """Set the turtle's second coordinate to y
01813 
01814         Argument:
01815         y -- a number (integer or float)
01816 
01817         Set the turtle's first coordinate to x, second coordinate remains
01818         unchanged.
01819 
01820         Example (for a Turtle instance named turtle):
01821         >>> turtle.position()
01822         (0.00, 40.00)
01823         >>> turtle.sety(-10)
01824         >>> turtle.position()
01825         (0.00, -10.00)
01826         """
01827         self._goto(Vec2D(self._position[0], y))

Here is the call graph for this function:

Here is the caller graph for this function:

def turtle.TNavigator.towards (   self,
  x,
  y = None 
)
Return the angle of the line from the turtle's position to (x, y).

Arguments:
x -- a number   or  a pair/vector of numbers   or   a turtle instance
y -- a number       None                            None

call: distance(x, y)         # two coordinates
--or: distance((x, y))       # a pair (tuple) of coordinates
--or: distance(vec)          # e.g. as returned by pos()
--or: distance(mypen)        # where mypen is another turtle

Return the angle, between the line from turtle-position to position
specified by x, y and the turtle's start orientation. (Depends on
modes - "standard" or "logo")

Example (for a Turtle instance named turtle):
>>> turtle.pos()
(10.00, 10.00)
>>> turtle.towards(0,0)
225.0

Definition at line 1860 of file turtle.py.

01860 
01861     def towards(self, x, y=None):
01862         """Return the angle of the line from the turtle's position to (x, y).
01863 
01864         Arguments:
01865         x -- a number   or  a pair/vector of numbers   or   a turtle instance
01866         y -- a number       None                            None
01867 
01868         call: distance(x, y)         # two coordinates
01869         --or: distance((x, y))       # a pair (tuple) of coordinates
01870         --or: distance(vec)          # e.g. as returned by pos()
01871         --or: distance(mypen)        # where mypen is another turtle
01872 
01873         Return the angle, between the line from turtle-position to position
01874         specified by x, y and the turtle's start orientation. (Depends on
01875         modes - "standard" or "logo")
01876 
01877         Example (for a Turtle instance named turtle):
01878         >>> turtle.pos()
01879         (10.00, 10.00)
01880         >>> turtle.towards(0,0)
01881         225.0
01882         """
01883         if y is not None:
01884             pos = Vec2D(x, y)
01885         if isinstance(x, Vec2D):
01886             pos = x
01887         elif isinstance(x, tuple):
01888             pos = Vec2D(*x)
01889         elif isinstance(x, TNavigator):
01890             pos = x._position
01891         x, y = pos - self._position
01892         result = round(math.atan2(y, x)*180.0/math.pi, 10) % 360.0
01893         result /= self._degreesPerAU
01894         return (self._angleOffset + self._angleOrient*result) % self._fullcircle

Here is the call graph for this function:

Here is the caller graph for this function:

def turtle.TNavigator.xcor (   self)
Return the turtle's x coordinate.

No arguments.

Example (for a Turtle instance named turtle):
>>> reset()
>>> turtle.left(60)
>>> turtle.forward(100)
>>> print turtle.xcor()
50.0

Definition at line 1714 of file turtle.py.

01714 
01715     def xcor(self):
01716         """ Return the turtle's x coordinate.
01717 
01718         No arguments.
01719 
01720         Example (for a Turtle instance named turtle):
01721         >>> reset()
01722         >>> turtle.left(60)
01723         >>> turtle.forward(100)
01724         >>> print turtle.xcor()
01725         50.0
01726         """
01727         return self._position[0]

Here is the call graph for this function:

def turtle.TNavigator.ycor (   self)
Return the turtle's y coordinate
---
No arguments.

Example (for a Turtle instance named turtle):
>>> reset()
>>> turtle.left(60)
>>> turtle.forward(100)
>>> print turtle.ycor()
86.6025403784

Definition at line 1728 of file turtle.py.

01728 
01729     def ycor(self):
01730         """ Return the turtle's y coordinate
01731         ---
01732         No arguments.
01733 
01734         Example (for a Turtle instance named turtle):
01735         >>> reset()
01736         >>> turtle.left(60)
01737         >>> turtle.forward(100)
01738         >>> print turtle.ycor()
01739         86.6025403784
01740         """
01741         return self._position[1]
01742 

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 1523 of file turtle.py.

Definition at line 1524 of file turtle.py.

Definition at line 1558 of file turtle.py.

Definition at line 1557 of file turtle.py.

Definition at line 1525 of file turtle.py.

Reimplemented in turtle.RawTurtle.

Definition at line 1538 of file turtle.py.

Reimplemented in turtle.RawTurtle.

Definition at line 1537 of file turtle.py.

Definition at line 1519 of file turtle.py.

Definition at line 1520 of file turtle.py.

string turtle.TNavigator.DEFAULT_MODE = "standard" [static]

Definition at line 1518 of file turtle.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Initial value:
{
        "standard": Vec2D(1.0, 0.0),
        "world"   : Vec2D(1.0, 0.0),
        "logo"    : Vec2D(0.0, 1.0)  }

Definition at line 1514 of file turtle.py.

Reimplemented in turtle.RawTurtle.

Definition at line 1526 of file turtle.py.


The documentation for this class was generated from the following file: