# Rotation and Easing

**URL:** <https://discourse.processing.org/t/rotation-and-easing/5704>\
**Category:** Coding Questions\
**Created:** [November 19, 2018, 8:11am UTC](https://discourse.processing.org/t/rotation-and-easing/5704 "2018-11-19T08:11:27Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [November 20, 2018, 3:12am UTC](https://discourse.processing.org/t/rotation-and-easing/5704/4 "2018-11-20T03:12:39Z")

</div>

@phoebus , i could not stop play with that excellent idea,  
but i could not solve the problem, but thanks to  
@brunoruchiga can now show this version:

```auto
// https://discourse.processing.org/t/rotation-and-easing/5704
PVector myMouse = new PVector();
float rot = 0, alpha, dalpha, easing = 0.03;
// __________________________________________________________
void setup() {
  size(600, 600);
  stroke(120,120,120);
}
// __________________________________________________________
void draw() {
  myMouse.set( mouseX, mouseY, 0);
  myMouse.sub(width/2, height/2, 0);
  alpha = myMouse.heading();
  dalpha = (alpha-rot)/PI;
  if ( dalpha < -1) rot -= TWO_PI; // @brunoruchiga
  else if ( dalpha > 1 ) rot += TWO_PI;
  rot += (alpha -rot) * easing; // @phoebus
  // draw
  background(0, 0, 50);
  translate(width/2, height/2); 
  fill(170, 170, 0);
  ellipse(0, 0, 400, 400);
  rotate (rot);
  fill(170, 170, 170);
  ellipse(150, 0, 100, 100);
}

```

---

_[View the full topic](https://discourse.processing.org/t/rotation-and-easing/5704)._
