Peyep CGA 函数参考变换 · 2026.1
版本首页查看 demo →
← 返回 2026.1 分类导航

变换 Transformations · 6 个函数

平移、旋转、缩放与居中

t native ✓ cpp-fast ✓ 已验证 406 条 · gold 官方文档 ↗ #
平移(官方简写操作 t)
签名(1 种重载)
t(tx, ty, tz)
参数说明
参数类型说明
txfloatAmount 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)
translate native ✓ cpp-fast ✓ 已验证 44 条 · silver 官方文档 ↗ #
平移形状
签名(1 种重载)
translate(mode, coordSystem, x, y, z)
参数说明
参数类型说明
modeselector
coordSystemselector{ scope | pivot | object | world }—Name of the coordinate system in which the following coordinates are given.
x,y,zfloatThe 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 : NIL
Init --> 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")
s native ✓ cpp-fast ✓ 已验证 409 条 · gold 官方文档 ↗ #
缩放:设置 scope 尺寸(官方简写操作 s)
签名(1 种重载)
s(xSize, ySize, zSize)
参数说明
参数类型说明
xSizefloatSizes 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 native ✓ cpp-fast ✓ 已验证 112 条 · gold 官方文档 ↗ #
旋转(官方简写操作 r)
签名(2 种重载)
r(xAngle, yAngle, zAngle)
r(center, xAngle, yAngle, zAngle)
参数说明
参数类型说明
xAnglefloatAngle in degrees to rotate about each axis.
centerselector
官方说明(英文原文)

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)
rotate native ✓ cpp-fast ✓ 已验证 7 条 · gold 官方文档 ↗ #
旋转形状 / scope
签名(1 种重载)
rotate(mode, coordSystem, xAngle, yAngle, zAngle)
参数说明
参数类型说明
modeselector
coordSystemselector{ scope | pivot | object | world }—Name of the coordinate system in which the following angles are given.
xAnglefloatAngles 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)
center native ✓ cpp-fast ✓ 已验证 195 条 · gold 官方文档 ↗ #
把形状居中到指定坐标轴
签名(1 种重载)
center(axes)
参数说明
参数类型说明
axesselector{ 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)