Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
603 views
in Technique[技术] by (71.8m points)

algorithm - Circular approximation of polygon (or its part)

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). enter image description here

  1. Approximation on full x-gon.
  2. Approximation of part x-gon where one side is different
  3. Approximate of x-gon where two sides are different but equal to each other
  4. Approximate of x-gon where two sides are different (not even to each other)not equal
  5. 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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  1. You can obtain curvature radius center for any 2 line segments

    curve radius

    1. find the lines midpoints
    2. cast perpendicular lines from each (red lines)
    3. find the intersection (it is the center of the curvature)

    In 3D use plane of the object (3 lines not 2). The radius is just distance between center and the lines joint point (blue line). If radius is too big then handle both lines as single line (no intersection or too far intersection)

  2. compute all segments like in #1

  3. join arcs with the same radius and center to single arc if joined

  4. handle the changing curvature

    if the arc is changing the center or radius do it like in this picture

    elliptic arc

    first segment does not have previous line so use the next instead that cause the irregularity at start arc ...

That should cover all cases hope my hand-paint-drawings are making sense ...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...