求出两条直线的交点

2024-12-16 03:21:05
推荐回答(2个)
回答1:

因(x0,y0)在过两个点(x1,y1),(x2,y2)的直线上,所以三点在一直线上,
(y0-y1)/(x0-x1)=(y1-y2)/(x1-x2)
又因(x0,y0)在过两个点(x3,y3),(x4,y4)的直线上,所以三点在一直线上,
(y0-y3)/(x0-x3)=(y3-y4)/(x3-x4)

y0-y1=[(y1-y2)/(x1-x2)](x0-x1)=[(y1-y2)/(x1-x2)]x0-[(y1-y2)/(x1-x2)]x1
y0-y3=[(y3-y4)/(x3-x4)](x0-x3)=[(y3-y4)/(x3-x4)]x0-[(y3-y4)/(x3-x4)]x3

[(y1-y2)/(x1-x2)-(y3-y4)/(x3-x4)]x0=[(y1-y2)/(x1-x2)]x1-[(y3-y4)/(x3-x4)]x3+y3-y1

x0=[(y1-y2)x1/(x1-x2)-(y3-y4)x3/(x3-x4)+y3-y1]/[(y1-y2)/(x1-x2)-(y3-y4)/(x3-x4)]
=[(y1-y2)x1(x3-x4)-(y3-y4)x3(x1-x2)+(y3-y1)(x1-x2)(x3-x4)]/[(y1-y2)(x3-x4)-(y3-y4)(x1-x2)]

y0=

回答2:

第一条直线方程y-y1=(y2-y1)/(x2-x1) *(x-x1)
第二条直线方程y-y3=(y4-y3)/(x4-x3) *(x-x3)
联立两个方程,求出交点即可
表示出来很复杂,就不写出来了