> For the complete documentation index, see [llms.txt](https://learnpython.strivemath.com/p5-python-web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learnpython.strivemath.com/p5-python-web/reference/3d-controls/translate.md).

# translate()

### Example

<figure><img src="/files/ZQuD0n6qfWc1Yrcdgw4H" alt=""><figcaption></figcaption></figure>

### Syntax

```
translate(x, y, [z])
```

<table><thead><tr><th width="134">Parameter</th><th>Description</th></tr></thead><tbody><tr><td>x</td><td>right-left translation</td></tr><tr><td>y</td><td>up-down translation</td></tr><tr><td>z</td><td>forward-backward translation (only in WEBGL mode)</td></tr></tbody></table>

### Full Example

<figure><img src="/files/f3WgOwT6GleoEffqWREI" alt=""><figcaption></figcaption></figure>

<details>

<summary>Example Full Code</summary>

```python
def setup():
  createCanvas(300,300, WEBGL)

def draw():
  background(255, 79, 132)
  fill(112, 88, 255)
  stroke(176, 235, 51)
  strokeWeight(2)

  torus(100, 25)
  translate(100*cos(frameCount), 0, 100*sin(frameCount))
  cone(50, 50)
```

</details>

### Description

It shifts the origin on the coordinate system. Calling `translate(50, 0, 0)` makes the point `(50, 0, 0)` the new origin. To illustrate:

* if one draws the point `(10, 0, 0)` **before** the translation, it appears 10 pixels to the right of the **original** center.
* if one draws the point `(10, 0, 0)` **after** the translation, it appears 10 pixels to the right of the **new** center, which is 60 pixels from the original center.

Like other transformations in the library ([rotateX()](/p5-python-web/reference/3d-controls/rotatex.md), [rotateY()](/p5-python-web/reference/3d-controls/rotatey.md), [rotateZ()](/p5-python-web/reference/3d-controls/rotatez.md)), this **effect is cumulative**. That is, calling `translate(10, 0, 0)` then `translate(20, 0, 0)` is the same as `translate(30, 0, 0)`

{% hint style="info" %}
Find these documents helpful? Let the people who made them help your child learn to code at [**Strivemath**](https://www.strivemath.com/)<mark style="color:blue;">**!**</mark>

We'd love to hear your Feedback/Comments [here](https://docs.google.com/forms/d/e/1FAIpQLSeqorBAGTya-YBRI-VFjJxtgQtCz3ucGDI96K96sNyuaGuvdw/viewform?usp=sf_link).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://learnpython.strivemath.com/p5-python-web/reference/3d-controls/translate.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
