变换 Transformations · 6 个函数
平移、旋转、缩放与居中
| 参数 | 类型 | 说明 |
|---|---|---|
| tx | float | Amount to translate in each direction. |
The t operation translates the current shape (it adds the translation vector (tx, ty, tz) to scope.t).
The translation is relative to the scope axes. If the scope is rotated, the given translation vector is rotated accordingly before it is applied.
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 | |
| 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 current shape (it manipulates the scope position scope.t). 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).
官方示例 · 点击展开
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")
| 参数 | 类型 | 说明 |
|---|---|---|
| xSize | float | Sizes of the new scope dimensions. |
The s operation resizes the current shape (it 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)
r(center, xAngle, yAngle, zAngle)
| 参数 | 类型 | 说明 |
|---|---|---|
| xAngle | float | Angle in degrees to rotate about each axis. |
| center | selector |
The r operation rotates the current shape around the pivot-axes in xyz order (it adds the given angles to scope.r). If the rotation center is scopeCenter, it also updates scope.t to keep the center fixed.
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 | |
| 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 each axis. |
The rotate operation rotates the current shape (it manipulates the scope orientation scope.r). The angles can be defined in any coordinate system, and the rotation can either be absolute (= set the angles) or relative (= add the angles).
官方示例 · 点击展开
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)
| 参数 | 类型 | 说明 |
|---|---|---|
| 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)