# Not sure why rotation isn't giving certain values

**URL:** https://discourse.processing.org/t/not-sure-why-rotation-isnt-giving-certain-values/31035
**Category:** Beginners
**Created:** [July 4, 2021, 6:29am UTC](https://discourse.processing.org/t/not-sure-why-rotation-isnt-giving-certain-values/31035 "2021-07-04T06:29:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![LuckyDots](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@LuckyDots](https://discourse.processing.org/u/LuckyDots)
#### Post date: [July 4, 2021, 6:29am UTC](https://discourse.processing.org/t/not-sure-why-rotation-isnt-giving-certain-values/31035/1 "2021-07-04T06:29:06Z")

</div>

Okay so I’ve followed a tutorial on youtube for creating kaleidoscope type images which is from the following link [https://www.youtube.com/watch?v=R3C2giDfmO8](https://www.youtube.com/watch?v=R3C2giDfmO8)

the video is done in p5.js so im not surprised it hasn’t worked exactly as i thought it would.

can anyone help me understand why im not getting a regular pattern of rotation with this code?

```auto
float angle = 0;

void setup()
{
size(900, 900);
background(0);
}

void draw()
{

 translate(width/2, height/2);
  pushMatrix();
    
 
  scale(0.5);
  angle = 360 /12;
  for(float i = 0; i<12; i++){
  rotate(angle);
  
  if(mousePressed){
    noStroke();
    fill(255);
  ellipse(mouseX, mouseY, 5, 5);
  }
  
  }
  popMatrix();
}

```

There are minor differences between this sketch and the one in the video, namely that the drawing function is different and also the line ‘rotate(angle);’ has been changed from ‘rotate(angle\*i);’ the latter produced even less regular patterns which did not seem desirable

I got a little bit closer to my desired result using the following

```auto
float angle = 0;
float angle2;
void setup()
{
size(900, 900);
background(0);
}

void draw()
{

 translate(width/2, height/2);
  pushMatrix();
    
 
  scale(0.5);
  angle = 360 /12;
  angle2 = 16*sin(radians(angle));
  for(float i = 0; i<12; i++){
  rotate(angle2);
  
  if(mousePressed){
    noStroke();
    fill(255);
  ellipse(mouseX, mouseY, 5, 5);
  }
  
  }
  popMatrix();
}

```

any help would be greatly appreciated and i hope this is an acceptable posting format, please inform me if theres anything i can do to improve that.

---

<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 4, 2021, 7:32am UTC](https://discourse.processing.org/t/not-sure-why-rotation-isnt-giving-certain-values/31035/2 "2021-07-04T07:32:03Z")

</div>

> [@LuckyDots](#):
>
> rotate(angle);

use radians () here

Chrisir

---

<div class="post-metadata">

### Author: ![LuckyDots](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@LuckyDots](https://discourse.processing.org/u/LuckyDots)
#### Post date: [July 4, 2021, 8:07am UTC](https://discourse.processing.org/t/not-sure-why-rotation-isnt-giving-certain-values/31035/3 "2021-07-04T08:07:36Z")

</div>

you’re a genuis good sir, many, many thanks!

---

<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 4, 2021, 10:04am UTC](https://discourse.processing.org/t/not-sure-why-rotation-isnt-giving-certain-values/31035/4 "2021-07-04T10:04:11Z")

</div>

> [@LuckyDots](#):
>
> i hope this is an acceptable posting format, please inform me if theres anything i can do to improve that.

Hello,

Please format your code:  
[https://discourse.processing.org/faq#format-your-code](https://discourse.processing.org/faq#format-your-code)

Your second example already uses _radians()_ and you are well on the way:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/930205962dcf8dceac6b85ddf012262d937531c1.png)

If you work directly in radians you do not have to convert with the _radians()_ function:

```auto
//angle = 360 /12;
angle = TWO_PI/12;

//angle2 = 16*sin(radians(angle));
angle2 = 16*sin(angle);

```

The above could be simplified.

There are resources(tutorials, references, examples, etc.) here:  
_[processing.org](http://processing.org)_

And ready to run examples with the Processing IDE:

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/9/98f4062c98ca5a4b1654066fb0448455b55df3c0.png)

For starters:  
_[rotate() / Reference / Processing.org](https://processing.org/reference/rotate_.html)_

`:)`
