# Rotation in relations to another object

**URL:** <https://discourse.processing.org/t/rotation-in-relations-to-another-object/14990>\
**Category:** Coding Questions\
**Created:** [October 28, 2019, 9:55pm UTC](https://discourse.processing.org/t/rotation-in-relations-to-another-object/14990 "2019-10-28T21:55:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![volous](https://avatars.discourse-cdn.com/v4/letter/v/a4c791/32.png) [@volous](https://discourse.processing.org/u/volous)\
**Post date:** [October 28, 2019, 9:55pm UTC](https://discourse.processing.org/t/rotation-in-relations-to-another-object/14990/1 "2019-10-28T21:55:26Z")

</div>

Hi, so i’m trying to rotate another shape in relations to another shape.  
but im not able to do so, how should i go about it(object/class based)?.

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [October 28, 2019, 10:59pm UTC](https://discourse.processing.org/t/rotation-in-relations-to-another-object/14990/2 "2019-10-28T22:59:50Z")

</div>

best you use  
`translate(x1,y1);`  
to move to the center of the first object  
and  
`rotate(ang);`  
and now draw second object

could now use  
` ang += dang;`  
change the rotation little bit in every draw loop

* * *

a general answer if you should use class is not possible  
it depends on  
++ will you later make many objects like a arrayList of class  
++ will they be of different properties ? like color, size…  
++ would using a class internal method clean up your code

+++ do you want to learn class ?

---

<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:** [October 30, 2019, 2:00am UTC](https://discourse.processing.org/t/rotation-in-relations-to-another-object/14990/3 "2019-10-30T02:00:51Z")

</div>

[https://processing.org/tutorials/transform2d/](https://processing.org/tutorials/transform2d/)

🙂
