解决方案二线性方程

编程入门 行业动态 更新时间:2024-10-08 02:24:38
本文介绍了解决方案二线性方程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有两条线路UV和PQ,与U(15,10)V(50,25)和P(40,10)和Q(30,30)。

和我发现这两个点之间的交叉点。我形成两个线性方程为:

公式1:

的Ux + T(Vx的-UX)= Px活性+ S(QX-Px)的

EQ2

我想用C程序来获得T或s的值来解决这些方程。

我用 T 从第二个方程,并在第一个方程取代它得到一个公式来找到秒。但它没有工作了。我如何在程序中解决这个问题?

解决方案

int类型,SA,SB;

好吧, SA 是一个整数。

SA = 1 /((Vx的-UX)*(QY-PY) - (QX-Px)的*(VY-UY));

由于这些都是整数,你正在做使用整数运算整数的倒数。结果是无穷大,如果整数是零个,一个,如果它是一个,如果它是负一负一和零,如果它是别的。因此, SA 只有三个可能的值,或者你崩溃。

也许你应该考虑不使用整数运算?也许浮动SA; 和 SA = 1.0 /(...

I have two lines UV and PQ, with U(15,10) V(50,25) and P(40,10) and Q(30,30).

and i am finding a point of intersection between these two points. I am forming two linear equations for that:

eq 1:

Ux + t(Vx-Ux) = Px +s(Qx-Px)

eq2

I want to solve these equations using C program to get the value of either t or s.

I used the t from second equation and substituted it in first equation to get a formula to find s. But it did not work out. How can I solve this in a program?

解决方案

int s,sa,sb;

Okay, sa is an integer.

sa=1/((Vx-Ux)*(Qy-Py)-(Qx-Px)*(Vy-Uy));

Since these are all integers, you're taking the reciprocal of an integer using integer math. The result is infinity if the integer is zero, one if it's one, negative one if it's negative one, and zero if it's anything else. So sa only has three possible values, or you crash.

Perhaps you should consider not using integer math? Maybe float sa; and sa = 1.0 / (....

更多推荐

解决方案二线性方程

本文发布于:2023-11-29 01:56:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1644831.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:线性方程   解决方案

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!