Calculate angles between two intersecting lines using the slopes if one slope is infinite

2 views (last 30 days)
For example m1=√3/2 & m2 = infinity

Answers (1)

Star Strider
Star Strider on 6 Mar 2016
An infinite slope is a vertical line, so this is straightforward:
m1 = sqrt(3/2);
thr = pi/2 - atan2(m1, 1);
thd = thr * 180/pi;
figure(1)
plot([0 0], [0 1.5])
hold on
plot([0 1], [0, m1])
hold off
grid
axis([-0.1 1 -0.1 1.5])
axis equal
text(0.35, 1, sprintf('\\leftarrow \\theta = %.2f\\circ \\rightarrow', thd), 'Rotation',-thd, 'HorizontalAlignment','center')

Community Treasure Hunt

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

Start Hunting!