变换 Transformations · 6 个函数
平移、旋转、缩放与居中
| 参数 | 类型 | 说明 |
|---|---|---|
| axes | selector | { x | y | z | xy | xz | yz | xyz }—Axes to include in center calculation. |
The center operation moves the scope of the current shape to the center of the previous shape's scope. 'Previous shape' means the previous shape on the shape stack.
官方示例 · 点击展开
Lot-->
primitiveCube()
s(4,4,4)
t(-2,-2,-2)
SelCube
SelCube-->
[ color("#ff0000") s(1,1,1) center(x) X ]
[ color("#00ff00") s(1,1,1) center(y) X ]
[ color("#0000ff") s(1,1,1) center(z) X ]
[ color("#ffff00") s(1,1,1) center(xy) X ]
[ color("#ff00ff") s(1,1,1) center(xz) X ]
[ color("#00ffff") s(1,1,1) center(yz) X ]
[ color("#ffffff") s(1,1,1) center(xyz) X ]我方已验证示例:center(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule Lot --> primitiveQuad(7, 15) extrude(4) t(2, 0, 0) center(xyz) color(0.5, 0.5, 1)
r(center, xAngle, yAngle, zAngle)
| 参数 | 类型 | 说明 |
|---|---|---|
| xAngle | float | Angle in degrees to rotate about x- axis. |
| yAngle | float | Angle in degrees to rotate about y- axis. |
| zAngle | float | Angle in degrees to rotate about each z- axis. |
| center | selector | { scopeOrgin | scopeCenter }—The rotation center. scopeOrgin is the default. (used if no center selector is given). |
The r operation rotates the scope of the current shape around the pivot-axes in xyz order. The center of rotation is either the scopeOrigin (scope.t) of the current shape or the scopeCenter of the current shape.
Note:
r(x,y,z) is the same as rotate(rel,pivot,x,y,z)
官方示例 · 点击展开
height = 18
dy = 2
Lot-->
extrude(height)
split(y) { dy : r(0,
360*split.index/split.total, 0)
X }*height = 18
dy = 2
Lot-->
extrude(height)
split(y) { dy : r(scopeCenter, 0,
360*split.index/split.total, 0)
X }*我方已验证示例:rectify(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule Lot --> primitiveQuad(7, 15) extrude(4) r(0, 20, 0) rectify() color(0.7, 0.8, 0.9)
| 参数 | 类型 | 说明 |
|---|---|---|
| mode | selector | { abs | rel }—Absolute or relative mode. Absolute means the angles are set to the given value, relative means the angles are added. |
| coordSystem | selector | { scope | pivot | object | world }—Name of the coordinate system in which the following angles are given. |
| xAngle | float | Angles in degrees to rotate about the x-axis. |
| yAngle | float | Angles in degrees to rotate about the y-axis. |
| zAngle | float | Angles in degrees to rotate about the z-axis. |
The rotate operation rotates the scope around the scope origin. The angles can
be defined in any coordinate system, and the rotation can either be
absolute (= set the angles) or relative (= add the angles). This
operation manipulates the scope orientation (scope.r attribute).
官方示例 · 点击展开
Init-->
extrude(10)
t('0.2, 0, '0.3)
s('0.5, '1, '0.5)
rotate(abs, world, 0, 90, 0)我方已验证示例:rotate(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule Lot --> primitiveQuad(7, 15) extrude(4) rotate(0, 45, 0) color(0.6, 0.7, 0.8)
| 参数 | 类型 | 说明 |
|---|---|---|
| xSize | float | Size of the new scope for x-dimension. |
| ySize | float | Size of the new scope for y-dimension. |
| zSize | float | Size of the new scope for z-dimension. |
The s operation sets the size vector scope.s. The relative operator ' permits a convenient notation relative to the current shape's scope size:
s('sx,0,0) is equivalent to s(sx*scope.sx, 0, 0)
Negative sizes result in mirroring along the corresponding axes; this means the normals are inverted.
官方示例 · 点击展开
Lot--> extrude(10)
Lot--> extrude(10) s(5,5,5)
Lot-->
extrude(10)
s('0.5,'1,'1.5)我方已验证示例:平移 / 旋转 / 缩放(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule Lot --> primitiveQuad(7, 15) t(0,0.5,0) r(0,15,0) s(0.8,1,0.8) extrude(5) color(0.3,0.6,0.4)
| 参数 | 类型 | 说明 |
|---|---|---|
| tx | float | Amount to translate in the x direction. |
| ty | float | Amount to translate in the y direction. |
| tz | float | Amount to translate in the z direction. |
The t operation translates the scope by the vector (tx, ty, tz), i.e. the vector is added to scope.t. If the scope rotation is non-zero, then the passed translation vector is rotated around the pivot first, with angles (scope.rx, scope.ry, scope.rz). In other words, the translation is relative to the scope axes.
The relative operator ' permits a convenient notation relative to the scope size: t('tx,0,0) is equivalent to t(tx*scope.sx, 0, 0).
Note: t(x,y,z) is the same as translate(rel, scope, x, y, z).
官方示例(共 4 个,展示前 3 个) · 点击展开
A--> primitiveCube()
A--> primitiveCube() t(2,0,0)
A--> primitiveCube() t(2,0,0) r(0,30,0)
我方已验证示例:center(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule Lot --> primitiveQuad(7, 15) extrude(4) t(2, 0, 0) center(xyz) color(0.5, 0.5, 1)
| 参数 | 类型 | 说明 |
|---|---|---|
| mode | selector | { abs | rel }—Absolute or relative mode. Absolute means the position is set to the given value, relative means the translation is added. |
| coordSystem | selector | { scope | pivot | object | world }—Name of the coordinate system in which the following coordinates are given. |
| x,y,z | float | The coordinates define a position in the coordSystem to which the current shape's scope (scope.t) is set if the mode is abs or a translation vector to apply if the mode is rel. |
The translate operation translates the scope. The coordinates can be defined in any coordinate system, and the translation can either be absolute (= set to x,y,z) or relative (= add the x,y,z vector). This operation manipulates the scope position (scope.t attribute).
官方示例 · 点击展开
Init --> split(x) { '0.2 : split(z) { '0.2 : PP }* }*
PP --> 43% : primitiveCube()
X
translate(rel, world, 2, 0, 0)
color("#ff0000")
X
else : NILInit --> split(x) { '0.2 : split(z) { '0.2 : PP }* }*
PP --> 43% : primitiveCube()
X
translate(rel, object, 2, 0, 0)
color("#ff0000")
X
else : NIL我方已验证示例:learning case #175(verified_silver)· 点击展开代码 · 在 demo 中运行 →
/* union boolean operation example */
Lot -->
union { primitiveCube() | translate("rel", "scope", 1, 0, 0) primitiveCube() }
color("#888888")