[ python-Bugs-1514685 ] radians() doesn't work correctly

SourceForge.net noreply at sourceforge.net
Mon Jul 3 12:29:07 CEST 2006


Bugs item #1514685, was opened at 2006-06-29 23:27
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1514685&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
>Status: Closed
>Resolution: Duplicate
Priority: 7
Submitted By: Lingl (gregorlingl)
Assigned to: Martin v. Löwis (loewis)
Summary: radians() doesn't work correctly

Initial Comment:
>>> from turtle import *
>>> left(90)
>>> heading()
90.0
>>> radians()
>>> heading()
90.0    # should give pi/2, i.e. 1.5707... 
>>> forward(50) # turtle goes in direction 90 rad
                # i.e. approx. 116.62 degrees
  

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2006-07-03 12:29

Message:
Logged In: YES 
user_id=21627

This is essentially a duplicate of #1514693, which was fixed
with r47210.

Please provide patches as unified diffs in the future; they
would be much easier to process that way. See

http://www.python.org/dev/patches/

I don't think the top-level degrees functions should grow a
fullcircle argument: this is only to simplify the
implementation (i.e. having the state-changing code in a
single function). The end user is not expected to pass an
argument to degrees() or radians().

----------------------------------------------------------------------

Comment By: Lingl (gregorlingl)
Date: 2006-06-30 21:04

Message:
Logged In: YES 
user_id=1547199

Making two changes will correct the bug:

(a) In RawPen.__init__(): 

    def __init__(self, canvas):
        self._canvas = canvas
        self._items = []
        self._tracing = 1
        self._arrow = 0
        self._delay = 10     # default delay for drawing
        # patch for degrees()
##      self.degrees() # replace by the following two lines
        self._fullcircle = 360.0
        self._invradian = pi/180.0
        self.reset()

(b) in RawPen.degrees() : 

    def degrees(self, fullcircle=360.0):
        """ Set angle measurement units to degrees.

        Example:
        >>> turtle.degrees()
        """
        # patch for degrees(): add next line
        self._angle=self._angle*fullcircle/self._fullcircle
        self._fullcircle = fullcircle
        self._invradian = pi / (fullcircle * 0.5)


Additional Remark: In order that the function degrees()
works identically to the method of same name it should be
written:

def degrees(fullcircle=360.0): _getpen().degrees(fullcircle)


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1514685&group_id=5470


More information about the Python-bugs-list mailing list