26
EINSTEIN COLLEGE OF ENGINEERING Sir.C.V.Raman Nagar, Tirunelveli-12 Department of Computer Science and Engineering Subject Code: CS76 “Computer Graphics Lab” Name : …………………………………… Reg No : …………………………………… Branch : …………………………………… Year & Semester : ……………………………………

CS76-Computer Graphics Lab

Embed Size (px)

Citation preview

Page 1: CS76-Computer Graphics Lab

EINSTEIN COLLEGE OF ENGINEERING Sir.C.V.Raman Nagar, Tirunelveli-12

Department of Computer Science and Engineering

Subject Code: CS76

“Computer Graphics Lab”

Name : ……………………………………

Reg No : ……………………………………

Branch : ……………………………………

Year & Semester : ……………………………………

Page 2: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 2 of 26

Syllabus

CS76 COMPUTER GRAPHICS LABORATORY L T P 0 0 3 2 1. Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2. Implementation of Line, Circle and ellipse Attributes 3. Two Dimensional transformations - Translation, Rotation, Scaling, Reflection, Shear. 4. Composite 2D Transformations 5. Cohen Sutherland 2D line clipping and Windowing 6. Sutherland – Hodgeman Polygon clipping Algorithm 7. Three dimensional transformations - Translation, Rotation, Scaling 8. Composite 3D transformations 9. Drawing three dimensional objects and Scenes 10. Generating Fractal images

Page 3: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 3 of 26

INDEX

Sl.No Date Experiment Name Page No. Marks Sign.

1 Implementation of Bresenhams Algorithm – Line, Circle, Ellipse.

2 Implementation of Line, Circle and ellipse Attributes

3

Two Dimensional transformations - Translation, Rotation, Scaling, Reflection, Shear.

4 Composite 2D Transformations

5 Cohen Sutherland 2D line clipping and Windowing

6 Sutherland – Hodgeman Polygon clipping Algorithm

7 Three dimensional transformations - Translation, Rotation, Scaling

8 Composite 3D transformations

9 Drawing three dimensional objects and Scenes

10 Generating Fractal images

Page 4: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 4 of 26

EX NO:1a. Bresenham’s Line Drawing Algorithm AIM: To write a C program to draw a line using Bresenham’s Algorithm

ALGORITHM:

1. Input the two endpoints (x1,y1) and (x2,y2). 2. Plot the pixel value (x1,y1) with a specified color. 3. Calculate the value of dx and dy and find the starting value of decision

parameter as dp=2*dy-dx;

4. Calculate the values of s1 and s2 depending on (x1,y1) and (x2,y2) values. 5. If dp<0, the next point to plot is (x,y+s2) and dp=+2*dy; 6. Otherwise the next point to plot is (x+s1,y+s2) and dp=dp+2*dx-2*dy. 7. Repeat steps 5 and 6 dx times.

Page 5: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 5 of 26

EX NO 1b. Bresenham’s Circle Drawing Algorithm AIM:

To write a C program to draw a circle using Bresenham’s Algorithm

ALGORITHM: 1. Input radius r and the midpoint of the circle (x,y) and obtain the first point on

the circumference for the circle as (0,r). 2. Calculate the initial value of the decision parameter as p=1-r. 3. At each position check the following conditions.

a) If p<0 then x=x+1 and p+=2*x+1 b) Else y=y-1 and p+=2*(x-y)+1.

4. Determine symmetry points at the other seven octants. 5. Move each calculated pixel position (x,y) onto the circular path centered on

(xc,yc) and plot the coordinate value as x=x+xc and y=y+yc. 6. Repeat step 3 until x<y.

Page 6: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 6 of 26

EX NO 1c. Bresenham’s Ellipse Drawing Algorithm AIM:

To write a C program to draw an ellipse using Bresenham’s Algorithm

ALGORITHM: 1. Input yx rr , and the center of the ellipse cc yx , and obtain the first point on

the ellipse centered on the origin as yryx ,0, 00 2. Calculate the initial value of the decision parameter in region1 as

2220 4

11 xyxy rrrrp

3. At each position kx in region 1 , starting at k=0,perform the following test.If 01 kp the next point along the ellipse centered on (0,0) is kk yx ,1 and

21

21 211 ykykk rxrpp .

4. Otherwise the next point along the ellipse is 1,1 kk yx and 2

12

12

1 2211 ykxkykk ryrxrpp with 22

1222

12 222,222 xkxkxykyky ryryrrxrxr and continue until

yrxr xy22 22 .

5. Calculate the initial position of the decision parameter in region 2 as

2220

22

02

0 1212 yxxy rryrxrp

where 00 , yx is the last position

calculated in region 1. 6. At each ky position in region 2, starting at k=0,perform the following test , if

02 kp the next point along the ellipse centered on (0,0) is 1, kk yx and 2

12

1 222 xkxkk ryrpp . 7. Otherwise the next point along the ellipse is 1,1 kk yx and

21

21

21 2222 xkxkykk ryrxrpp .

8. Using the same incremental values for x and y as in region 1 ,continue until y=0.

9. For both regions determine symmetry points along the other three quadrants. 10. Move each calculated pixel position (x,y) on to the elliptical path centered on

cc yx , and plot the coordinate values cc yyyxxx , QUESTIONS

1. Difference between DDA and Bresenham's line drawing algorithm DDA uses float numbers and uses operators such as division and multiplication in its calculation. Bresenhams algorithm uses ints and only uses addition and subtraction. Due to the use of only addition subtraction and bit shifting (multiplication and division use more resources and processor power) bresenhams algorithm is faster than DDA in producing the line. Im not sure, though if i remember right, they still produce the same line in the end. 2.What are the advantages of bresenhams algorithm?

Page 7: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 7 of 26

The main advantage of Bresenham's algorithm is speed. It uses only integer addition/subtraction and bit shifting.

3.What are the disadvantages of bresenhams algorithm? The disadvantage of such a simple algorithm is that it is meant for basic line drawing. 4.What is the drawback of DDA? Time consuming 5. Define Computer graphics. Computer graphics remains one of the most existing and rapidly growing computer fields. Computer graphics may be defined as a pictorial representation or graphical representation of objects in a computer

Page 8: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 8 of 26

EX NO 2 Implementation of Line, Circle and ellipse Attributes AIM: To write a program to draw a Line,circle,ellipse. LINE DRAWING FUNCTIONS USED: Line()

line (x1,y1,x2,y2) : Line function draws a line between two specified points (x,y) towards (x2,y2).This function comes handy if you want to draw box like shapes or just plotting the graphs etc. e.g. line(100,50,100,400);

You can set the line style using setlinestyle functions. This function specifies the type of line, pattern & the thickness that is going to appear on the screen. You have options like solid,dotted,centered,dashed etc.

The other attributes with the command are as follows: setlinestyle(style,0,1);SetLinetype(lt),setLinewidthScaleFactor(lw),sePolylinecolourIndex(lc)

Color palettes

The graphics.h has declaration about 16 colors.In order to use the color in your program you have to use the functions like setcolor( ) ,setbkcolor( ) & setfillstyle( ).The function setcolor( ) sets the value of current drawing color to color.setfillstyle( ) sets the current fill pattern and fill color.setbkcolor( ) sets the value for background color,which is by default black.

Below is the table that describes the value for each color that are declared in the graphics.h file.

Color Value Black 0 Blue 1 GREEN 2 Cyan 3 RED 4 MAGENTA 5 BROWN 6 LIGHTGRAY 7 DARKGRAY 8 LIGHTBLUE 9

Page 9: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 9 of 26

LIGHTGREEN 10 LIGHTCYAN 11 LIGHTRED 12 LIGHTMAGENTA 13 YELLOW 14 WHITE 15 CIRCLE DRAWING

FUNCTIONS USED: Circle() The function circle() is used to draw a circle using(x,y) as centre point.

Syntax: circle (x,y,radius) The other attributes with the command are as follows: Setfillstyle(style,lc),setcolor(lc) ELLIPSE DRAWING

FUNCTIONS USED:

ellipse (x,y,stangle,endangle,xrad,yrad) : This function draws an elliptical arc. Here (x,y) are the co-ordinates of center of the ellipse. (stangle,endangle) are the starting and ending angles. If stangle=0 and endangle=360 then this function draws complete ellipse. eg.ellipse(100,150,0,360,100,50); The other attributes with the command are as follows: setfillcolor(lc),setfillstyle(ls),setlinecolor(lc),setlinewidth(lw) ALGORITHM Step 1: Start Step 2: Draw the line. Set the attributes like style,type,width etc. Step 3: Draw the circle. Set the attributes using commands. Step 4: Draw the ellipse . Set the attributes like fillcolour,fillstyle,linecolour,linewidth Step 5: stop the program QUESTIONS 1. What is scan conversion? A major task of the display processor is digitizing a picture definition given in an application program into a set of pixel-intensity values for storage in the frame buffer. This digitization process is called scan conversion. 2. Write the properties of video display devices? Properties of video display devices are persistence, resolution, and aspect ratio.

Page 10: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 10 of 26

3. What is rasterization? The process of determining the appropriate pixels for representing picture or graphics object is known as rasterization. 4. Name any four input devices. Four input devices are keyboard, mouse, image scanners, and trackball. 5. Write the two techniques for producing color displays with a CRT? Beam penetration method, shadow mask method

Page 11: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 11 of 26

EX NO 3 2D Transformations

AIM: To write a C program to perform 2D transformations such as translation, rotation, scaling, reflection and sharing. ALGORITHM:

1. Input the object coordinates. 2. 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

3. 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

4. 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

5.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

6. Shearing a) Input the shearing factors shx and shy. b) Shearing related to x axis : Transform coordinates x1=x+shx*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 and g) Display the object after shearing

Page 12: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 12 of 26

QUESTIONS 1 What is reflection? The reflection is actually the transformation that produces a mirror image of an object. For this use some angles and lines of reflection. 2. What are the two classifications of shear transformation? X shear, y shear. 3. Name any three font editing tools. ResEdit, FONTographer 4. What is bitmap? Some system has only one bit per pixel; the frame buffer is often referred to as bitmap. 5. What is point in the computer graphics system? The point is a most basic graphical element & is completely defined by a pair of user coordinates (x, y).

Page 13: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 13 of 26

EX.NO.4 Composite 2D Transformations AIM: To perform the 2D transformation such as translation, rotation, scaling, shearing, Reflection Global, Local and Composite Transformations Transformation can be divided into two categories based on their scope: global and local. In addition, there are composite transformations. A global transformation is applicable to all items of a Graphics object. The Transform property of the Graphics class is used to set global transformations. A composite transformation is a sequence of transformations. For example, scaling followed by translation and rotation is a composite translation. We can set up a matrix for any sequence of transformation matrix by calculating the matrix product of individual transformations forming these products is called composition. Multiply matrices in order from right to left. Each successive transformation matrix premultiplies the product of the preceding transformation matrices. ALGORITHM:

1. Input the object coordinates. 2. 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. 3. Rotation

d) Enter the radian for rotation angle θ. e) Rotate a point at position (x,y) through an angle θ about the origin

x1=xcos θ - ysin θ , y1=ycos θ + xsin θ. 4. Scaling

d) Input the scaled factors sx and sy. e) The transformed coordinates (x1,y1) , x1=x.sx and y1=y.sy.

5.Reflection Reflection can be performed about x axis and y axis.

d) Reflection about x axis : The transformed coordinates are x1=a and y1=-y.

e) Reflection about y axis : The transformed coordinates are x1=x and y1=y.

6. Shearing h) Input the shearing factors shx and shy. i) Shearing related to x axis : Transform coordinates x1=x+shx*y

and y1=y. j) Shearing related to y axis : Transform coordinates x1=x and

y1=y+shy*x. k) Input the xref and yref values.

Page 14: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 14 of 26

l) X axis shear related to the reference line y-yref is x1=x+shx(y-yref) and y1=y.

m) Y axis shear related to the reference line x=xref is x1=x and y1=y+shy(x-xref)

7.Finally display the transformed object after the successive transformations. QUESTIONS

1. What is Transformation? Transformation is the process of introducing changes in the shape size and orientation of the object using scaling rotation reflection shearing & translation etc. 2. What is translation? Translation is the process of changing the position of an object in a straight-line path from one coordinate location to another. Every point (x , y) in the object must under go a displacement to (x|,y|). the transformation is: x| = x + tx ; y| = y+ty 3. What is rotation? A 2-D rotation is done by repositioning the coordinates along a circular path, in the x-y plane by making an angle with the axes. The transformation is given by: X| = r cos (q + f) and Y| = r sin (q + f). 4. What is scaling? A 2-D rotation is done by repositioning the coordinates along a circular path, in the x-y plane by making an angle with the axes. The transformation is given by: X| = r cos (q + f) and Y| = r sin (q + f). 5. What is shearing? The shearing transformation actually slants the object along the X direction or the Y direction as required. ie; this transformation slants the shape of an object along a required plane. 6. What is reflection? The reflection is actually the transformation that produces a mirror image of an object. For this use some angles and lines of reflection.

Page 15: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 15 of 26

EX NO 5 Cohen Sutherland 2D clipping AIM: To write a C program to perform cohen Sutherland 2D clipping and window

viewport mapping. ALGORITHM

1. Enter the line end points and the window coordinates. 2. Every line end point is assigned a code that identified the location of the point

relative to the boundaries of the clipping rectangle. 3. Check whether the line lies inside the window then it is entirely drawn. 4. Check whether the line lies outside the window then it is entirely clipped. 5. Otherwise check whether the line intersects the window:

a) Calculate differences between end points and clip boundaries. b) Determine the intersection point and how much of the line is to be

discarded.

QUESTIONS

1. What is pixmap? Some system has multiple bits per pixel, the frame buffer is often referred to as pixmap. 2. Write the types of clipping? Point clipping, line clipping, area clipping, text clipping and curve clipping. 3. What is meant by scan code? When a key is pressed on the keyboard, the keyboard controller places a code carry to the key pressed into a part of the memory called as the keyboard buffer. This code is called as the scan code. 4. List out the merits and demerits of Penetration techniques? The merits and demerits of the Penetration techniques are as follows • It is an inexpensive technique • It has only four colors • The quality of the picture is not good when it is compared to other techniques • It can display color scans in monitors • Poor limitation etc. 5. List out the merits and demerits of DVST? The merits and demerits of direct view storage tubes [DVST] are as follows • It has a flat screen • Refreshing of screen is not required • Selective or part erasing of screen is not possible • It has poor contrast Performance is inferior to the refresh CRT.

Page 16: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 16 of 26

EX NO:6 Sutherland – Hodgeman Polygon clipping Algorithm

AIM

To write a program for implementing Sutherland – Hodgeman Polygon clipping Algorithm

ALGORITHM

The Sutherland - Hodgman algorithm performs a clipping of a polygon against each window edge in turn. It accepts an ordered sequence of verices v1, v2, v3, ..., vn and puts out a set of vertices defining the clipped polygon.

This figure represents a polygon (the large, solid, upward pointing arrow) before clipping has occurred.

The following figures show how this algorithm works at each edge, clipping the polygon.

a. Clipping against the left side of the clip window. b. Clipping against the top side of the clip window. c. Clipping against the right side of the clip window. d. Clipping against the bottom side of the clip window.

Page 17: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 17 of 26

Four Types of Edges

As the algorithm goes around the edges of the window, clipping the polygon, it encounters four types of edges. All four edge types are illustrated by the polygon in the following figure. For each edge type, zero, one, or two vertices are added to the output list of vertices that define the clipped polygon.

The four types of edges are:

1. Edges that are totally inside the clip window. - add the second inside vertex point

2. Edges that are leaving the clip window. - add the intersection point as a vertex 3. Edges that are entirely outside the clip window. - add nothing to the vertex

output list 4. Edges that are entering the clip window. - save the intersection and inside

points as vertices

How To Calculate Intersections

Assume that we're clipping a polgon's edge with vertices at (x1,y1) and (x2,y2) against a clip window with vertices at (xmin, ymin) and (xmax,ymax).

The location (IX, IY) of the intersection of the edge with the left side of the window is:

i. IX = xmin ii. IY = slope*(xmin-x1) + y1, where the slope = (y2-y1)/(x2-x1)

The location of the intersection of the edge with the right side of the window is:

i. IX = xmax ii. IY = slope*(xmax-x1) + y1, where the slope = (y2-y1)/(x2-x1)

The intersection of the polygon's edge with the top side of the window is:

i. IX = x1 + (ymax - y1) / slope ii. IY = ymax

Page 18: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 18 of 26

Finally, the intersection of the edge with the bottom side of the window is:

i. IX = x1 + (ymin - y1) / slope ii. IY = ymin

QUESTIONS 1. What is run length encoding? Run length encoding is a compression technique used to store the intensity values in the frame buffer, which stores each scan line as a set of integer pairs. One number each pair indicates an intensity value, and second number specifies the number of adjacent pixels on the scan line that are to have that intensity value. 2. What is point in the computer graphics system? The point is a most basic graphical element & is completely defined by a pair of user coordinates (x, y). 3. Write short notes on lines? A line is of infinite extent can be defined by an angle of slope q and one point on the line P=P(x,y). This can also be defined as y=mx+C where C is the Yintercept. 4. Define Circle? Circle is defined by its center xc, yc and its radius in user coordinate units. The equation of the circle is (x-xc) + (y-yc) = r2. 5. What are the various attributes of a line? The line type, width and color are the attributes of the line. The line type include solid line, dashed lines, and dotted lines.

Page 19: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 19 of 26

EX NO 7 3D Transformations AIM: To write a C program to perform 3D transformations such as translation

rotation and scaling. ALGORITHM:

1. Translation a) A point is transferred from position (x,y,z) to position (x1,y1,z1) with

the matrix operation X1 1 0 0 tx x Y1 = 0 1 0 ty y Z1 0 0 1 tz z 1 0 0 0 1 1

b) The values are x1=x+tx ,y1=y+ty and z1=z+tz. c) Display the translated object

2. Rotation a) Coordinate axes rotation

X1=x-cos θ-ysin θ Y1=xsin θ+ycos θ Z1=z

b) Y axis rotation Z1=zcos θ-xsin θ X1=zsin θ+xcos θ Y1=y

c) X axis rotation Y1=ycos θ-zsin θ Z1=ysin θ+zcos θ X1=x

d) Display the rotated object 3. Scaling

a) Translate the fixed point to the origin b) Scale the object c) Translate the fixed point back to its original position. d) Display the scaled object

QUESTIONS 1. What is fixed point scaling? The location of a scaled object can be controlled by a position called the fixed point that is to remain unchanged after the scaling transformation. 2. What is Bezier Basis Function? Bezier Basis functions are a set of polynomials, which can be used instead of the primitive polynomial basis, and have some useful properties for interactive curve design. 3. What is surface patch? A single surface element can be defined as the surface traced out as two parameters (u, v) take all possible values between 0 and 1 in a two-parameter representation. Such a single surface element is known as a surface patch. 4. Define B-Spline curve?

Page 20: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 20 of 26

A B-Spline curve is a set of piecewise(usually cubic) polynomial segments that pass close to a set of control points. However the curve does not pass through these control points, it only passes close to them. 5. What is a spline? To produce a smooth curve through a designed set of points, a flexible strip called spline is used. Such a spline curve can be mathematically described with a piecewise cubic polynomial function whose first and second derivatives are continuous across various curve section. 6. What are the different ways of specifying spline? Using a set of boundary conditions that are imposed on the spline. • Using the state matrix that characteristics the spline • Using a set of blending functions that calculate the positions along the curve path by specifying combination of geometric constraints on the curve

Page 21: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 21 of 26

EX NO 8 Composite 3D Transformation AIM: To write a program to perform composite 3D Transformation. Composite transformation

Here we multiply the matrix representations for the individual operations in the transformation sequence. This concatenation is carried out from right to left. A sequence of 3 basic transformation is carried out to produce the composite transformation ALGORITHM

1. Translation a) A point is transferred from position (x,y,z) to position (x1,y1,z1) with

the matrix operation X1 1 0 0 tx x Y1 = 0 1 0 ty y Z1 0 0 1 tz z 1 0 0 0 1 1

b) The values are x1=x+tx ,y1=y+ty and z1=z+tz. 2. Rotation

a) Coordinate axes rotation X1=x-cos θ-ysin θ Y1=xsin θ+ycos θ Z1=z

b) Y axis rotation Z1=zcos θ-xsin θ X1=zsin θ+xcos θ Y1=y

c) X axis rotation Y1=ycos θ-zsin θ Z1=ysin θ+zcos θ X1=x

3. Scaling a) Translate the fixed point to the origin b) Scale the object c) Translate the fixed point back to its original position

4. Finally display the object after the sequence of transformation QUESTIONS 1.Define Projection? The process of displaying 3D into a 2D display unit is known as projection. The projection transforms 3D objects into a 2D projection plane 2. What are the steps involved in 3D transformation? • Modeling Transformation • Viewing Transformation • Projection Transformation Workstation Transformation 3. What do you mean by view plane?

Page 22: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 22 of 26

A view plane is nothing but the film plane in camera which is positioned and oriented for a particular shot of the scene. 4. Define projection? The process of converting the description of objects from world coordinates to viewing coordinates is known as projection

Page 23: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 23 of 26

Ex NO 9 Drawing three dimensional objects and Scenes AIM To draw 3D objects and scenes ALGORITHM:

1. Parallel Projection a) Enter the boundary coordinates of the object. b) Define the direction of the projection line. c) Align the projection plane so that it intersects each coordinate axis in

which the object is defined at the same distance from the origin. d) The projection is perpendicular to the view plane e) If the view plane is placed at position Z1 along the z axis , then any

point (x,y,z) in viewing coordinates is transformed to projection coordinates xp=x and yp=y.

2.Perspective Projection a) Enter the boundary coordinates of the object. b) Define the projection reference point and thus the direction of the

projection lines. c) The projected view is obtained by transforming points along projection

lines that meet at the projection reference point. d) Calculate the intersection of the projection lines with the view plane. e) Parallel lines in the object that are not parallel to the plane are

projected into converging lines. f) Parallel lines that are parallel to the view plane will be projected as

parallel lines. QUESTIONS 1. What do you mean by Perspective projection? Perspective projection is one in which the lines of projection are not parallel. Instead, they all converge at a single point called the center of projection. 2. What is Projection reference point? In Perspective projection, the lines of projection are not parallel. Instead, they all converge at a single point called Projection reference point. 3. What you mean by parallel projection? Parallel projection is one in which z coordinates is discarded and parallel lines from each vertex on the object are extended until they intersect the view plane. 4. What is tweening? It is the process, which is applicable to animation objects defined by a sequence of points, and that change shape from frame to frame. 5.Define frame? One of the shape photographs that a film or video is made of is known as frame. 6. What is key frame? One of the shape photographs that a film or video is made of the shape of an object is known initially and for a small no of other frames called keyframe

Page 24: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 24 of 26

EX NO 10 Generating Fractal images AIM: To generate fractal images. ALGORITHM

The sierpinski triangle-A fractal image 1.The sierpinski Triangle is created by infinite removals 2.Each triangle is divided into 4 smaller upside down triangles 3.The center of the 4 triangles is removed 4. As the process is iterated infinite number of times, the total area of the set goes to infinity as the size of the each new triangle goes to zero 5.After closer examination magnification factor is 2. 6.With each magnification there are 3 divisions of a triangle Dimension D=ln(3)/ln(2) D=1.5850

QUESTIONS 1.What is a fractal image Fractal is "a rough or fragmented geometric shape that can be split into parts, each of which is (at least approximately) a reduced-size copy of the whole,"[1] a property called self-similarity. 2. Define the following: (i) X-height (ii) Set (iii) Kerning X-height: The X-height is the measurement of the height of the character X, in other words of the middle bit without any ascender or descender. (ii) Set: The width of the letters is called the set and is fixed relative to the point-size. (iii) Kerning: The spaces between letters in one world (tracking) can be adjusted in a process called kerning. 3. Define the following respective to sound: (i) Waveform (ii) Frequency (iii) Amplitude i) Waveform Sound is produced by the vibration of matter. During the vibration pressure variation are created in the air surrounding it. The pattern of the oscillation is called a waveform. (ii) Frequency The frequency of the sound is the reciprocal value of the period. It represents the number of period s in a second and it is measured in Hertz (Hz) or cycles per second. (iii) Amplitude

Page 25: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 25 of 26

A sound also has amplitude. The amplitude of a sound is a measure of the displacement of the air pressure wave from its, or quiescent state. 4. Define quantization (or) resolution? The resolution (or) quantization of a sample value depends on the number of bits used in measuring the height of the waveform. An 8-bit quantization yields 256 possible values, 16-bit CD-qudra quantization results in over 65536 values. 5. What are the types of sound objects that can be used in multimedia production? There are four types of sound objects that can be used in multimedia production: _ Waveform audio _ MIDI sound tracks _ Compact disc (CD) audio _ MP3 files 6.What are the applications of fractal image? Produces visual effect. Hence used in film industry

Page 26: CS76-Computer Graphics Lab

CS76

©Einstein College of Engineering

Page 26 of 26