0% found this document useful (0 votes)
24 views4 pages

45 Degree Angle Generation Program in C: #Include #Include

This C program uses the Digital Differential Analyzer (DDA) algorithm to generate 45 degree angles by drawing lines between coordinate points. It includes functions for calculating absolute values and implementing the DDA line drawing method. The main function initializes graphics mode, calls the DDA function twice to draw lines at 45 degree angles, and waits for user input before ending.

Uploaded by

Himanshu Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views4 pages

45 Degree Angle Generation Program in C: #Include #Include

This C program uses the Digital Differential Analyzer (DDA) algorithm to generate 45 degree angles by drawing lines between coordinate points. It includes functions for calculating absolute values and implementing the DDA line drawing method. The main function initializes graphics mode, calls the DDA function twice to draw lines at 45 degree angles, and waits for user input before ending.

Uploaded by

Himanshu Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

45 degree anGle generation program in C

#include<stdio.h>

#include<graphics.h>

int abs (int n)

return ( (n>0) ? n : ( n * (-1)));

void DDA(int X0, int Y0, int X1, int Y1)

int dx = X1 - X0;

int dy = Y1 - Y0;

int steps = abs(dx) > abs(dy) ? abs(dx) : abs(dy);


float Xinc = dx / (float) steps;

float Yinc = dy / (float) steps;

float X = X0;

float Y = Y0;

for (int i = 0; i <= steps; i++)

putpixel (X,Y,YELLOW);

X += Xinc;

Y += Yinc;

int main()

int gd = DETECT, gm;

initgraph (&gd, &gm, "");


DDA(50,200,200,200);

DDA(50,200,200,50);

getch();

return 0;

Output:

You might also like