1

I have a problem to use this bulge arc (dxf parser) function in C++ getArcDataFromBulge().

https://github.com/Embroidermodder/Embroidermodder/blob/master/libembroidery/geom-arc.c

I have my drawArc() function which need 'start angle' and 'sweep angle' parameters from this getArcDataFromBulge() function. My drawArc() function use OpenGL 2D coordinate system with right side zero angle position and when I get values from getArcDataFromBulge() and recalculate it (0+-, 180+-, 360+-) I have something like unexpected opposite angles as results. It looks like clockwise-counterclockwise problem, but I'm think is not, I'm not sure. Do you have some idea what is going on?

For example:

tempBulge.bulge := 0.70;
arcMidAngle := RadToDeg( atan2(tempBulge.arcMidY - tempBulge.arcCenterY, 
tempBulge.arcCenterX - tempBulge.arcMidX) );

After calculaton: arcMidAngle = 179.999 When I add and subtract from this point half of arc chord angle, I get start and end angles of my arc: 90°, 270° but it's not the same arc when I open dxf with some CAD software, it is opposite than origin drawing.

escape321
  • 39
  • 7
  • Perhaps you can expand your question with an example of the "negative, positive angles, directions and other circle stuff" and where it is you're having trouble using them with DrawArc(). As the question currently is, there isn't enough information for most people to put the effort in to answer. If you write a better question though, that will change. – David Aug 28 '14 at 10:33
  • Yes I will expand, just to check my assumptions about autocad, opengl coordinate systems and my inverse y-axe drawing – escape321 Aug 29 '14 at 11:50
  • What you need to show us are (1) The code you are using. (2) The result it produces. (3) The result you are expecting (or wish to achieve). Without this information it is very difficult to help. – J... Aug 29 '14 at 12:55
  • Finally I found that I had wrong expectation about coordinate zero position. When using OpenGL 2D coordinate system my circle drawing goes in clockwise direction (zero is on the right side of circle), but when I receive bulge arc parameters from dxf examples it seams that zero position is on the left side of circle!? Who decide where zero position have to be? Does arc direction can change that zero position? – escape321 Aug 29 '14 at 13:10
  • zero position is a start 0° angle position of drawing circle – escape321 Aug 29 '14 at 13:18
  • Actually my question is in wrong direction and answer is probably here: http://stackoverflow.com/questions/4124041/is-opengl-coordinate-system-left-handed-or-right-handed – escape321 Aug 29 '14 at 13:26
  • I've rolled back your edits. That is not the proper way to answer your own question here. First, edit it to get it reopened, so that answers can be posted. Then post an actual answer to the question just like anyone else would do; you can even accept it as correct, although you won't gain any reputation for doing so. For more info, see [Can I answer my own question?](http://stackoverflow.com/help/self-answer). – Ken White Aug 31 '14 at 21:49
  • You need to parse the `$ANGDIR` variable from the `HEADER` section which tells you in which direction angles are defined within that specific DXF file. – NGLN Sep 02 '14 at 06:15
  • Does $ANGDIR reflects on initial/terminal side as orientation of calculation? I found that everything works when I calculate angles adaptation as left initial/terminal side (zero is on the left side of circle). It doesn't refer on clockwise/counter-clockwise problem I think. I tried with clockwise-counterclockwise on right initial orientation (zero on the right side of circle) but without success. – escape321 Sep 02 '14 at 18:27
  • Please address users with @ in comments. See [What happens when I comment?](http://stackoverflow.com/help/privileges/comment) and [How do comment @replies work?](http://meta.stackexchange.com/q/43019/162538). – NGLN Sep 07 '14 at 07:52

1 Answers1

2

If you have an arc from 0° to 90°, it could be a 1/4 circle or a 3/4 circle.

You need to parse the $ANGDIR and $ANGBASE variables from the HEADER section which tells you in which direction angles are defined ($ANGDIR) and where the 0° angle starts ($ANGBASE) within that specific DXF file:

Variable  Group code  Description 
$ANGBASE  50          Angle 0 direction 
$ANGDIR   70          1 = Clockwise angles, 0 = Counterclockwise

For DXF, if $ANGBASE = 0, then 0° is on the right of the center, alike Windows.

Furthermore, in DXF, the positive Y-axis is upwards, in contrast to many Windows API's where the positive Y-axis is downwards.

NGLN
  • 43,011
  • 8
  • 105
  • 200