Identify the direction of arc's

  • Thread starter Thread starter bsharp
  • Start date Start date
  • Tags Tags
    Direction
Click For Summary

Discussion Overview

The discussion revolves around determining the direction of arcs in a file format conversion context, specifically from APT code to G-code. Participants explore methods for calculating arc direction based on given coordinates and direction vectors, with a focus on both theoretical and practical implications of their approaches.

Discussion Character

  • Technical explanation, Experimental/applied, Debate/contested

Main Points Raised

  • One participant describes the structure of the APT code, detailing how the "GOTO" command, "INDRV" direction vector, and "TLON,GOFWD" lines relate to arc definitions.
  • Another participant shares their solution for determining arc direction by calculating the angle between the direction vector and the arc's center, suggesting that the sign of this angle indicates the arc's direction.
  • A later reply mentions the need to translate APT arc direction to G-code, highlighting the difference in how arc direction is specified in both formats, and emphasizes the importance of angle calculation for determining clockwise or counterclockwise direction.
  • Some participants express frustration over the lack of initial responses to the original question, indicating a sense of community engagement and the challenges faced in solving the problem.
  • There is a mention of the participant's pride in developing a G-code post processor that outperforms commercial alternatives, suggesting a successful application of their findings.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best method for determining arc direction, with multiple approaches and interpretations of the problem presented. Some methods are proposed and refined, but no single solution is universally accepted.

Contextual Notes

Limitations include the potential variability in arc definitions and the dependence on the specific format of the input data. The discussion also reflects differing levels of familiarity with the programming languages involved, which may affect the interpretation of the solutions proposed.

Who May Find This Useful

This discussion may be useful for software developers working on file format translations, engineers dealing with CNC programming, and individuals interested in geometric calculations related to arcs and circles.

bsharp
Messages
7
Reaction score
0
I am trying to translate a file from one format to another. The file I am trying to read from gives me the coordinates of arcs like this.

A three arc circle going clockwise:
GOTO / 0.80353, -0.60825, 0.75000, 0.000000, 0.000000, 1.000000
INDIRV/ -0.86603, 0.50000, 0.00000
TLON,GOFWD/ (CIRCLE/ 0.86603, -0.50000, 0.75000,$
0.12500),ON,(LINE/ 0.86603, -0.50000, 0.75000,$
0.92853, -0.39175, 0.75000)
INDIRV/ 0.86603, -0.50000, 0.00000
TLON,GOFWD/ (CIRCLE/ 0.86603, -0.50000, 0.75000,$
0.12500),ON,(LINE/ 0.86603, -0.50000, 0.75000,$
0.97428, -0.56250, 0.75000)
INDIRV/ -0.50000, -0.86603, 0.00000
TLON,GOFWD/ (CIRCLE/ 0.86603, -0.50000, 0.75000,$
0.12500),ON,(LINE/ 0.86603, -0.50000, 0.75000,$
0.80353, -0.60825, 0.75000)
The same three arc circle going counterclockwise:
GOTO / 0.80353, -0.60825, 0.75000, 0.000000, 0.000000, 1.000000
INDIRV/ 0.86603, -0.50000, 0.00000
TLON,GOFWD/ (CIRCLE/ 0.86603, -0.50000, 0.75000,$
0.12500),ON,(LINE/ 0.86603, -0.50000, 0.75000,$
0.92853, -0.39175, 0.75000)
INDIRV/ -0.86603, 0.50000, 0.00000
TLON,GOFWD/ (CIRCLE/ 0.86603, -0.50000, 0.75000,$
0.12500),ON,(LINE/ 0.86603, -0.50000, 0.75000,$
0.75777, -0.43750, 0.75000)
INDIRV/ -0.50000, -0.86603, 0.00000
TLON,GOFWD/ (CIRCLE/ 0.86603, -0.50000, 0.75000,$
0.12500),ON,(LINE/ 0.86603, -0.50000, 0.75000,$
0.80353, -0.60825, 0.75000)

The “GOTO” command is a linear move followed by it’s cords “X,Y,Z”
The “INDRV” is from what I can figure is a direction vector “X,Y,Z”?
The TLON,GOFWD line specifies the arc center cords “X,Y,Z”
The line after specifies the radius “0.12500” and arc center cords
The next line specifies the ending cords “X,Y,Z”.

Some how I need to determine the direction of each arc. I have tried comparing the starting and ending cords but it will not always work.
If the arc is 360 deg the “INDRV” cord will be positive or negative the corresponding arc center cord.
I think I have to calculate the direction from the “INDRV” based on the starting or ending cords some how.
If you look at the last arc in each example the only thing different is the starting cords “the ending cords from the previous arc”. If some one could help me out with this it would be great.
 
Computer science news on Phys.org
Since not one sole answered this ugly question. And after asking a thirty year mechanical engineer veteran and also a 4 year degree physics major.
This is how I solved it on my own. Once plotted out on a graph it is a lot more obvious. Just calculate the angle from the Direction Vector to the center of the arc. This will basically be two vectors. One being the direction vector start point to arc start point and the second as arc start to arc center. Once you can reliably calculate the angle it will be a negative value for one direction and a positive value for the opposite.

http://www.vb-helper.com/howto_find_angles.html"
Basically the sign of the solution will give you the direction.
It also works regardless of quadrant position in Cartesian space.
 
Last edited by a moderator:
Looks like BasicA... But no, it's VB.
 
mugaliens said:
Looks like BasicA... But no, it's VB.

The "three arc circle" code posted above is actualy APT
http://en.wikipedia.org/wiki/APT_%28programming_language%29"

I wrote a translator in VB to convert APT code to G code http://en.wikipedia.org/wiki/G-code.
The problem I was having with the arc direction was that in G code the direction is specified in a prefix of ether G03 "cw" or G02 "ccw" and in APT the arc direction is specified by a direction vector's relationship with the arc points. so to translate the "APT" arc direction vector to the "G code" equivalent prefix. I needed to calculate the angle between the direction Vector and the Arc points and the sign of the angle will determine the direction "cw or ccw". With this it is easy in VB to say "If arcsign <0 than gcode = G03" or something like that.
It took a lot of learning and turning of some pretty rusty gears but I got it and now I am proud to say I have a G code post processor that I wrote myself and is faster and more precise than any commercial one out there.
 
Last edited by a moderator:

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 14 ·
Replies
14
Views
1K
  • · Replies 39 ·
2
Replies
39
Views
5K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 25 ·
Replies
25
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
1K