First and foremost let me say I am an absolutely atrocious at maths, please bear with me.
I'm trying to calculate the angle between two points on a circle, the two points being the distance the user has dragged in a certain amount of time.
This is what I have so far:
intervalId = setInterval(function(){
if(p1x != undefined){
p2x = Xpos;
}
if(p1y != undefined){
p2y = Ypos;
}
if( p1x != p2x || p1y != p2y ){
p1a = p1x - wheelMiddleVer;
p1b = p1y - wheelMiddleHor;
a = Math.sqrt((p1a * p1a) + (p1b * p1b));
p2a = p2x - wheelMiddleVer;
p2b = p2y - wheelMiddleHor;
b = Math.sqrt((p2a * p2a) + (p2b * p2b));
u = p1x - p2x;
v = p1y - p2y;
c = Math.sqrt((u * u) + (v * v));
}
p1x = Xpos;
p1y = Ypos;
}, 1000);
I'm not sure how to finish it. I have tried using the cos A = (b^2 + c^2 - a^2)/2bc formula but it's not worked out for me. I will appreciate your input on this. If I can make the question clearer let me know.
First find the difference between the start point and the end point.
Then calculate the angle using arctan
First of all, keep in mind that most of the languages have an invert Y axis. Meaning the higher the point on the scale -> the smaller it Y value is.
As for your question, you should use arctan: