从2个笛卡尔坐标确定直线方程 [英] Determining a straight line equation from 2 cartesian coordinates

查看:142
本文介绍了从2个笛卡尔坐标确定直线方程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以很容易地在纸上做到这一点,但是在将其转化为语言方面有一点精神障碍(我会回答任何问题,但Java可能最简单).

I can do this on paper easily enough but have a bit of a mental block in getting this into a language (I'd take any answer but Java probably easiest).

我有两组点A点(xA,yA)和B点(xB,yB).

I have two sets of points Point A (xA, yA) and Point B (xB, yB).

知道这一点,并假设这两个都创建了一条直线图,我需要能够编写一个函数,给定xC,前提是我知道yC(显然,新点在同一条线上).

Knowing this, and assuming that these two create a straight line graph I need to be able write a function that will give me xC given that I would know yC (and, obviously that the new point is on the same line).

感谢所有帮助:)

亲切的问候

推荐答案

(yB-yA)/(xB-xA) = (yC - yA) / (xC-xA)

您现在只需要获取 xC ,即

xC = xA + ((yC - yA) * (xB-xA) / (yB-yA))

这是假设 yB yA 不同.如果它们相等,则如果 yC yA 不同,则没有解决方案;如果yC = yA

This is, assuming that yB is different from yA . If they are equal, then you have not solutions if yC is different from yA, and infinite solutions ( every xC works) if yC=yA

这篇关于从2个笛卡尔坐标确定直线方程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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