【问题标题】:Get the centerpoint of an Arc - G-Code Conversion获取圆弧的中心点 - G 代码转换
【发布时间】:2014-03-18 19:08:16
【问题描述】:

英雄

这是我第一次在这里发帖 我是 C# 的新手,但我遇到了一些困难

在插图中你会发现 圆弧坐标 从 (0,0) 引用的所有点 X 轴是水平的 Z轴是垂直的

http://i.stack.imgur.com/ycmdi.png

输入变量:

Xo,Zo =(529.819,343.509)
Xn,Zn =(529.26,343.678)
R(Radius) =(9.2)

我需要 I,K 的坐标(中心点,参考 0,0)

I,K 的答案是 (I532.2,K352.396) 但我想知道如何计算这个

这将在 G 代码转换中使用 例如:

N8(3)X529.819Z343.509$
N9(4)X529.26Z343.678R9.2C0$

N8(3)X529.819Z343.509$
N9(4)X529.26Z343.678I532.2K352.396$

(C0 和 C1 是 CW 和 CCW)

【问题讨论】:

  • 这似乎更像是一道几何题。

标签: c# g-code


【解决方案1】:

我多年前编写的一些 VB6 代码的复制/粘贴,它每天在很多机器上运行。它通过将坐标系旋转两点之间的角度来工作,从而大大简化了数学运算。 Tangent() 返回角度,Rotate() 旋转一个点,Sqr() 是C#中的Math.Sqrt():

  '--- Compute arc center from radius
  Dim tang#, w#
  tang = co1.Tangent(co2)
  co2.Rotate co1, -tang
  center.X = (co1.X + co2.X) / 2
  center.Y = 0
  w = center.X - co1.X
  If Abs(mModal.RWord) < w Then
    '--- R-word too small
    If mModal.ThrowErr And w - Abs(mModal.RWord) > 0.00
      Err.Raise 911, , "R-word too small"
    End If
  Else
    center.Y = -Sqr(mModal.RWord * mModal.RWord - w * w
  End If
  '--- Choose out of the 4 possible arcs
  If Not cw Then center.Y = -center.Y
  If mModal.RWord < 0 Then center.Y = -center.Y
  center.Y = center.Y + co1.Y
  center.Rotate co1, tang
  co2.Rotate co1, tang
  GetArcCenter = center

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-10
    • 2022-11-30
    • 2017-12-06
    • 1970-01-01
    • 2012-07-12
    相关资源
    最近更新 更多