求解联立方程的算法 [英] Algorithm for solving simultaneous equations

查看:164
本文介绍了求解联立方程的算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个mfc应用程序,我需要推断两行是否相交。为此,我有2个方程:

  x = [-x1y2 + x2y1  - (x2-x1)y] / y1- y2 

y = [-x3y4 + x4y3 - (y3-y4)x] / x4-x3

但是我需要一种方法来同时解决这两个方程,我该怎么做?

解决方案

确定,假设 x1,x2,x3,x4,y1,y2,y3,y4 在这个过程中是常量,我们也可以把它写成

  x = ab * y 
y = cd * x

a =( - x1y2 + x2y1)/ y1-y2 等。

现在将第一行代入第二行给出

  y = cd *(ab * y)
y(1+ d * b)= cd * a
y =(cd * a)/(1 + d * b)

重新分配给 x = ab * y 给出结果的x部分

I'm making an mfc application in which I need to deduce if two lines intersect or not. For that I have the 2 equations:

x= [-x1y2 +x2y1 - (x2-x1)y ] / y1-y2

y= [-x3y4 +x4y3 - (y3-y4)x ] / x4-x3

But I need a way to solve these 2 equations simultaneously, How would I do that?

解决方案

OK, assuming that x1,x2,x3,x4,y1,y2,y3,y4 are constant inside the process we can also write this as

x=a-b*y
y=c-d*x

with a=(-x1y2+x2y1)/y1-y2 etc.

Now substituting the first line into the second gives

y=c-d*(a-b*y)
y(1+d*b)=c-d*a
y=(c-d*a)/(1+d*b)

resubstituting into x=a-b*y gives the x part of the result

这篇关于求解联立方程的算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆