问题描述
所以我有一个解决线性方程组的程序,但这不相关。那么我的程序会以下列形式传递两个线性方程:y = mx + b。我不知道如何使用Graphics2D绘制图形,我在解决它时遇到了一些麻烦。现在我不知道所以我没有可以告诉你的代码,但我可以告诉你:
So I have a program that solves a system of linear equations, but that is not relevant. So what happens is that my program pass two linear equations in the form of: y = mx +b. I do not know how I would graph this using Graphics2D, I am having some trouble figuring it out. Right now I have no idea so I have no code that I could show you, but I can tell you that:
- 我的程序正确将Ax + By = C转换为y = mx + B
- 在某些代码中使用drawLine()方法显示示例会很有帮助
推荐答案
在代码中绘制一条线时,需要从点 A $ c绘制$ c>指向
B
。 (一行段)
When you draw a line in code, you need to draw from point A
to point B
. (a line segment)
选择一个点 A
来启动该行,然后从 A
抽取到(AX + dx,AY + m * dx)
,其中 dx
是所需的行宽。
Pick a point A
to start the line from, then draw from A
to (A.X + dx, A.Y + m * dx)
, where dx
is the desired width of the line.
例如,您可能需要 A
是你所在地区的一角, dx
是该地区的宽度。
For example, you may want A
to be one corner of your area, and dx
to be the width of the area.
这篇关于如何在java中使用y = mx + b绘制一条线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!