There is some info here that may give you some ideas:
Building a software Indexer
I'm currently a software engineering for a laser company and am programming a GCode display program in C#. How would I go about displaying arcs using I/J values?
As far as drawing arcs goes here are my options:
x, y, width, height, startAngle, sweepAngle
Rectangle, startAngle, sweepAngle
How would I gather the startAngle and sweepAngle from the GCode? Another option would be just to draw an arc using straight lines... How should I approach this?
Don't think that's what I'm looking for...
The best place I found that describes the different methods of arcs in G code is the Mach3 manual.
It can be found at http://www.machsupport.com/docs/Mach3Mill_1.84.pdf
Look at section 10.7.3.1 and 10.7.3.2
NCPlot.com - Tools for CNC Programmers
Arc Buddy is a simple python script that does what you want in reverse. I'm not sure if it helps at all but the code won't cost much time to read.How would I gather the startAngle and sweepAngle from the GCode?
EMC Documentation Wiki: Simple EMC G-Code Generators
"Axis" does the backplotting for EMC2. It's open source but wading through the code will take a lot of effort. More python.
No idea.Another option would be just to draw an arc using straight lines... How should I approach this?
G02 and G03 defines arcs so why go there ?
edit/ G02 and G03 use 'start point/end point/distance from center' (or alternatively R). If sweep is needed the program will need to make the calculation, it helps to think in quadrants.
Anyone who says "It only goes together one way" has no imagination.
When writing software to display the tool path, you can:
1. Easily calculate the arc center point in systems using I and J to describe the center point incrementally, by applying the I and J values to the arc start point.
2. In systems using I and J to describe the arc center in Absolute terms, the center requires no calculation.
3. In systems using R, the center point is calculated using the Start, End points and the R value. I can give you the algorithm for this if its a help to you.
Once the arc center is known the Start and End angle of the arc is calculated using simple trigonometry.
If the software is to display the cutter path of a laser machine (top view of XY plane) then using arc center, start angle, sweep angle, and radius is the best solution. If the display is an Isometric view, then the properties of the arc will still have to be calculated based on the G code data, but the acr will be drawn using short, straight lines because the representative curve drawn in the display will not be a true arc.
ZSamuels, if I understand your question correctly, you're trying to write a g-code simulator in C++ to be used with your laser. Is that correct?
If so, there's quite a lot for you to consider. I've got a simulator in Beta Test called G-Wizard Editor:
GWizard Editor: A G-Code Editor and Simulator
Something you may find useful about GWE is it has a facility called "Hints" for folks that are not dyed in the wool g-code experts (actually it is helpful to many experts too, LOL). It pumps out a lot of information about each line of g-code in easy to understand English.
Here is a typical hint with information on an arc, for example:
You might find it useful just because it provides a lot of information about the arc that is not immediately obvious just looking at the raw g-code.
As for the other considerations of a g-code simulator, the language has all sorts of ways to modify what's going on that you'll need to be aware of depending on which dialect your laser's controller plans to support.
For example, you'll need to be prepared to plot the arc when scaling, work offsets, coordinate rotation, and various other factors are in play. Quite a bit of work required to build a general purpose simulator, LOL.
Probably the best place to drill down and see at least one way things are done is to go check out the source code for EMC2.
Try G-Wizard Machinist's Calculator for free: