# Any maths wizards in today?

Picklefactory 13:24 10 Jan 2009
Locked

Not a PC issue, (FE please move post if I've posted in wrong forum) but I know there are some numerically gifted members who look in.

I'm trying to cretate a formula to use in Excel to calculate the length of a circular arc. Sounds simple enough, but it gets more complicated. The known data will come from a CNC machine program which would comprise of a start and end point in x,y co-ordinates, a radius and rotation direction (CW or CCW) and nothing more, that is all there is to work with. So I have start point X1,Y1 and end point X2,Y2 with radius r and I know whether CW or CCW. So IF statement is available to run a choice of formulae.

I have found various ways to calculate arc length, but my biggest issue is I cannot find a way for the formula to be able to decide in all scenarios from CW or CCW whether to calculate longer or shorter of the 2 possible arcs between the start/end point. I can do it when X0,Y0 is centre of arc, but I can't find a way to do it when X0Y0 is outside the arc circle.

I hope that makes sense. Any suggestions gratefully accepted as this has been twisting my head since yesterday lunchtime.

woodchip 13:47 10 Jan 2009

Picklefactory 13:56 10 Jan 2009

Yeah I know, my hat is always off to VoG re:Excel, but this is less Excel than pure calculus or trig. The Excel part is not too difficult, hopefully just a long formula, but I'm struggling with the maths.

Pineman100 15:18 10 Jan 2009

I'm not sure I understand your question fully, so the following may be a gross oversimplification.

The key question, it seems to me, is do you know the angle that will be struck by the two lines that join points X1,Y1 and X2,Y2 to point zero?

If you do, then calculating the length of the arc should be possible as follows (where A is the angle I've mentioned above and R is the radius):

(Pi*R)*(A/360)

The only difference in calculating CW or CCW will be whether you use the acute angle or the obtuse angle.

If you have no way of knowing the angle A, then I'm afraid I'm as stymied as you!

Picklefactory 15:35 10 Jan 2009

... but you've hit same wall as me. I only have the known data as specified, so, no, I don't know angle A from base data although it can be calculated via simple trig. The arc length formula was never a problem, the problem is how can I mathematically determine whether to calculate with acute or obtuse angle using CW/CCW with start/end point as deciding factors. Or indeed there is the possibilty of 180º arc to add a 3rd option.
Not easy.

Pineman100 15:46 10 Jan 2009

I rather suspected that I came to my solution too easily! Sorry.

Picklefactory 15:48 10 Jan 2009

Thanks for trying.

skeletal 17:23 10 Jan 2009

Have you considered that there may be a convention in CNC programming? Perhaps anyone who has done this could confirm.

The point is that putting in start and end coordinates and radius would hopefully always produce the same effect on any machine.

So, thinking like this, I’ve just scribbled a few points on a piece of paper (impossible to reproduce here!) and I think that the short arc can only ever have a maximum of two changes in sign of the X, Y coordinates i.e. X increasing with Y decreasing, then X and Y both decreasing; e.g writing it as + -, - -. Alternatively it could be only X and Y both increasing i.e. + +.

The long arc going CCW could be - -, + -, + +, - +.

If both sets of number have two reversals, the line lengths would be the same (I think, but haven’t proved it!) so I guess it would not matter.

Counting the number of reversals could be a way of relating CW/CCW and arc length.

You may have to try a few combinations to see if this is always true; if it isn’t sorry for wasting the rest of your weekend!!

I hope this makes sense and if so, has this offered any new clues?

Skeletal

skeletal 17:45 10 Jan 2009

Actually, sticking with the idea that there may be some sort of convention: it could be that if you want a CNC machine to do the large arc, you always tell it to go CCW, and the short arc to go CW (or the other way round obviously).

This would be a big help.

Skeletal

Picklefactory 18:31 10 Jan 2009

Thanks for the thoughts but I think I should shed more light than I have. I program CNC's, what I'm attempting is to create a spreadsheet to calculate time taken to complete a series of moves. Linear is simple, but to calculate the time taken to travel around an arc requires me knowing the length of travel around that arc. the programs exist, but all I have to work with are start and end points in cartesian x,y format, the radius of arc and the rotational direction.
eg one such move could be thus

X20.0Y20.0 (Start point of arc)
G2X40.0Y20.0R10.0 (End point of arc)

That is an overly simple exmple where the arc created would be 180º and would start and end at the same point on Y axis. What I need to do (And may have managed now) is find a formula that can determine from that which arc to calculate.

Does that help?

I've been trawling the net and have found a formula that might do it, I'm still experimenting.

Picklefactory 19:10 10 Jan 2009

I found a formula that is supposed to do it, but I'm too stupid to understand it fully. Formula is as follows (If you can understand my way of tying it): -

k=(x'y"-y'x")/(x'²+y'²)³/² but the final / should also be superscript, but I don't know how to display that.
If you want see it properly, I found it here about midway down the page.

The bit I don't understand is the final ³/² bit, what does that tell me to do with the result of the bracketted expression? Cube it then square it????

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

OnePlus 5 review

Alice Saey's mesmerising animation for Dutch singer Mark Lotterman