6 views (last 30 days)

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
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')

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')

Opportunities for recent engineering grads.

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

Start Hunting!
## 1 Comment

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/572335-how-to-find-the-point-at-which-a-line-becomes-perpendicular-to-another-line#comment_954052

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/572335-how-to-find-the-point-at-which-a-line-becomes-perpendicular-to-another-line#comment_954052

Sign in to comment.