# How Do you change the rotational origin for a shape?

**URL:** https://discourse.processing.org/t/how-do-you-change-the-rotational-origin-for-a-shape/22774
**Category:** Processing.py
**Tags:** homework
**Created:** [July 22, 2020, 4:17am UTC](https://discourse.processing.org/t/how-do-you-change-the-rotational-origin-for-a-shape/22774 "2020-07-22T04:17:29Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Learner](https://avatars.discourse-cdn.com/v4/letter/l/b782af/32.png) [@Learner](https://discourse.processing.org/u/Learner)
#### Post date: [July 22, 2020, 4:17am UTC](https://discourse.processing.org/t/how-do-you-change-the-rotational-origin-for-a-shape/22774/1 "2020-07-22T04:17:29Z")

</div>

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

Hello, I am learning processing through this intro course and we have an assignment where we need to make a triangle that spins and follows your mouse. I have figured all of the code except, because **rotate()** operates around the origin which I have set at **translate (mouseX, mouseY)**, it rotates around a vertices. I need to have the rotational origin on the side of the shape.

Here is my code, I have done so much research for the past 5 hours and I have finally decided to ask for help. I have no idea ho to fix this problem.

angle = 0

def setup ():  
size (600, 600)

def draw ():  
background (0)  
global angle

```
translate (mouseX , mouseY)
rotate (radians (angle))
fill(255)
beginShape ()
vertex(-50, 50)
vertex (50, 50)
vertex (0, 0)
endShape ()

angle += 0.5

```

---

<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: [July 22, 2020, 4:46am UTC](https://discourse.processing.org/t/how-do-you-change-the-rotational-origin-for-a-shape/22774/2 "2020-07-22T04:46:54Z")

</div>

After rotate make a 2nd translate that is with -50,0

---

<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: [July 22, 2020, 1:38pm UTC](https://discourse.processing.org/t/how-do-you-change-the-rotational-origin-for-a-shape/22774/3 "2020-07-22T13:38:00Z")

</div>

Hello,

Consider centering the shape.  
You have an x and y in your vertices and you can add an offset to these to center it.

I only centered the 0, 0 on the canvas so you could visualize the point of rotation:

```auto
angle = 0

def setup():
    size(200, 200);

def draw ():
    background (0)
    global angle
    
    translate (width/2, height/2) #0,0 is now center of canvas
    rotate (radians (angle))
    fill(255)
    beginShape ()
    vertex(-50, 50)
    vertex (50, 50)
    vertex (0, 0)
    endShape ()

    angle += 0.5

```

> [@Chrisir](#):
>
> After rotate make a 2nd translate that is with -50,0

This is not the correct axis or value but a place to start.  
It will work with the correct values; @Learner I will leave this with you to explore.

Some resources here:

> **[Python Mode for Processing](https://py.processing.org/)**
>
> Python Mode for Processing extends the Processing Development Environment with the Python programming language.

``:)‘’

---

<div class="post-metadata">

### Author: ![Learner](https://avatars.discourse-cdn.com/v4/letter/l/b782af/32.png) [@Learner](https://discourse.processing.org/u/Learner)
#### Post date: [July 22, 2020, 5:17pm UTC](https://discourse.processing.org/t/how-do-you-change-the-rotational-origin-for-a-shape/22774/4 "2020-07-22T17:17:17Z")

</div>

Hey! Thanks so much. I was able to figure it out! Your guy’s help is very much appreciated.
