Rotate p5 Vector and get angleBetweend

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 :

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 ;)``

1 Like

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

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

1 Like

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

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.

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