Plotting an Arc in Discrete Steps
Posted
by
phobos51594
on Stack Overflow
See other posts from Stack Overflow
or by phobos51594
Published on 2011-06-24T22:07:42Z
Indexed on
2011/06/25
0:22 UTC
Read the original article
Hit count: 261
Good afternoon,
Background
My question relates to the plotting of an arbitrary arc in space using discrete steps. It is unique, however, in that I am not drawing to a canvas in the typical sense. The firmware I am designing is for a gcode interpreter for a CNC mill that will translate commands into stepper motor movements. Now, I have already found a similar question on this very site, but the methodology suggested (Bresenham's Algorithm) appears to be incompatable for moving an object in space, as it only relies on the calculation of one octant of a circle which is then mirrored about the remaining axes of symmetry. Furthermore, the prescribed method of calculation an arc between two arbitrary angles relies on trigonometry (I am implementing on a microcontroller and would like to avoid costly trig functions, if possible) and simply not taking the steps that are out of the range. Finally, the algorithm only is designed to work in one rotational direction (e.g. counterclockwise).
Question
So, on to the actual question: Does anyone know of a general-purpose algorithm that can be used to "draw" an arbitrary arc in discrete steps while still giving respect to angular direction (CW / CCW)? The final implementation will be done in C, but the language for the purpose of the question is irrelevant.
Thank you in advance.
References
S.O post on drawing a simple circle using Bresenham's Algorithm:
"Drawing" an arc in discrete x-y steps
Wiki page describing Bresenham's Algorithm for a circle
http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
Gcode instructions to be implemented (see. G2 and G3)
http://linuxcnc.org/docs/html/gcode.html
© Stack Overflow or respective owner