Transform
A 2D affine transform (rotation, translation, scaling).
Transforms encode geometric operations that can be applied to points. They
are used internally by CellRef and Instance to position and orient
cells, and can be composed together with then().
# Rotate 90 degrees then translate
t = Transform.rotate(90).then(Transform.translate(100, 0))
p = t.apply(Point(1, 0)) # Point(100, 1)Static constructors
funcidentity() -> TransformReturn the identity transform (no change).
Returns
Transformfunctranslate(tx, ty) -> TransformCreate a translation transform.
paramtxfloatTranslation along the X axis.
paramtyfloatTranslation along the Y axis.
Returns
Transformfuncrotate(angle_deg) -> TransformCreate a rotation transform around the origin.
paramangle_degfloatRotation angle in degrees (counter-clockwise).
Returns
Transformfuncscale_uniform(s) -> TransformCreate a uniform scaling transform (same factor for both axes).
paramsfloatScale factor.
Returns
Transformfuncscale(sx, sy) -> TransformCreate an anisotropic scaling transform.
paramsxfloatScale factor along the X axis.
paramsyfloatScale factor along the Y axis.
Returns
TransformMethods
func__init__() -> NoneCreate the identity transform. Equivalent to Transform.identity().
Returns
Nonefuncapply(p) -> PointApply the transform to a point, returning the transformed point.
parampPointThe point to transform.
Returns
PointThe transformed point.
functhen(other) -> TransformCompose this transform with another, returning a new transform that
applies self first, then other.
Transform composition reads left to right: a.then(b) means "apply a
first, then apply b to the result." This is the reverse of
mathematical matrix multiplication order but matches the natural reading
order for chained operations.
# Rotate 45 degrees, then translate by (10, 0)
t = Transform.rotate(45).then(Transform.translate(10, 0))
# Equivalent to:
p = Transform.rotate(45).apply(Point(1, 0)) # rotated
p = Transform.translate(10, 0).apply(p) # then translatedparamotherTransformThe transform to apply after self.
Returns
TransformA new composed transform.