-
Notifications
You must be signed in to change notification settings - Fork 0
/
DDA3POINTS.C
60 lines (57 loc) · 890 Bytes
/
DDA3POINTS.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
void main(){
int gd = DETECT ,gm, i;
float x, y,dx,dy,steps,steps1,x3,y3,dx1,dy1;
int x0, x1, y0, y1,x2,y2;
initgraph(&gd, &gm, "C:\\TURBOC3\\BGI");
x0 = 100 , y0 = 200, x1 = 400, y1 = 200,x2=600,y2=400;
dx = (float)(x1 - x0);
dy = (float)(y1 - y0);
dx1=(float)(x2-x1);
dy1=(float)(y2-y1);
if(dx>=dy)
{
steps = dx;
}
else
{
steps = dy;
}
dx = dx/steps;
dy = dy/steps;
x = x0;
y = y0;
i = 1;
while(i<= steps)
{
putpixel(x, y, WHITE);
x += dx;
y += dy;
i=i+1;
}
if(dx1>=dy1)
{
steps1 = dx1;
}
else
{
steps1 = dy1;
}
dx1 = dx1/steps1;
dy1 = dy1/steps1;
x3 = x1;
y3 = y1;
i = 1;
while(i<= steps1)
{
putpixel(x3, y3, BLUE);
x3 += dx1;
y3 += dy1;
i=i+1;
}
getch();
closegraph();
}