## Re: [PyX-user] absangle, relangle

 Re: [PyX-user] absangle, relangle From: Michael Schindler - 2005-09-14 22:36:25 ```Hello Rich, On 14.09.05, Rich Drewes wrote: > I'm having a lot of trouble getting absangle1= and absangle2= on curve()s > to do what I expect. This may be because what I expect it to do is not > what it is supposed to do--the documentation is a bit brief on what they > do. > > What I *think* absangle is supposed to do is define the absolute angle of > entry of my connector curve into the object being connected to. In my > case, I am connecting polygons, mostly just boxes. So absangle2=0 would > mean that my arrow would enter the target from the left (or maybe the > right, wherever 0 is defined . . . already things are a bit hazy). If > absangle2=90 the target would be entered from the top of the object (or > maybe bottom, depending on which direction things are counted.) > > (Or, rather than connecting to the edge of the target at the angle given > by the side, does it merely instruct the curve drawer to connect to some > convenient side of the target, but connect to it at the indicated angle of > incidence?) When giving the orientation angle, I always think in terms of the tangent vector of the path (heading in the direction that the path is drawn: along positive parameterization). The coordinate system is such that an angle of 0 degrees means "heading right" and 90 degrees means "heading top" Therefore, if you want something like this: _ _ |_| -----> |_| then use absangle1=0, absangle2=0 _______ / \ | | | v |_| |_| then use absangle1=90, absangle2=-90 and so on. For the relative angles, things are different. Here, I try to be consistent with the arc() connector, where both relative angles are the same. Therefore, the coordinate systems at the two boxes have different signs. The absolute values of relangle1 and relangle2 are the (absolute) angles between the connector and the straight connection line between the box centers. Their sign gives the side on which they start: When they have the same sign, the whole connectors stays on the same side. I admit that there are many different coordinate systems for these angles. Maybe we should turn the sign of relangle2. This is a point that can be discussed. > The absangle arguments seem to have more effect when my polygons are > smaller. If my polygons are more elongated, my absangle commands seem to > be ignored consistently by whatever actually placed my connector curves. In order to convince me that something strange happens, please enclose a short example. This is what the connectors do: 1. draw a line/curve/arc from one box-center to the other box-center The centers are the important orientation points for connectors. If you are using text-boxes, then the center will be on the baseline of the text, at the leftmost point (unless you use text.halign.xxx) 2. intersect this line/curve/arc with the box' outline path (polygons in your case) 3. shorten the line/curve/arc according to the boxdists parameter Note that all angles are evaluated at the box' center. This means that when you connect a pair of boxes, first large boxes, and then small ones, and then compare, the global slopes of the two connectors will be the same, but the angle at the different box' outlines will, of course, be different. > See http://www.interstice.com/drewes/brain/pyxdocexample.eps for an > example of what I am trying to do. As you can see, I have to be pretty > careful about how the connectors are placed to make sure the result is > legible. > I suspect I am working under at least one major misconception here. I hope my explanations are helpful, and I will improve the documentation at this point. Michael. -- "A mathematician is a device for turning coffee into theorems" Paul Erdös. ```

 [PyX-user] absangle, relangle From: Rich Drewes - 2005-09-14 21:34:26 ```I'm having a lot of trouble getting absangle1= and absangle2= on curve()s to do what I expect. This may be because what I expect it to do is not what it is supposed to do--the documentation is a bit brief on what they do. What I *think* absangle is supposed to do is define the absolute angle of entry of my connector curve into the object being connected to. In my case, I am connecting polygons, mostly just boxes. So absangle2=0 would mean that my arrow would enter the target from the left (or maybe the right, wherever 0 is defined . . . already things are a bit hazy). If absangle2=90 the target would be entered from the top of the object (or maybe bottom, depending on which direction things are counted.) (Or, rather than connecting to the edge of the target at the angle given by the side, does it merely instruct the curve drawer to connect to some convenient side of the target, but connect to it at the indicated angle of incidence?) The absangle arguments seem to have more effect when my polygons are smaller. If my polygons are more elongated, my absangle commands seem to be ignored consistently by whatever actually placed my connector curves. See http://www.interstice.com/drewes/brain/pyxdocexample.eps for an example of what I am trying to do. As you can see, I have to be pretty careful about how the connectors are placed to make sure the result is legible. I suspect I am working under at least one major misconception here. Thanks, Rich ```
 Re: [PyX-user] absangle, relangle From: Michael Schindler - 2005-09-14 22:36:25 ```Hello Rich, On 14.09.05, Rich Drewes wrote: > I'm having a lot of trouble getting absangle1= and absangle2= on curve()s > to do what I expect. This may be because what I expect it to do is not > what it is supposed to do--the documentation is a bit brief on what they > do. > > What I *think* absangle is supposed to do is define the absolute angle of > entry of my connector curve into the object being connected to. In my > case, I am connecting polygons, mostly just boxes. So absangle2=0 would > mean that my arrow would enter the target from the left (or maybe the > right, wherever 0 is defined . . . already things are a bit hazy). If > absangle2=90 the target would be entered from the top of the object (or > maybe bottom, depending on which direction things are counted.) > > (Or, rather than connecting to the edge of the target at the angle given > by the side, does it merely instruct the curve drawer to connect to some > convenient side of the target, but connect to it at the indicated angle of > incidence?) When giving the orientation angle, I always think in terms of the tangent vector of the path (heading in the direction that the path is drawn: along positive parameterization). The coordinate system is such that an angle of 0 degrees means "heading right" and 90 degrees means "heading top" Therefore, if you want something like this: _ _ |_| -----> |_| then use absangle1=0, absangle2=0 _______ / \ | | | v |_| |_| then use absangle1=90, absangle2=-90 and so on. For the relative angles, things are different. Here, I try to be consistent with the arc() connector, where both relative angles are the same. Therefore, the coordinate systems at the two boxes have different signs. The absolute values of relangle1 and relangle2 are the (absolute) angles between the connector and the straight connection line between the box centers. Their sign gives the side on which they start: When they have the same sign, the whole connectors stays on the same side. I admit that there are many different coordinate systems for these angles. Maybe we should turn the sign of relangle2. This is a point that can be discussed. > The absangle arguments seem to have more effect when my polygons are > smaller. If my polygons are more elongated, my absangle commands seem to > be ignored consistently by whatever actually placed my connector curves. In order to convince me that something strange happens, please enclose a short example. This is what the connectors do: 1. draw a line/curve/arc from one box-center to the other box-center The centers are the important orientation points for connectors. If you are using text-boxes, then the center will be on the baseline of the text, at the leftmost point (unless you use text.halign.xxx) 2. intersect this line/curve/arc with the box' outline path (polygons in your case) 3. shorten the line/curve/arc according to the boxdists parameter Note that all angles are evaluated at the box' center. This means that when you connect a pair of boxes, first large boxes, and then small ones, and then compare, the global slopes of the two connectors will be the same, but the angle at the different box' outlines will, of course, be different. > See http://www.interstice.com/drewes/brain/pyxdocexample.eps for an > example of what I am trying to do. As you can see, I have to be pretty > careful about how the connectors are placed to make sure the result is > legible. > I suspect I am working under at least one major misconception here. I hope my explanations are helpful, and I will improve the documentation at this point. Michael. -- "A mathematician is a device for turning coffee into theorems" Paul Erdös. ```
 Re: [PyX-user] absangle, relangle From: Rich Drewes - 2005-09-15 00:51:07 ```Thanks for your response. Below is a small demo program that doesn't quite do what I would expect even given your explanations. Regardless of what I specify as absangle2 I can't seem to force the connection to come in from the right side of the target box, for example. Does this demo do what you would expect it would? Rich #!/usr/bin/env python import pyx ca=pyx.canvas.canvas() pyx.unit.set(defaultunit="inch") corners=[(5.0, 2.0), (7.0, 2.0), (7.0, 3.0), (5.0, 3.0)] bt1=pyx.box.polygon(corners) ca.stroke(bt1.path(), [pyx.color.rgb.red]) corners=[(1.0, 1.0), (2.0, 1.0), (2.0, 2.0), (1.0, 2.0)] bt2=pyx.box.polygon(corners) ca.stroke(bt2.path(), [pyx.color.rgb.red]) curve=pyx.connector.curve co=pyx.color.rgb.red ar=pyx.deco.earrow.normal #la='label' #for (a2,co) in ((0, pyx.color.rgb.red), # (90, pyx.color.rgb.green), # (180, pyx.color.rgb.blue), # (270, pyx.color.rgb.black), # (330, pyx.color.cmyk.Tan)): #for a2 in range(-180, 180, 10): for a2 in range(0, 360, 10): ca.stroke(curve(bt2, bt1, absangle1=a2, absangle2=a2), [co, ar]) ca.writeEPSfile('doc.eps') ```
 Re: [PyX-user] absangle, relangle From: Michael Schindler - 2005-09-15 08:39:05 ```On 14.09.05, Rich Drewes wrote: > > Thanks for your response. > > Below is a small demo program that doesn't quite do what I would expect > even given your explanations. Regardless of what I specify as absangle2 I > can't seem to force the connection to come in from the right side of the > target box, for example. Does this demo do what you would expect it > would? Yes, indeed. Everything is fine. What do you mean? I guess: You want to see alle the angles between 0 and 360 degrees coming out of your boxes. But they are too big for that. Just make them smaller, and you will have what you want. The boxes simply cover most of the outcoming angle. This is exactly what I meant with "the connectors orient themselves at the boxes centers". One possibility for you is to use the "bulge" arguments. Try setting "relbulge=1.5" in your example. Then the curves will have more freedom stretching along the given directions. Michael. > #!/usr/bin/env python > import pyx > > ca=pyx.canvas.canvas() > > pyx.unit.set(defaultunit="inch") > > corners=[(5.0, 2.0), (7.0, 2.0), (7.0, 3.0), (5.0, 3.0)] corners=[(5.0, 2.0), (5.1, 2.0), (5.1, 2.1), (5.0, 2.1)] > bt1=pyx.box.polygon(corners) > ca.stroke(bt1.path(), [pyx.color.rgb.red]) > > corners=[(1.0, 1.0), (2.0, 1.0), (2.0, 2.0), (1.0, 2.0)] corners=[(1.0, 1.0), (1.1, 1.0), (1.1, 1.1), (1.0, 1.1)] > bt2=pyx.box.polygon(corners) > ca.stroke(bt2.path(), [pyx.color.rgb.red]) > > curve=pyx.connector.curve > > co=pyx.color.rgb.red > ar=pyx.deco.earrow.normal > #la='label' > > #for (a2,co) in ((0, pyx.color.rgb.red), > # (90, pyx.color.rgb.green), > # (180, pyx.color.rgb.blue), > # (270, pyx.color.rgb.black), > # (330, pyx.color.cmyk.Tan)): > > #for a2 in range(-180, 180, 10): > for a2 in range(0, 360, 10): > ca.stroke(curve(bt2, bt1, absangle1=a2, absangle2=a2), [co, ar]) > > ca.writeEPSfile('doc.eps') -- "A mathematician is a device for turning coffee into theorems" Paul Erdös. ```
 Re: [PyX-user] absangle, relangle From: Rich Drewes - 2005-09-15 15:55:14 ```On Thu, 15 Sep 2005, Michael Schindler wrote: > Yes, indeed. Everything is fine. What do you mean? > I guess: You want to see alle the angles between 0 and 360 degrees > coming out of your boxes. But they are too big for that. Just make > them smaller, and you will have what you want. Doh! I see. The line does leave the object center at the angle requested by absangle, but by the time it intersects the object outline it has already curved enough that it actually emerges from the object at a radically different orientation. It seems like it might be preferable to project a straight line out from the object center and intersect it with the path of the object and use that intersection point as the endpoint of the connection. Otherwise the actual connection points and paths can't really be predicted easily, and I suspect they might change greatly even as the figure is uniformly scaled (as the ratio of the (distance from object center to object edge) to (distance from object to object) changes). Thanks for walking me through this! Rich ```