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() -> Transform

Return the identity transform (no change).

Returns

Transform
functranslate(tx, ty) -> Transform

Create a translation transform.

paramtxfloat

Translation along the X axis.

paramtyfloat

Translation along the Y axis.

Returns

Transform
funcrotate(angle_deg) -> Transform

Create a rotation transform around the origin.

paramangle_degfloat

Rotation angle in degrees (counter-clockwise).

Returns

Transform
funcscale_uniform(s) -> Transform

Create a uniform scaling transform (same factor for both axes).

paramsfloat

Scale factor.

Returns

Transform
funcscale(sx, sy) -> Transform

Create an anisotropic scaling transform.

paramsxfloat

Scale factor along the X axis.

paramsyfloat

Scale factor along the Y axis.

Returns

Transform

Methods

func__init__() -> None

Create the identity transform. Equivalent to Transform.identity().

Returns

None
funcapply(p) -> Point

Apply the transform to a point, returning the transformed point.

parampPoint

The point to transform.

Returns

Point

The transformed point.

functhen(other) -> Transform

Compose 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 translated
paramotherTransform

The transform to apply after self.

Returns

Transform

A new composed transform.

On this page