How to find the point at which a line becomes perpendicular to another line?
2 次查看(过去 30 天)
显示 更早的评论
In the figure, the first two points are:
x = [150 0]
y = [0 150]
So, the line was plotted using
line(x,y,'color','red');
For a given red line, how can you find the point at which a line from the center becomes perpendicular to it? I just need the x value.
You can also think of it as the point where the radius value decreases then increases if you were to follow the red line from the first point to the second.
采纳的回答
KSSV
2020-7-29
编辑:KSSV
2020-7-29
x = [150 0]
y = [0 150]
C = [0 0] ;
% get the line ax+by+c = 0
slope = diff(y)/diff(x) ; % slope
a = slope ;
b = -1 ;
c = y(1)-slope*x(1) ;
% foot of the perpendicular
m = -(a*C(1)+b*C(2)+c)/(a^2+b^2) ;
h = a*m+C(1) ;
k = b*m+C(2) ;
line(x,y,'color','red');
hold on
line([C(1) h],[C(2) k],'color','black')
line([h h],[k 0],'color','black')
plot(h,k,'*g')
5 个评论
KSSV
2020-7-30
This is not issue. This is correct. You need to extend the straight line..basic high school maths
% extend the straight line
x = 0:150 ;
y = -a/b*x-c/b ;
plot(x,y,'-b')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!