# Rotating an object need to know the position of the points globally

**URL:** <https://discourse.processing.org/t/rotating-an-object-need-to-know-the-position-of-the-points-globally/18270>\
**Category:** Coding Questions\
**Created:** [March 1, 2020, 6:50am UTC](https://discourse.processing.org/t/rotating-an-object-need-to-know-the-position-of-the-points-globally/18270 "2020-03-01T06:50:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pixelfixation](https://avatars.discourse-cdn.com/v4/letter/p/9de053/32.png) [@Pixelfixation](https://discourse.processing.org/u/Pixelfixation)\
**Post date:** [March 1, 2020, 6:50am UTC](https://discourse.processing.org/t/rotating-an-object-need-to-know-the-position-of-the-points-globally/18270/1 "2020-03-01T06:50:21Z")

</div>

Hey! I am making a simulation for my calc 1 professor. He wants a simulation of a ferris wheel where I can check the positions of the passengers on the Y axis at different points in time during the rotations. What I need help with is how to arrange ferris wheel cabins (just a simple ellipse) in a circular pattern around the ferris wheels hub, and how to change their x and y positions to make them rotate manually.

I looked into just using rotations but it seems like if I use the translate and rotate methods I won’t be able to store and view the x and y positions of the cabins. I need to be able to do this freely to have the simulation have any worth.

Anybody know how to do this or can point me to a tutorial?

---

<div class="post-metadata">

**Author:** ![manno](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@manno](https://discourse.processing.org/u/manno)\
**Post date:** [March 1, 2020, 9:17am UTC](https://discourse.processing.org/t/rotating-an-object-need-to-know-the-position-of-the-points-globally/18270/2 "2020-03-01T09:17:18Z")

</div>

Hi,

I’d say some basic trigonometry is best here.

**The ferris wheel**  
It has a center point. Store that in a var (using [createVector](https://p5js.org/reference/#/p5/createVector) maybe).  
It also has a radius. Another var.

**Cabins**  
Each cabin has a rotation or angle property, describing its position on the circle.  
And probably a passenger count.  
There are a number of cabins, so probably they are represented by an array of objects.

With the above, the position of each cabin can be described as:

x: ferris wheel center X + Math.cos(angle of cabin in radians) \* radius of ferris wheel  
y: ferris wheel center Y + Math.sin(angle of cabin in radians) \* radius of ferris wheel

(OTTOMH, but I think I made no typos 😀 )

(edit)  
of course you need to change/increment the angle of each cabin every draw call so that they rotate around the hub.

Kind regards,  
Manno

---

<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:** [March 1, 2020, 11:42am UTC](https://discourse.processing.org/t/rotating-an-object-need-to-know-the-position-of-the-points-globally/18270/3 "2020-03-01T11:42:47Z")

</div>

there is a tutorial about trigonometry [https://www.processing.org/tutorials/](https://www.processing.org/tutorials/)

all about cos and sin…

---

<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:** [March 1, 2020, 5:20pm UTC](https://discourse.processing.org/t/rotating-an-object-need-to-know-the-position-of-the-points-globally/18270/4 "2020-03-01T17:20:31Z")

</div>

Hello,

Welcome to the Processing community.

I have found vectors to be very useful but there is a learning curve:  
[https://p5js.org/reference/#/p5.Vector](https://p5js.org/reference/#/p5.Vector)

A Processing tutorial:  
[https://www.processing.org/tutorials/pvector/](https://www.processing.org/tutorials/pvector/)

`:)`

---

<div class="post-metadata">

**Author:** ![Pixelfixation](https://avatars.discourse-cdn.com/v4/letter/p/9de053/32.png) [@Pixelfixation](https://discourse.processing.org/u/Pixelfixation)\
**Post date:** [March 1, 2020, 8:51pm UTC](https://discourse.processing.org/t/rotating-an-object-need-to-know-the-position-of-the-points-globally/18270/5 "2020-03-01T20:51:54Z")

</div>

Thanks guys! I got it working!
