Thursday, April 25, 2024

MSBTE Diploma In Computer Engineering

 Data Communication and Computer 22414 Unit Wise Notes

Syllabus DCC(314318)





 Short Course of DCN
Class Test Question Banks




Practical's 











MSBTE MODEL ANSWER PEPAR




Environmental Studies Notes 22447
 PPT :

Environmental Education and Sustainability (314301) 

Class Test Question Bank 



 Computer Graphics Notes 313001
All Program

Practical 

 Procedure
#include: The header file must be included for every graphics program 
1. Void initgraph(int v*graphdriver,int graph mode,char*pathodriver); Initgraph() function is used To change from text mode to graphics mode. The graphics drivers and graphics mode are the parameters to this function. detectgraph() function is used to find out the graphics drivers and graphics mode. 
2. void closegraph(); closegraph() function closes the graphcis mode,deallocates all memory allocated by graphics system and restores the screen to text 
3.put pixel(int x,int y,color); putpixel() fuction is used to draw pixels at given position(x,y) and with given color. 
4.line(int x1, int y1,intx2,inty2) Line fuction is used to draw a line from point (x1,y1)-starting point to point (x2,y2)-Ending point 
5.circle(intx,inty,int radius); Circle function is used to draw a circle with center (x,y) and radius of a circle. 
6.rectangle(int left,int top,int right,int bottom) Rectangle fuction is used to draw a rectangle. Coordinates of left top and right bottom corner are required to draw the rectangle. 7.ellipse(intx,inty,start angle,end angle,int xradius,int yradius); Ellipse function is used to draw wllipse with center(x,y),starting angle,end anglr,radius of x and y axis. 

8.outtexty(intx,inty.”text”); Outtexty function is used to insert text at the given position(x,y).
  Outputs : 



We say these computers have vector graphics capability (the line is a vector). The process is turning on pixels for a line segment is called vector generation and algorithm for them is known as vector generation algorithm.

Problems of vector generation:

 

·         Line is straight but width is no constant.

·         Brightness of line dependent on orientation of the line.

·         Calculate only an approximate linelength.

·         Reduce the calculations using simple integer arithmetic.

 

Line Drawing Algorithms

 

1. DDA Algorithm (Digital Differential Analyzer)

 

Step1: Start Algorithm

 

Step2: Declare x1,y1,x2,y2,dx,dy,x,y as integer variables.

 

Step3: Enter value of x1,y1,x2,y2. Step4: Calculate dx = x2-x1 Step5: Calculate dy = y2-y1



Step6: If ABS (dx) > ABS (dy) Then step = abs (dx) Else

Step7: xinc=dx/step yin=dy/step assign x = x1 assign y = y1

 

Step8: Set pixel (x, y)

 

Step9: x = x + xinc

y = y + yinc

Set pixels (Round (x), Round (y))

 

Step10: Repeat step 9 until x = x2



 It’s an accurate and efficient raster line generating Algorithm. Bresenham's line-drawing algorithm uses an iterative scheme. A key feature of the algorithm is that it requires only integer data and simple arithmetic. This makes the algorithm very efficient andfast.

Procedure for Bresenham’s algorithm:


1.Read line end points (x1,y1) and (x2,y2) such that they are not equal.


2. dx=|x2-x1| and dy=|y2-y1| 3.x=x1 and y=y1

4.e=2*dy-dx 5.i=1

 

6.plot (x,y) 7.while (e>0)

{


x=y+1 e=e-2*dx

}


x=x+1 e=e+2*dy

8 for .i=i+1


9. if(i<dx) then goto step 6.


10. Stop.








Algorithm:
Step 1: Start the program.
Step 2: Input the object coordinates
Step 3: For Translation
a) Enter the translation factors tx and ty.
b) Move the original coordinate position (x,y) to a new position (x1,y1).ie. x=x+x1, y=y+y1.
c) Display the object after translation
Step 4: For Rotation

a) Enter the radian for rotation angle θ.
b) Rotate a point at position (x,y) through an angle θ about the origin x1=xcos θ - ysin θ , y1=ycos θ + xsin θ.
c) Display the object after rotation



Step 5: For Scaling
a) Input the scaled factors sx and sy.
b) The transformed coordinates (x1,y1) , x1=x.sx and y1=y.sy.
c) Display the object after scaling
Step 6: For Reflection
Reflection can be performed about x axis and y axis.
a) Reflection about x axis : The transformed coordinates are x1=a and y1=-y.
b) Reflection about y axis : The transformed coordinates are x1=x and y1=y.
c) Display the object after reflection
Step 7: For Shearing
a) Input the shearing factors shx and shy.

b) Shearing related to x axis : Transform coordinates x1=x+sh x*y and y1=y.
c) Shearing related to y axis : Transform coordinates x1=x and y1=y+shy*x.
d) Input the xref and yref values.
e) X axis shear related to the reference line y-yref is x1=x+shx(y- yref) and y1=y.
f) Y axis shear related to the reference line x=xref is x1=x
g) Display the object after shearing
Step 8: Stop the Program.

OUTPUT

OUTPUT:
Menu
Translation
1. Rotation
2. Rotation
3. Scaling
4. Shearing
5. Reflection
6. Exit

Enter the choice: 1
Enter the number of Vertices: 3

Enter the coordinates : 30 150 10 200
Enter the coordinates : 10 200 60 200
Enter the coordinates : 60 200 30 150






Enter the translation vector Tx, Ty : 90 60



 
ROTATION
Enter the choice : 2
Enter the number of Vertices: 3

Enter the coordinates : 30 150 10 200
Enter the coordinates : 10 200 60 200
Enter the coordinates : 60 200 30 150






Enter the Rotating Angle : 90
Enter the Pivot Point : 100 200






 
SCALING
Enter the choice : 3
Enter the number of Vertices: 3

Enter the coordinates : 30 150 10 200
Enter the coordinates : 10 200 60 200
Enter the coordinates : 60 200 30 150







Enter the scaling Factor : 0.3 0.4
Enter the Fixed Point : 100 200





 
SHEARING
Enter the choice : 4
Enter the number of Vertices: 3

Enter the coordinates : 30 150 10 200
Enter the coordinates : 10 200 60 200
Enter the coordinates : 60 200 30 150


Enter the shear Value : 5
Enter the fixed point : 50 100

Enter the Axis for shearing if x-axis then 1
                                               if y-axis then 0






 
REFLECTION
Enter the choice : 5
Enter the number of Vertices: 3

Enter the coordinates : 30 150 10 200
Enter the coordinates : 10 200 60 200
Enter the coordinates : 60 200 30 150





Example OUTPUT Result compuer Graphics

Enter the upper left corner of the rectangle:
100
100
Enter the lower right corner of the rectangle:
200
200
******2DTransformations*******
1.Translation
2.Rotation
3.Scaling
4.Reflection
5.Shearing
6.Exit

Enter your choice: 1

*******Translation******* Enter the value of shift vector:
150
150
******2DTransformations*******
1.Translation
2.Rotation
3.Scaling
4.Reflection
5.Shearing
6.Exit
Enter your choice: 2
*******Rotation*******
Enter the value of fixed point and angle of rotation:
300
300
70
******2DTransformations******* 1.Translation
2.Rotation
3.Scaling
4.Reflection
5.Shearing
6.Exit
Enter your choice: 3
********Scaling*******
Enter the value of scaling factor:
2
2
******2DTransformations*******
1.Translation
2.Rotation
3.Scaling
4.Reflection
5.Shearing
6.Exit

Enter your choice: 4
*******Reflection*********
1.About x-axis
2.About y-axis
3.About both axis
Enter your choice:1
Enter the fixed point
150
150
Enter your choice: 2
Enter the fixed point
150
150
Enter your choice: 3
Enter the fixed point
150
150
******2DTransformations******* 1.Translation
2.Rotation
3.Scaling
4.Reflection
5.Shearing
6.Exit
Enter your choice: 5
*******Shearing*********
1.x-direction shear
2.y-direction shear
Enter your choice: 1
Enter the value of shear : 2
Enter your choice: 2
Enter the value of shear : 2


Algorithm:

Step 1:            Start the program.        

Step 2:            input the points for the cude and size of the Cube.

Step 3:            Display the menu as 1.Translation 2.Scaling 3.Rotation 4.Exit

Step 4:            Get the choice from the user.

Step 5:            If the choice is 1 a point or an object is translated from position P to position P‘ with the operation P’=T.P where tx,ty and tz specifying translation distances.

x’=x+ tx ,y’=y+ ty,z’=z+ tz

Step 6:            If the choice is 2 the scaling transformation of a position P can be written as P’=S.P where scaling parameters sx,sy and sz are assigned any positive values.

x’=x.sx ,y’=y.sy ,z’=z.sz

Step 7:            If the choice is 3 get the rotation angle. Rotate the figure with respect to the axis of rotation.

 

Step 8:            About z axis rotation x’=xcosӨ-ysinӨ ,y’=xsinӨ+ycosӨ

z’=z Rotation can be expressed as P’=Rz(Ө).P

Step 9:            About x axis rotation y’=ycosӨ-zsinӨ z’=ysinӨ+zcosӨ x’=x

Rotation can be expressed as P’=Rx(Ө).P

Step 10:          About y axis rotation z’=zcosӨ-xsinӨ x’=zsinӨ+xcosӨ y’=y

Rotation can be expressed as P’=Ry(Ө).P 

Step 11:          If choice is 4 exit the program.

Step 12:          Stop the program.








Algorithm :

 

1)  Read two end points of line P1 (x1,y1) and P2 (x2,y2).

2)    Read corners of window (Wx1, Wy1) and (Wx2, Wy2).

3)   Assign region codes for P1 and P2. A region code is a 4 digit bit code which indicates one of nine regions having the end point of line.

Initialize code with bits 0000

Set Bit 



1 if(x<Wx1) Set Bit

2 if (x>Wx2) Set Bit

3 if (y<Wy2) Set Bit

4 if (y>Wy1)

4)    Check visibility of line P1P2

a)  If region codes for both end points P1 and P2 are 0 = > Line is completely visible. Draw Line and Go to Step 3.

b)  If region codes for both end points P1 and P2 are not 0 and logical ANDing of them is

also not zero = > Line is completely invisible. Reject line and Go to Step 3.

c)  If a) and b) both are not satisfied, line is partially visible.


5)   Divide partially visible line segments to equal parts and repeat steps 3 through 5 for both sub divided line segments until you get completely visible and completely invisible line segments.

6)    Stop.


Algorithm 



// output:

 //enter the co-ordinate of px :20

//enter the co-ordinate of py: 200

 //enter the co-ordinate of px: 40 

//enter the co-ordinate of py: 300

 //enter the co-ordinate of px: 80 

//enter the co-ordinate of py: 30 

 //enter the co-ordinate of px: 50 

//enter the co-ordinate of py: 400




MSBTE Diploma In Computer Engineering

  Data Communication and Computer 22414 Unit Wise Notes Syllabus DCC( 314318) Unit I: Fundamentals' of Data Communication and Computer N...