Arcs and Circle line segments for CNC

The calculator plugin can be found [here][1].

When machining metals using CNC, it is generally desirable to use enough points so that the “flats” are kept to a minimum to provide a smooth finish. On the other hand, when machining a hole (for example), it is desirable to have enough points so that the diameter is maintained to some tolerance to insure the proper size (the sagitta). For a very large circle, the number of points is substantially different than what is needed for a small circle. As @scurring pointed out, the units will cancel out in the calculation and yield only a number representing the number of segments (i.e., works in inches, millimeters, etc.). More information can be found in this thread: How many points for a smooth curve?

The calculations I used are:

Flat: n = scale * Math::PI / Math.asin(error / (2.0 * radius))
Sagitta: n = scale * Math::PI / Math.acos((radius - error) / radius)

(The second equation is identical to the one scurring posted although I allow for portions of a full circle)
[1]: https://sites.google.com/site/spirixcode/code/jrh_n_calc.rb