# How to find the point at which a line becomes perpendicular to another line?

6 views (last 30 days)
Cnell on 29 Jul 2020
Commented: Cnell on 30 Jul 2020
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.

#### 1 Comment

KSSV on 29 Jul 2020

KSSV on 29 Jul 2020
Edited: KSSV on 29 Jul 2020
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')

Cnell on 29 Jul 2020
C should always be [0 0]. Could you clarify bc I am having issues with the points
x = [150 50]
y = [0 50]
KSSV on 30 Jul 2020
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')
Cnell on 30 Jul 2020
Actually, it was the scaling of the plot :)