How to draw a line using y = mx +b in java?

前端 未结 3 1220
北恋
北恋 2021-01-29 01:45

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

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-29 02:11

    You also need to consider how to map from physical (x, y) coordinates to screen (u, v) coordinates.

    Transforming from Ax + By = C is mere high school algebra:

    1. Subtract Ax from both sides: By = C - Ax
    2. Divide both sides by B: y = (C/B) - (A/B)x
    3. By inspection, m = -(A/B) and b = (C/B). Obviously, B != 0.

提交回复
热议问题