I have two lines: Line1 and Line2. Each line is defined by two points (P1L1(x1, y1), P2L1(x2, y2)
and P1L1(x1, y1), P2L3(x2, y3))
. I want to know t
Inner angle between 2 vectors (v1, v2) = arc cos ( inner product(v1,v2) / (module(v1) * module(v2)) ).
Where inner product(v1,v2) = xv1*xv2 + yv1*yv2
module(v) = sqrt(pow(xv,2) + pow(yv,2))
So, the answer of your question is implemented on the following example:
#define PI 3.14159258
int main()
{
double x1,y1,x2,y2,y3;
double m1, m2;
double mod1, mod2, innerp, angle;
cout << "x1 :";
cin >> x1;
cout << "y1 :";
cin >> y1;
cout << "x2 :";
cin >> x2;
cout << "y2 :";
cin >> y2;
cout << "y3 :";
cin >> y3;
m1 = atan((y2-y1)/(x2-x1)) * 180 / PI;
m2 = atan((y3-y1)/(x2-x1)) * 180 / PI;
mod1 = sqrt(pow(y2-y1,2)+pow(x2-x1,2));
mod2 = sqrt(pow(y3-y1,2)+pow(x2-x1,2));
innerp = (x2-x1)*(x2-x1) + (y2-y1)*(y3-y1);
angle = acos(innerp / (mod1 * mod2)) * 180 / PI;
cout << "m1 : " << m1 << endl;
cout << "m2 : " << m2 << endl;
cout << "angle : " << angle << endl;
}