[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] draw.arc comment



Hi,

As you may have been able to tell, I've been working with draw.arc recently...

One problem that i have is that it has its 0 degree mark on the right hand side, 90 on the top, 180 on the left, and 270 on the bottom.  This is problematic because as (0, 0) is the top left hand corner and the points increase to the bottom corner, draw.arc is 90 degrees out of phase with any trig calculations one does - with zero on the bottom, etc,  viz:

=== BEGIN
import math

def get_sides(pt1, pt2):
    x1, y1 = pt1
    x2, y2 = pt2
    
    return (x2 - x1), (y2 - y1)   # opplen, adjlen


def pts_to_angle(pt1, pt2):
    opplen, adjlen = get_sides(pt1, pt2)
    angle = math.degrees(math.atan2(opplen, adjlen))
    if angle < 0:
        angle += 360
    return angle

=== END

Of course draw.arc _can_ be wrapped - but any user who needs to do dynamic calculations will have to do so.  Whether or not it would be reasonable to change it at this stage is another matter (If indeed, it is agreed that it is a problem).

-T. (It's not that I'm not hugely grateful for draw.arc - believe me, i am ;-)

-- 
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm