Intersection of two Lines,which are passing through different slopes and two different points

1 次查看(过去 30 天)
Hi,
I have two Lines.
Line1 has slope m1 and it passes through point (x1,y1).
Line2 has slope m2 and it passes through points (x2,y2).
I would like to find the intersection point of these two lines.
Thanks in advance.

采纳的回答

KSSV
KSSV 2018-11-16
编辑:KSSV 2018-11-16
m1 = rand ; %slope of line1
P1 = rand(2,1) ; % line1 passes through this point
%
m2 = rand ; % slope of line 2
P2 = rand(2,1) ; % line 2 passes through this point
% Get c
c1 = P1(2)-m1*P1(1) ;
c2 = P2(2)-m2*P2(1) ;
%
% MAke line coords
x = linspace(-10,10) ;
%
x1 = x ;
y1 = m1*x1+c1 ;
%
x2 = x ;
y2 = m2*x2+c2 ;
figure
hold on
plot(x1,y1) ;
plot(x2,y2) ;
%
P = InterX([x1;y1],[x2;y2]) ;
plot(P(1),P(2),'*r')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by