Hi Les,

I was going to go on a maths forum and ask for help on this but thought I’d ask you first. If the answer is long winded, don’t worry, I know you are very busy, and this is not Sheetcam related.

In my never ending quest to “play” and figure out how to do things, I’m embarking on a technical mission to write some code that can read a gcode file and calculate arc lengths.

Most of it seems easy enough as the gcode gives XY start end end points, IJ arc centre location, etc. I can then use right angled triangle calcs, and circle calcs to get arc lengths.

The bit I’m stuck on is how to know whether the arc is a minor or major arc. Is there any simple trick to get that info from the gcode co-ordinates.

Keith

Couldn’t you use trig to calculate the arc angle given the start, end, and center points?

If you know three points then you can calculate the lengths of all three sides. Then you can calculate the angles.

https://www.mathsisfun.com/algebra/trig-solving-sss-triangles.html

That’s the easy bit, I’ve got all that worked out. But thanks all the same

The gcode gives us the start and end points, and the arc centre via IJ. So from those I can easily work out radius, sector angle, arc length, etc.

However, depending on whether the command is G2 or G3, the arc will be going in either a clockwise, or anti-clockwise direction respectively. Thus for a given set of co-ordinates, and the same start/end points, depending on the direction of the arc, it could be a minor arc, or a major arc. E.g. the minor arc could have a small angle of 10 degrees, but if the travel path is on the major arc of 350 degrees, the length of the arc is 35 times more.

So I’m not sure at the moment how to get that info (travel path on major or minor arc) from the XY/IJ positions I can get from the gcode.

Probably quite simply once it’s pointed out LOL. Maybe I’m just not seeing the forest for the trees.

Keith

The start, end and centre will get you the start and end angles. You need to use the arc direction (G02/G03) to figure out which of the two possible arcs is the correct one.

Assume sa = start angle and ea = end angle. The angles should be in the range -pi to +pi

angle = ea - sa

if angle < 0 then angle = angle + (2 * pi)

Reverse the angle for G03. If you are using degrees use 360 instead of 2 * pi. sa and ea should be in the range -180 to +180

Thanks a bunch Les.

That was really hurting my head for a few minutes until something clicked when you said, “If you are using degrees…”

So then I thought is Les using those Radian thingies (you see the mathematician in me ). So I check out Google and find there are pi radians in 180 degrees, and I got what you meant when you said -pi to + pi. Up until that eureka moment I was thinking how can the angle only be between -pi degrees and +pi degrees LOL.

With your explanation I now think I’ve got a fighting chance.

Thanks again.

Keith

curiosity has got me Keith, what are you experimenting with?

Hi Rob,

you know the THC that I designed. It’s another feature I’d like to add to that. If you got a flameout during a cut, the system would either automatically or upon a button press (depending on setting), reverse along the cut path a given amount at cut height, re-start motion, then fire the torch a few mm before the flameout point.

But as always, got so much other stuff happening I only get pockets of time at this. I got hold of some climbing equipment at a good price and now my boy and me are always playing with that. End goal is to do some recreational tree climbing. Just fabricated a 4.3m tall hang point in my back garden for practicing our rope techniques. I’m just a 50 odd year old boy I think

I understand completely about the pockets of time as I am the same.

that thc sounds like it’s going well, I thought you may be one of the plasmac converts. (too much under the bonnet time for me… not enough pockets of time between wife, life, children, work (new job thanks to covid redundancy), and other non CNC hobbies)

I had a friend I use to work with who was into climbing with ropes, all over my head, too brave… the best I’ve done is some absailing as a child… leaning backwards over the edge and looking down / backwards was enough for me… it’s not the drop it’s the sudden stop at the bottom that puts me off… I remember my friend saying that you allow for one or two of the anchor points coming out if you slip, but hope the third will hold as the first two have taken the shock out of the slip… he use to do various rock face places in Wales and the lakes with mates.