## Re: [PyX-user] connect.arc bug

 Re: [PyX-user] connect.arc bug From: Francisco Borges - 2005-09-07 19:39:59 ```Hello, =BB On Wed, Sep 07, 2005 at 07:48PM +0200, Andre Wobst wrote: > nothing else. You can't describe a straight line by an arc, so you're > just requesting the wrong thing. The arc connector is just not > welldefined for a relangle of zero. I see the point. But if that should be the case, I would suggest adding something to the documentation for the sloppy users like me. > In case we want to replace the arc by a straight line, the question > arrises when to do that. What do you think would be an appropriate > threshould? How to define that threshold (do we need an parameter for > that ... what should this parameter look like)? I just don't know ... IMHO a reasonable threshold would be: if relangle =3D=3D 0.: # make it a straight line. But there is more to it, see below. > and that's again an indication, that it might not be right to do fancy > things. What do you suggest? First I would suggest you to look again at these try/except blocks: At pyx/connector.py,=20 class arc_pt(connector_pt): def __init__(self, box1, box2, relangle=3D45, absbulge=3DNone, relbulge=3DNone, boxdists=3D[0,0]): [....] if relbulge is not None or absbulge is not None: try: radius =3D abs(0.5 * (bulge + 0.25 * distance**2 / bulge)) except: radius =3D 10 * distance # default value for too straight ar= cs radius =3D min(radius, 10 * distance) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # ad hoc threshold. [.....] # otherwise use relangle [...] bulge=3DNone try: radius =3D 0.5 * distance / abs(cos(0.5*math.pi - radians(relang= le))) except: radius =3D 10 * distance ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # this one will not be triggered (i think). try: center =3D tan(0.5*math.pi - radians(relangle)) except: center =3D 0 =20 I can only guess about the intention of these try/except clauses, and my guess is that they are here to get a ZeroDivisionError. /If/ that's the case... I would tell you that: math.cos is not precise enough to raise th= at for 1/math.cos(pi/2) (or math.tan(pi/2)).=20 So in any case, you should check the size of radius or center with the same threhold as in the "relbulge !=3D None" part. (where an ad hoc thres= hold is in use ;-)). My suggestion would be to whenever hitting this huge radius threshold (currently 10*distance, if you use relbulge), instead of setting radius t= o some huge value (i.e. 10*distance), switch to a straight line. This would cover the relangle=3D=3D0 case and also the cases where relangle\$\approx\$= 0. This could be better than just checking for relangle=3D=3D0. It's not perfect, I know, but it seems like a better compromise: it would output a usable figure while setting radius=3D10*distance doesn't seems t= o. Cheers, Francisco. ```