2

I am working on a project for my seventh grade math class and I was wondering how would I calculate the Y-Intercept of a graph with two points knowing the position of the two points. Here is what I have:

Option Explicit
Dim X1, X2, Y1, Y2, Y, X, S
X1=InputBox("Enter X1")
Y1=InputBox("Enter Y1")
X2=InputBox("Enter X2")
Y2=InputBox("Enter Y2")
X=X2-X1
Y=Y2-Y1
S=Y/X
MsgBox("The slope of [" & X1 & "," & Y1 & "] and [" & X2 & "," & Y2 & "] is " & S)
MsgBox("Equation: (" & Y2 & "-" & Y1 & ") / (" & X2 & "-" & X1 & ") = " & S)

I don't know how to compute (X1, Y1) and (X2, Y2) into the Y-Intercept.

4

3 回答 3

3

第一步是找到斜率。看起来你正在用 S = Y/X 做。

之后很容易:

y 截距 = Y1 - S*X1

于 2013-11-13T17:07:18.657 回答
0

通过(X1,Y1)具有斜率的点的线S

y(x) = Y1 + S*(x-X1)

过两点的(X1,Y1)线(X2,Y2)

y(x) = Y1 + (Y2-Y1)*(x-X1)/(X2-X1)

直线与 y 轴相交于

Y0 = (X2*Y1-X1*Y2)/(X2-X1)

xy平面上线的另一种形式是

(X2-X1)*y - (Y2-Y1)*x = X2*Y1-X1*Y2 = constant
于 2013-11-13T18:55:18.570 回答
0

请试试这个

p1 = InputBox("Enter X1,Y1","Y Intercept")
p2 = InputBox("Enter X2,Y2","Y Intercept")
x1 = Left(p1,InStr(p1,",") -  1)
y1 = Replace(p1,x1 & ",","")
x2 = Left(p2,InStr(p2,",") -  1)
y2 = Replace(p2,x2 & ",","")
MsgBox "Y Intercept = " & y2 - (((y2-y1)/(x2-x1)) * x2)
于 2016-10-06T03:45:49.970 回答