Rasterizer Project - Part 2: Lines and Optimization (Excited reaction)
dev.to·1d·
Discuss: DEV
Flag this post

Hello there beautiful people, lets continue on this rasterizer.

So now we want to draw lines between points inside of our image. How do we do this? Well firstly lets talk about linear interpolation. It works like this

You take point A (origin point) and your point B (goal point), whats a point? well in 2D that comprises of a X and a Y coordinate.

You calculate the X and Y cooridnate seperately in functions. What you do is you take A’s x coordinate + (Bx - Ax) and * it by a scalar between 0 and 1. So in our example we use 0.02f which is 2% of the total lines length. So what this formula does is that we essentially calculate, what is 2% of the X value in the distance between our two Points (A and B). Then we store that and apply the same logic for our Y calculation. It…

Similar Posts

Loading similar posts...