# translate()

### Example

<figure><img src="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2Fcx9LOdyN2fBtrjZTQsOD%2Ftranslate.gif?alt=media&#x26;token=2b8642d7-0219-456e-ae82-239c33fd5bde" 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="https://768248463-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqbs7pgU3AVBY06Rl9M31%2Fuploads%2FJyi2wXqXANeI6OGQ64Ud%2Ftranslate%20full.gif?alt=media&#x26;token=e859e514-5e24-4898-821a-9f914625145b" 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()](https://learnpython.strivemath.com/p5-python-web/reference/3d-controls/rotatex), [rotateY()](https://learnpython.strivemath.com/p5-python-web/reference/3d-controls/rotatey), [rotateZ()](https://learnpython.strivemath.com/p5-python-web/reference/3d-controls/rotatez)), 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
