SHORT DESCRIPTION OF MY PROBLEM
I need to implement GCODE autorefactoring from G1 instructions to G2 and G3 (http://www.cnccookbook.com/CCCNCGCodeArcsG02G03.htm) for 3D Printing.
G1 is a movement in straight line with printing (path is describe by vector).
I'm searching for algorytm to aproxymate circle/arc (specialy it's midpoint) based on given vectors path.
Note that G2 and G3 can't print curves that are not part of a circle - so not every vectors path can be approximate this way.
LONG DESCRIPTION OF MY PROBLEM
I'm searching way to approximate part (or all) of vectors path (can be regular polygon, part of it or inregular polygon part) by circle (arc).
But let's, at first, focuse on regural polygons.
In the picture i drew different cases of this problem.
NOTE: Every polygons are build by vectors (like in point 5).
- Approximation on full x-gon.
- Approximation of part x-gon where one side is different
- Approximate of x-gon where two sides are different but equal to each other
- Approximate of x-gon where two sides are different (not even to each other)not equal
- Approximation of part x-gom where all sides are equal
It's not the eod of story...there are couple criteria:
- Circle's start/end point must be in the beginning/end of vectors path.
- I need to know circles mid point.
Solutions that i found (good and bad):
1) and 5) - my simple solution
This is the easiest case. I can count radius between each side that shares one opint. If they have same length and angles between each are equal i can calculate circles mid point (as point that belongs to perpendiculat middle-lines, one middle-line per side) and i have all i need: Start point, end point, mid-point.
But this solution works only for cases 1 and 5.
I realy have no ide what to do when i have cases 2,3,4 or inregural polygon's part
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…