---
title: "Transform"
description: "A 2D affine transform for rotation, translation, and scaling."
canonical_url: "https://www.rosette.dev/docs/api-reference/Transform"
markdown_url: "https://www.rosette.dev/docs/api-reference/Transform.md"
source_url: "https://github.com/PreFab-Photonics/rosette/blob/f086d7670645fd36c05362d696d442a2b2e74850/www/content/docs/api-reference/Transform.mdx"
docs_channel: "main"
docs_revision: "f086d7670645fd36c05362d696d442a2b2e74850"
---

# Transform

A 2D affine transform (rotation, translation, scaling).

Transforms encode geometric operations that can be applied to points. They
are used by `Instance` to position and orient cells, and can be composed
together with `then()`. `ArrayCopy` exposes the composed world-space
transform for an observed array copy.

```python
# 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



### `identity`

```python
identity() -> Transform
```

Return the identity transform (no change).



**Returns:** `Transform`





### `translate`

```python
translate(tx, ty) -> Transform
```

Create a translation transform.



- **`tx`** (`float`)

  Translation along the X axis.





- **`ty`** (`float`)

  Translation along the Y axis.





**Returns:** `Transform`





### `rotate`

```python
rotate(angle_deg) -> Transform
```

Create a rotation transform around the origin.



- **`angle_deg`** (`float`)

  Rotation angle in degrees (counter-clockwise).





**Returns:** `Transform`





### `scale_uniform`

```python
scale_uniform(s) -> Transform
```

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



- **`s`** (`float`)

  Scale factor.





**Returns:** `Transform`





### `scale`

```python
scale(sx, sy) -> Transform
```

Create an anisotropic scaling transform.



- **`sx`** (`float`)

  Scale factor along the X axis.





- **`sy`** (`float`)

  Scale factor along the Y axis.





**Returns:** `Transform`



## Methods



### `__init__`

```python
__init__() -> None
```

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



**Returns:** `None`





### `apply`

```python
apply(p) -> Point
```

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



- **`p`** (`Point`)

  The point to transform.





**Returns:** `Point`

The transformed point.





### `then`

```python
then(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.

```python
# 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
```



- **`other`** (`Transform`)

  The transform to apply after `self`.





**Returns:** `Transform`

A new composed transform.