多边形(或其部分)的圆近似 [英] Circular approximation of polygon (or its part)

查看:287
本文介绍了多边形(或其部分)的圆近似的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简短描述我的问题

我需要实现从G1指令到G2和G3的GCODE自动重构( http://www.cnccookbook.com/CCCNCGCodeArcsG02G03.htm )用于3D打印。

I need to implement GCODE autorefactoring from G1 instructions to G2 and G3 (http://www.cnccookbook.com/CCCNCGCodeArcsG02G03.htm) for 3D Printing.

G1是带有印刷的直线运动(路径由矢量描述)。

G1 is a movement in straight line with printing (path is describe by vector).

我正在寻找algorytm来替代圆/弧(特别是中点)基于给定的矢量路径。
请注意,G2和G3无法打印不属于圆弧的曲线-因此,并非每个矢量路径都可以以此方式近似。

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.

我的问题的详细描述

我正在寻找一种方法来逼近矢量路径的一部分(或全部)(可以是规则的多边形,一部分或不规则多边形部分)按圆(弧)。
但是,首先让我们着重于规则多边形。

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.

在图片中,我画了这个问题的不同案例。
注意: :每个多边形都是由矢量构建的(如第5点所示)。

In the picture i drew different cases of this problem. NOTE: Every polygons are build by vectors (like in point 5).


  1. 在完整x角上的近似值。

  2. 在一侧不同的部分x-gon的近似值

  3. x-的近似值两侧不同但彼此相等的gon

  4. 两侧不同(甚至彼此不相等)的x-gon的近似值不相等

  5. 双方都相等的部分x-gom的近似值

  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:


  • 圆的起点/终点必须在向量路径的起点/终点。

  • I需要知道圆的中点。

我发现的解决方案(很好和坏):

1)和5)-我的简单解决方案

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.

但是此解决方案仅适用于情况1和5。

But this solution works only for cases 1 and 5.

I当我有案例2,3,4或不规则多边形的一部分时,真的不知道该怎么办

I realy have no ide what to do when i have cases 2,3,4 or inregural polygon's part

推荐答案


  1. 您可以获取任意2条线段的曲率半径中心


  1. 找到直线中点

  2. 从每条(红线)投射垂直线

  3. 找到交点(它是曲率的中心)

3D 中使用对象的平面(3行而不是2行)。半径仅是中心与直线连接点(蓝线)之间的距离。如果半径太大,则将两条线都视为单条线(没有相交或相交太远)

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)

计算所有线段,如#1

如果半径相同,则将半径和中心相同的圆弧连接到单个圆弧

处理变化的曲率

如果圆弧正在改变中心或半径,请按照以下图片操作

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

第一段没有上一行,因此使用下一行会导致起始弧不规则...

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 ...

这篇关于多边形(或其部分)的圆近似的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆