The straight line equation y=kx+b is given two points a, b. Find the coordinates x, y of any point in the middle of ab

Reference article
Slope How to find
the known slope and the coordinates of another point, how to find the coordinates of another point
Triangle slope
DirectX C++ 3D Programming Basics 5 [Triangle rasterization] Self-made Chinese characters
Straight line equation formula y=kx+b
k slope, b intercept
known point a(1,2) b(4,3) green line segment
Insert image description here

Find the slope k=(by-ay)/(bx-ax) or (ay-by)/(ax-bx)
k=(3-2)/(4-1)=one third of
k and point a Or point b, any point x, y into the y=kx+b formula to find the intercept b, here bring in point a (1,2)

2=⅓+b
-b=⅓-six thirds
b=five thirds

Now find out what y= is when x=3.
Bring x into y=kx+b.
y=1+five thirds
y=eight thirds. Blue line segment
Insert image description here
. Now find out what y= is when x=6.
Bring x into y. =kx+b in
y=2+five-thirds
y=eleven-thirds orange line segment
Insert image description here
. In this way, we know the x coordinates 1-4 of a(1,2) b(4,3). Take any number in this interval. The value of y can be obtained to prepare for future triangle rasterization.

Guess you like

Origin blog.csdn.net/weixin_40938312/article/details/131245114