Spline¶ 样条
The SPLINE entity (DXF Reference) is a 3D curve, all coordinates have to be 3D
coordinates even if the spline is just a 2D planar curve.
SPLINE 实体(DXF 参考)是一个 3D 曲线,所有坐标即使是 2D 平面曲线也必须是 3D 坐标。
The spline curve is defined by control points, knot values and weights. The
control points establish the spline, the various types of knot vector determines
the shape of the curve and the weights of rational splines define how
strong a control point influences the shape.
样条曲线由控制点、节点值和权重定义。控制点建立样条,不同类型的节点矢量决定曲线的形状,而有理样条的权重则定义了一个控制点对形状影响的强度。
A SPLINE can be created just from fit points - knot values and weights are
optional (tested with AutoCAD 2010). If you add additional data,
be sure you know what you do, because invalid data may invalidate
the whole DXF file.
可以仅从拟合点创建样条曲线 - 节点值和权重是可选的(已在 AutoCAD 2010 中测试)。如果你添加额外的数据,请确保你知道你在做什么,因为无效的数据可能会使整个 DXF 文件无效。
The function ezdxf.math.fit_points_to_cad_cv()
calculates control
vertices from given fit points. This control vertices define a cubic
B-spline which matches visually the SPLINE entities created by BricsCAD and
AutoCAD from fit points.
函数 ezdxf.math.fit_points_to_cad_cv()
从给定的拟合点计算控制顶点。 这些控制顶点定义了一个三次 B 样条,它在视觉上与 BricsCAD 和 AutoCAD 从拟合点创建的 SPLINE 实体相匹配。
See also 另请参见
Department of Computer Science and Technology at the Cambridge University
剑桥大学计算机科学与技术系
Subclass of 子类 |
|
DXF type DXF 类型 |
|
Factory function 工厂函数 |
see table below 请参见下面的表格 |
Inherited DXF attributes 继承的 DXF 属性 |
|
Required DXF version 所需 DXF 版本 |
DXF R2000 ( |
Factory Functions¶
工厂函数
Basic spline entity 基本样条实体 |
|
Spline control frame from fit points |
|
Open uniform spline 开放均匀样条 |
|
Closed uniform spline 封闭均匀样条 |
|
Open rational uniform spline |
|
Closed rational uniform spline |
|
- class ezdxf.entities.Spline¶
All points in WCS as (x, y, z) tuples
所有点在 WCS 中作为(x, y, z)三元组-
dxf.degree¶
度 Degree of the spline curve (int).
样条曲线的度数(整数)。
-
dxf.flags¶
dxf.标志 Bit coded option flags, constants defined in
ezdxf.lldxf.const
:
位编码选项标志,常量定义在ezdxf.lldxf.const
:dxf.flags
Value 价值
Description 描述
CLOSED_SPLINE
1
Spline is closed 样条已关闭
PERIODIC_SPLINE
2
RATIONAL_SPLINE
4
PLANAR_SPLINE
8
LINEAR_SPLINE
16
planar bit is also set
平面位也被设置
- dxf.n_knots¶
Count of knot values (int), automatically set by ezdxf (read only)
结点值计数(int),由ezdxf自动设置(只读)
- dxf.n_fit_points¶
Count of fit points (int), automatically set by ezdxf (read only)
拟合点数(整数),由 ezdxf 自动设置(只读)
-
dxf.n_control_points¶
dxf.n_control_points¶ Count of control points (int), automatically set by ezdxf (read only)
控制点的数量(整数),由 ezdxf 自动设置(只读)
-
dxf.knot_tolerance¶
dxf.knot_tolerance¶ Knot tolerance (float); default is 1e-10
结容差(浮点数);默认值为 1e-10
- dxf.fit_tolerance¶
Fit tolerance (float); default is 1e-10
配合公差(浮动);默认值为 1e-10
-
dxf.control_point_tolerance¶
dxf.control_point_tolerance Control point tolerance (float); default is 1e-10
控制点公差(浮点数);默认值为 1e-10
-
closed¶
关闭 True
if spline is closed. A closed spline has a connection from the last control point to the first control point. (read/write)
如果样条曲线是闭合的,则为True
。闭合样条曲线从最后一个控制点连接到第一个控制点。(读/写)
- control_points¶
VertexArray
of control points in WCS.
在VertexArray
中作为控制点的WCS。
- fit_points¶
VertexArray
of fit points in WCS.
在 WCS 中的拟合点的 VertexArray。
-
knots¶
结节 Knot values as
array.array('d')
.
Knot 值为array.array('d')
。
-
weights¶
权重 Control point weights as
array.array('d')
.
控制点权重为array.array('d')
。
- control_point_count() int ¶
Count of control points. 控制点数量。
- fit_point_count() int ¶
Count of fit points. 适配点的数量。
- knot_count() int ¶
Count of knot values. 结点值的数量。
- construction_tool() BSpline ¶
Returns the construction tool
ezdxf.math.BSpline
.
返回构造工具ezdxf.math.BSpline
。
- apply_construction_tool(s) Spline ¶
Apply SPLINE data from a
BSpline
construction tool or from ageomdl.BSpline.Curve
object.
应用来自BSpline
构建工具或来自geomdl.BSpline.Curve
对象的 SPLINE 数据。
-
flattening(distance: float, segments: int = 4) Iterator[Vec3] ¶
展平距离: float, 分段: int = 4Iterator[Vec3] ¶ Adaptive recursive flattening. The argument segments is the minimum count of approximation segments between two knots, if the distance from the center of the approximation segment to the curve is bigger than distance the segment will be subdivided.
自适应递归展平。参数分段是两个节点之间近似分段的最小数量,如果从近似分段的中心到曲线的距离大于距离,则分段将被细分。- Parameters 参数:
distance – maximum distance from the projected curve point onto the segment chord.
distance – 投影曲线点到线段弦的最大距离。segments – minimum segment count between two knots
segments – 两个节点之间的最小段数
- set_open_uniform(control_points: Sequence[UVec], degree: int = 3) None ¶
Open B-spline with a uniform knot vector, start and end at your first and last control points.
带有均匀节点矢量的开放 B 样条,起点和终点为您的第一个和最后一个控制点。
- set_uniform(control_points: Sequence[UVec], degree: int = 3) None ¶
B-spline with a uniform knot vector, does NOT start and end at your first and last control points.
具有均匀节点向量的 B 样条,并不从第一个和最后一个控制点开始和结束。
- set_closed(control_points: Sequence[UVec], degree=3) None ¶
Closed B-spline with a uniform knot vector, start and end at your first control point.
使用均匀节点向量的封闭 B 样条,从第一个控制点开始和结束。
- set_open_rational(control_points: Sequence[UVec], weights: Sequence[float], degree: int = 3) None ¶
Open rational B-spline with a uniform knot vector, start and end at your first and last control points, and has additional control possibilities by weighting each control point.
带有均匀节点向量的开放有理 B 样条,在第一个和最后一个控制点处开始和结束,并通过加权每个控制点具有额外的控制可能性。
- set_uniform_rational(control_points: Sequence[UVec], weights: Sequence[float], degree: int = 3) None ¶
Rational B-spline with a uniform knot vector, does NOT start and end at your first and last control points, and has additional control possibilities by weighting each control point.
带有均匀节点向量的有理 B 样条不会在第一个和最后一个控制点开始和结束,并且通过对每个控制点赋予权重具有额外的控制可能性。
- set_closed_rational(control_points: Sequence[UVec], weights: Sequence[float], degree: int = 3) None ¶
Closed rational B-spline with a uniform knot vector, start and end at your first control point, and has additional control possibilities by weighting each control point.
闭合有理 B 样条具有均匀的节点向量,从第一个控制点开始和结束,并通过对每个控制点加权提供额外的控制可能性。
- transform(m: Matrix44) Spline ¶
Transform the SPLINE entity by transformation matrix m inplace.
通过转换矩阵m原地转换 SPLINE 实体。
- classmethod from_arc(entity: DXFGraphic) Spline ¶
Create a new SPLINE entity from a CIRCLE, ARC or ELLIPSE entity.
从圆、弧或椭圆实体创建一个新的样条实体。The new SPLINE entity has no owner, no handle, is not stored in the entity database nor assigned to any layout!
新的 SPLINE 实体没有所有者,没有句柄,未存储在实体数据库中,也未分配给任何布局!
-
dxf.degree¶