> For the complete documentation index, see [llms.txt](https://primer2.dynamobim.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://primer2.dynamobim.org/zh-cn/8_coding_in_dynamo/8-2_geometry-with-design-script/6-surfaces.md).

# 曲面：内插、控制点、放样、旋转

对 NurbsCurve 的二维模拟是 NurbsSurface，与自由形式的 NurbsCurve 一样，可以使用两种基本方法构建 NurbsSurface：输入一组基点并在它们之间内插 Dynamo，然后明确指定曲面的控制点。当设计师确切知道曲面需要的形状或者设计需要曲面通过约束点时，内插曲面也与自由曲线一样非常有用。另一方面，由控制点创建的曲面对于各种平滑级别的探索式设计更为有用。

### 插值曲面

要创建插值曲面，只需生成与曲面形状近似的点的二维集合即可。集合必须是矩形，即不能出现锯齿。*NurbsSurface.ByPoints* 方法通过这些点构造曲面。

![](https://338946474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZkPl5tDHbu5X9VJTozDs%2Fuploads%2Fgit-blob-5b888ef38397cfd83e5d6126c3e451706cabb3a1%2FSurfaces_01.png?alt=media\&token=76bf81ad-7605-4aa1-8e44-003019c8410c)

```js
// python_points_1 is a set of Points generated with
// a Python script found in Chapter 12, Section 10

surf = NurbsSurface.ByPoints(python_points_1);
```

### 控制点曲面

也可以通过指定曲面的基本控制点来创建自由形式的 NurbsSurfaces。与 NurbsCurves 一样，控制点可以看作是表示具有直线段的四边形网格，这可以平滑到最终的曲面形式（取决于曲面的阶数）。要通过控制点创建 NurbsSurface，请为 *NurbsSurface.ByPoints* 添加两个附加参数，以指示基本曲线在曲面两个方向上的角度。

![](https://338946474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZkPl5tDHbu5X9VJTozDs%2Fuploads%2Fgit-blob-6b61c0756bff92c125d15deab7e21b33bdbe5542%2FSurfaces_02.png?alt=media)

```js
// python_points_1 is a set of Points generated with
// a Python script found in Chapter 12, Section 10

// create a surface of degree 2 with smooth segments
surf = NurbsSurface.ByPoints(python_points_1, 2, 2);
```

我们可以增加 NurbsSurface 的阶数，来更改生成的曲面几何图形：

![](https://338946474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZkPl5tDHbu5X9VJTozDs%2Fuploads%2Fgit-blob-87537ab964c3bf36f9310f2aee88dbe966c712eb%2FSurfaces_03.png?alt=media\&token=f99b5c9f-b68b-4131-a07a-9bea861b7fef)

```js
// python_points_1 is a set of Points generated with
// a Python script found in Chapter 12, Section 10

// create a surface of degree 6
surf = NurbsSurface.ByPoints(python_points_1, 6, 6);
```

### 放样曲面

就像可以通过在一组输入点之间内插来创建曲面一样，可以通过在一组基础曲线之间内插来创建曲面。这称为“放样”。放样曲线是使用 *Surface.ByLoft* 构造函数创建的，其中输入曲线集合作为唯一参数。

![](https://338946474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZkPl5tDHbu5X9VJTozDs%2Fuploads%2Fgit-blob-6845490881f84c706d829994393fdae282790a32%2FSurfaces_04.png?alt=media)

```js
// python_points_2, 3, and 4 are generated with
// Python scripts found in Chapter 12, Section 10

c1 = NurbsCurve.ByPoints(python_points_2);
c2 = NurbsCurve.ByPoints(python_points_3);
c3 = NurbsCurve.ByPoints(python_points_4);

loft = Surface.ByLoft([c1, c2, c3]);
```

### 旋转曲面

旋转曲面是通过绕中心轴扫掠基础曲线创建的附加类型的曲面。如果插值曲面是对插值曲线的二维模拟，则旋转曲面是对圆和圆弧的二维模拟。

旋转曲面由基本曲线指定，表示曲面的“边”；轴原点、曲面的基点；轴方向、中心“核心”方向；扫掠开始角；以及扫掠结束角。这些曲面用作 *Surface.Revolve* 构造函数的输入。

![](https://338946474-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZkPl5tDHbu5X9VJTozDs%2Fuploads%2Fgit-blob-4f46ee39d9da283c2edb05905751c70547f86629%2FSurfaces_05.png?alt=media\&token=21dcec96-36ce-42a3-a63b-d722c6c3706c)

```js
pts = {};
pts[0] = Point.ByCoordinates(4, 0, 0);
pts[1] = Point.ByCoordinates(3, 0, 1);
pts[2] = Point.ByCoordinates(4, 0, 2);
pts[3] = Point.ByCoordinates(4, 0, 3);
pts[4] = Point.ByCoordinates(4, 0, 4);
pts[5] = Point.ByCoordinates(5, 0, 5);
pts[6] = Point.ByCoordinates(4, 0, 6);
pts[7] = Point.ByCoordinates(4, 0, 7);

crv = NurbsCurve.ByPoints(pts);

axis_origin = Point.ByCoordinates(0, 0, 0);
axis = Vector.ByCoordinates(0, 0, 1);

surf = Surface.ByRevolve(crv, axis_origin, axis, 0,
    360);
```
