I’m trying to calculate an angle, but it’s only working correctly at certain angles. I was thinking it might have to do with the Math.acos function, does anyone have any ideas why it might not be working?

```
var x = A-C;
var y = B-D;
var top = x*x+y*y;
var etan = Math.tan(E*3.1416/180);
var h = top/(2*x+2*y*etan);
var k = top/(2*y+2*x/etan);
var p = Math.sqrt(x*x+y*y);
var q = Math.sqrt(h*h+k*k);
var r = Math.sqrt(Math.pow(h-x,2)+Math.pow(k-y,2));
return Math.acos((r*r+q*q-p*p)/
(2*r*q))*180/3.1416;
```

This desmos graph is where I came up with the formulas, it works fine for all quadrants and situations, but it doesn’t work in all situations in flowlab; so it must be something wrong with my implementation in flowlab, not the calculations themselves.

This is the game. You can find the code in

connectionNode>Drag>DragInteraction>Blueprint