How can I change the angle of a vector when hitting an obstacle

So, my issue concerns vectors, I don’t know where I’m going with that case. I’m building a pandemic simulation (using Javascript and the library p5.js), and I’m trying to add a lockdown feature. Here …

Getting the angle from a direction vector?

I have this simple function to set an angle for a vector. It effectively gets the vector’s current magnitude (length), calulates the angle and converts the angle from radians to degrees. Then I apply the angle to X and Y, lastly multiplying the vector by it’s original magnitude. However I am unsure how to obtain (get) an angle from a Vector. Below is my attempt: This attempt doesn’t return any value except 0 or -1. Any suggestions? Edit: Correct method: Answer