# Independently translate and rotate

**URL:** <https://discourse.processing.org/t/independently-translate-and-rotate/25606>\
**Category:** Coding Questions\
**Created:** [November 22, 2020, 2:08pm UTC](https://discourse.processing.org/t/independently-translate-and-rotate/25606 "2020-11-22T14:08:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ginopalombi](https://avatars.discourse-cdn.com/v4/letter/g/5f8ce5/32.png) [@Ginopalombi](https://discourse.processing.org/u/Ginopalombi)\
**Post date:** [November 22, 2020, 2:08pm UTC](https://discourse.processing.org/t/independently-translate-and-rotate/25606/1 "2020-11-22T14:08:16Z")

</div>

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

Hi, how can I translate and rotate object independetly?  
I don’t want to translate the object after a translated object…

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [November 22, 2020, 2:15pm UTC](https://discourse.processing.org/t/independently-translate-and-rotate/25606/2 "2020-11-22T14:15:57Z")

</div>

you can isolate the different objects by using

pushMatrix and popMatrix around the rotation of one object.

example

```auto

float angle; 

void setup()
{
  size( 800, 800, P3D );
  noFill();
  stroke(255, 2, 2);
} // setup

void draw()
{
  background(0);
  lights();

  pushMatrix();
  noFill();
  stroke(255, 2, 2);
  translate(width/2-100, height/2+100, 0);
  rotateY(angle);
  box(60);
  angle+=.01;
  popMatrix();

  pushMatrix();
  stroke(111);
  fill(255, 2, 2);
  translate(width/2+100, height/2+100, 0);
  rotateX(angle);
  box(60);
  angle+=.01;
  popMatrix();
} // draw

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [November 22, 2020, 2:39pm UTC](https://discourse.processing.org/t/independently-translate-and-rotate/25606/3 "2020-11-22T14:39:05Z")

</div>

Hello,

[Processing.org](http://Processing.org) has tutorials, references, examples and other resources.

> **[2D Transformations \\ Processing.org](https://processing.org/tutorials/transform2d/)**

`:)`
