Friday, June 26, 2015

Computer Graphics : Just some Line Algorithm


Try analyzing the below code. It's not exactly DDA algorithm. It just uses some basic math like DDA, and the trick for 'sampling' is based on the slope value.

In DDA algorithm, the equations for the coordinates are recurrence equations, here I haven't used recurrence stuff, that's it.

Refer this pdf if you don't know about DDA algorithm :

Line Algorithms PDF


The Code :

Basic Line Code

And do check on the glVertex2f() function...I am checking on it too...if that works fine, then we don't need to go for better algorithms etc...we can pass floating point arguments and plot the line. Though it doesn't make sense...like, pixels are discrete countable stuff. So, we can't just say plot a pixel at ( 234.6 , 156.7 )..it looks weird...Look about it. And do mail me if you get something.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.