Add : DDA algorithm#1007
Conversation
| #include <graphics.h> | ||
| #include <stdio.h> | ||
| #include <conio.h> | ||
| #include <math.h> |
There was a problem hiding this comment.
Please add a one-line description of what the library/header is for (see the example below).
#include <stdio.h> /// for IO operations
#include <assert.h> /// for assert| @@ -0,0 +1,46 @@ | |||
| // DDA line drawing algorithm | |||
There was a problem hiding this comment.
Please describe how the algorithm works, a Wikipedia link, what the algorithm does, etc..
| dx = x2 - x1; | ||
| dy = y2 - y1; | ||
|
|
||
| if (abs(dx) > abs(dy)) | ||
| steps = abs(dx); | ||
| else | ||
| steps = abs(dy); | ||
|
|
||
| xinc = dx / (float) steps; | ||
| yinc = dy / (float) steps; | ||
|
|
||
| x = x1; | ||
| y = y1; | ||
|
|
||
| putpixel(x, y, 15); |
There was a problem hiding this comment.
Separate the code into functions and structures if needed as well as add self-test cases using assert (requires the assert.h library/header).
|
This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
Please ping one of the maintainers once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to ask for help in our Gitter channel or our Discord server. Thank you for your contributions! |
Description of Change
References
Checklist
Notes: