Sutherland â Hodgeman Polygon clipping Algorithm. 7. Three dimensional transformations - Translation, Rotation, Scalin
1
om
COMPUTER GRAPHICS
.c
CS2405
w
w
w
.re
jin pa
ul
LAB MANUAL
INDEX
2
SN
TITLE
PAGE
Line Drawing Using Bresenham Algorithm 1A
Ellipse Drawing Using Bresenham Algorithm
1C 2
ul
Two Dimensional Transformations
jin pa
4
Cohen Sutherland 2D line clipping and Windowing
6
. Three dimensional transformations
.re
7
w
w
10
w
8 9
.c
. Implementation of Line, Circle and ellipse Attributes
3
5
om
Circle Drawing Using Bresenham Algorithm
1B
3
SYLLABUS COMPUTER GRAPHICS LABORATORY
om
CS2405
1. Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2. Implementation of Line, Circle and ellipse Attributes Shear. 4. Composite 2D Transformations
ul
5. Cohen Sutherland 2D line clipping and Windowing
.c
3. Two Dimensional transformations - Translation, Rotation, Scaling, Reflection,
6. Sutherland – Hodgeman Polygon clipping Algorithm
jin pa
7. Three dimensional transformations - Translation, Rotation, Scaling 8. Composite 3D transformations
9. Drawing three dimensional objects and Scenes 10. Generating Fractal images
1) Turbo C
.re
LIST OF EQUIPMENTS:
TOTAL: 45 PERIODS
2) Visual C++ with OPENGL
w
w
w
3) Any 3D animation software like 3DSMAX, Maya, Blender
LINE DRAWING USING BRESENHAM ALGORITHM EX.NO: 1A
4
DATE:
AIM: To write a C program for Line Drawing Using Bresenham Algorithm.
Step 1 : Start the program. Step 2 : Declare the necessary variables. Step 3 : Initialize the graph using dx, dy, gd, gm. Step 5 : Similarly, absolute values to dx, dy.
ul
Step 6 : put pixel and set 15 to pixel position.
.c
Step 4 : Assign the values of x1, y1 to x,y respectively.
Step 7 : Using do-while loop, put e,x,y,I values.
w
w
w
.re
jin pa
Step 8 : Stop the program.
PROGRAM: #include #include
om
ALGORITHM:
5
#include #include #include void main() { float x,y,x1,y1,x2,y2,dx,dy,e; int i,gd=DETECT,gm; printf("\n ENTER THE VALUE OF X1:"); scanf("%f",&x1); scanf("%f",&y1);
.c
printf("\n ENTER THE VALUES OF Y1:");
om
clrscr();
scanf("%f%f",&x2,&y2); initgraph(&gd,&gm," ");
jin pa
dx=abs(x2-x1); dy=abs(y2-y1); x=x1; y-y1;
e=2*(dy-dx);
.re
i=1; do {
w
putpixel(x,y,15);
w
while(e>=0)
w
ul
printf("\n ENTER THE VALUES OF X2 AND Y2:");
{ y=y+1; e=e-(2*dx); } x=x+1; e=e+(2*dy); i=i+1; delay(100);
}while(i