Slope of line intersecting with y axis
3 次查看(过去 30 天)
显示 更早的评论
Hi,
I am trying to caluclate the slope of a line intersecting with one of the axes. I do understand that, as shown in the figure below, the slopw in case (a) is the
where θ is the angle between the line and the x axis. But what about case (b)? What is the slope when the line intersects with the y axis and the angle θ becomes between the line and the y axis. is the slope becomes the
?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1152923/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1152928/image.png)
% case a
slope_a = tan(theta) % or y2-y1/x2-x1
%case b
slope_b = cot(theta) % or x2-x1/y2-y1
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1152933/image.png)
Thanks.
0 个评论
回答(1 个)
John D'Errico
2022-10-11
编辑:John D'Errico
2022-10-11
What has this to do with MATLAB?
The axis has NOTHING to do with the slope!!!!
The slope in both cases is (y2 - y1)/(x2 - x1). Which axis a line intersects is completely irrelevant. In fact, do you see the line ALWAYS intersects both axes, unless the line is exactly horizontal or vertical. In the case of a vertical line of course, the slope is undefined.
How you define the ANGLE a line intersects with an axis is irrelevant, as slope is not represented by an angle. Yes, you can compute that angle, but then surely you would recognize that the angle a line makes when it intersects with the two axes is always given by the angles of a right triangle, and therefore one angle is 90 degrees minus the other?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Visual Exploration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!