How to find angle between two lines?

Beulah A · Jan 11, 2024 · 2K views
Question
For example, there is line L1 between two points (x1,y1) and (x2,y2). Another line L2 between points (x1,y1) and (x3,y3). I want to find the angle between the lines L1, L2. How to find in MATLAB? I think in matlab there is no predefined function which performs the same.  
Expert Answer
Profile picture of Prashant Kumar
Prashant Kumar PhD Expert
Answered Nov 20, 2025
A more stable method that what Jos suggested is:
 
v_1 = [x2,y2,0] - [x1,y1,0];
v_2 = [x3,y3,0] - [x1,y1,0];
Theta = atan2(norm(cross(v_1, v_2)), dot(v_1, v_2));

 

Have a different question? Ask here

Get a Free Consultation or a Sample Assignment Review!