Calculate angles between two intersecting lines using the slopes

44 views (last 30 days)
I have two slopes M1 and M2 that I wish to check the angle between them.
I was told that I can use the inverse tangent of (m1 - m2)/(1 + m1*m2)
Is it true, why? What is the difference if I use the (m1 - m2)/(1 - m1*m2) instead?

Accepted Answer

Roger Stafford
Roger Stafford on 14 Aug 2014
That formula comes from the trigonometric identity
tan(A-B) = (tan(A)-tan(B))/(1+tan(A)*tan(B))
Note: You have the sign wrong in atand((m1-m2)/(1-m1*m2))
It should be understood that taking the arctangent (atand) of your expression corresponds to rotating the line with slope m2 in both a counterclockwise and a clockwise direction around the intersection point until first encountering the line with slope m1. Going counterclockwise counts as a positive angle and clockwise is considered negative. Therefore your answer will lie between +90 and -90.

Sign in to comment.

More Answers (2)

Rick Rosson
Rick Rosson on 14 Aug 2014
phi = atan(m1) - atan(m2);

Amir on 14 Aug 2014
This image is from this video:
Hope this can clarify this for you.


Find more on Display Image in Help Center and File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!