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
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
. 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
. 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.