如何使用拟合点创建 dxf 样条曲线? [英] How do I create a dxf spline curve using fitpoints?

查看:45
本文介绍了如何使用拟合点创建 dxf 样条曲线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 dxf 文件中以编程方式创建样条曲线.我需要使用拟合点,因为曲线需要通过指定的点.我知道我也需要使用控制点.有没有公​​式可以计算这些应该是什么?它是一个有四个拟合点的闭合样条.

提前致谢!

解决方案

我认为这不是一件容易的事.除了控制点之外,您还需要确定节点.有一个 DXF 阅读器/查看器

使用多段线来近似您的样条线会更容易.这是多段线的示例(L 形从 0,0 -> 100, 0 -> 100, 50 开始)

<代码> 0折线5D533070100实体80100AcDb折线903700430.0100.0200.010100.0200.010100.02050.0

要从拟合点计算控制点的位置,您可以参考此页面 (§24 & §25).事实上,您需要反转 Casteljau 的算法(对于贝塞尔曲线;我不知道它对 NURBS 是如何工作的).

I'm trying to create a spline curve programmatically in a dxf file. I need to use fit points as the curve needs to pass through the specified points. I understand I also need to use control points. Is there a formula to calculate what these should be? It is a closed spline with four fit points.

Thanks in advance!

解决方案

I think this is not an easy task. In addition to the control points, you will also need to determine the knots. There is a DXF reader/viewer here (written in C++) which claims to support spline. May be you can find some information by reading the code.

AutoCAD uses NURBS which are approximated curves (the curve pass only by the first and last points). In the user interface, splines are interpolated (the curve pass by the fit points), so there is a translation which is done when reading/writing a DXF file. If you create a closed point with 4 fit points, you will see there is 7 controls points in the DXF file:

Using a polyline to approximate your spline will be easier. Here is a sample of a polyline (L shape starting from 0,0 -> 100, 0 -> 100, 50)

  0
LWPOLYLINE
  5
D5
  330
70
  100
AcDbEntity
  8
0
  100
AcDbPolyline
  90
3
  70
0
  43
0.0
  10
0.0
  20
0.0
  10
100.0
  20
0.0
  10
100.0
  20
50.0

To compute the position of the control points from the fit points, you can consult this page (§24 & §25). In fact you need to reverse the Casteljau's algorithm (for Bezier curves; I don't know how it works for NURBS).

这篇关于如何使用拟合点创建 dxf 样条曲线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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