# Rotate p5 Vector and get angleBetweend

**URL:** <https://discourse.processing.org/t/rotate-p5-vector-and-get-anglebetweend/21215>\
**Category:** Beginners\
**Created:** [May 23, 2020, 7:54pm UTC](https://discourse.processing.org/t/rotate-p5-vector-and-get-anglebetweend/21215 "2020-05-23T19:54:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bouls631](https://avatars.discourse-cdn.com/v4/letter/b/6a8cbe/32.png) [@Bouls631](https://discourse.processing.org/u/Bouls631)\
**Post date:** [May 23, 2020, 7:54pm UTC](https://discourse.processing.org/t/rotate-p5-vector-and-get-anglebetweend/21215/1 "2020-05-23T19:54:28Z")

</div>

Hy every one,  
Here is my probleme i try to get angle between two Vectors in p5 when both Can moove. What i’ve done is :

```auto
Push();
Translate(...);
Bb= createVector (mouseX,mouseY)
RotateZ(x);
Aa= createVector(0,100);
Pop();
Cc=aa.angleBetween(bb);
x=mooving by an action/

```

So I get Cc for the first angle event I moove the mouse but if I change x it doesn’t change my angle.  
Thanks a lot for your help and sorry for language I’m french ;)``

---

<div class="post-metadata">

**Author:** ![tony](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tony/32/949_2.png) [@tony](https://discourse.processing.org/u/tony)\
**Post date:** [May 24, 2020, 6:11am UTC](https://discourse.processing.org/t/rotate-p5-vector-and-get-anglebetweend/21215/2 "2020-05-24T06:11:27Z")

</div>

In the future, please format your code with the `</>` button.

Interesting problem. Is this block of code inside `draw()`?

---

<div class="post-metadata">

**Author:** ![Bouls631](https://avatars.discourse-cdn.com/v4/letter/b/6a8cbe/32.png) [@Bouls631](https://discourse.processing.org/u/Bouls631)\
**Post date:** [May 24, 2020, 7:02am UTC](https://discourse.processing.org/t/rotate-p5-vector-and-get-anglebetweend/21215/3 "2020-05-24T07:02:19Z")

</div>

Yes it is in draw loop (sorry for the format now it’s edit)

---

<div class="post-metadata">

**Author:** ![Bouls631](https://avatars.discourse-cdn.com/v4/letter/b/6a8cbe/32.png) [@Bouls631](https://discourse.processing.org/u/Bouls631)\
**Post date:** [May 24, 2020, 12:23pm UTC](https://discourse.processing.org/t/rotate-p5-vector-and-get-anglebetweend/21215/4 "2020-05-24T12:23:17Z")

</div>

I found the solution because when i use rotation the vector have a rotation in the same time the 0 position change that why my angle is steel the same so I use this.

```auto
 push();
    translate(x,y);
     Bb= createVector(mouseX,mouseY); 
    Aa = p5.Vector.fromAngle (radians(x));//Changing by an action
    pop();
    
    Cc=Bb.angleBetween(Aa); 

```
