0% found this document useful (0 votes)
57 views8 pages

PR - 7 - Computer Graphics

This document outlines a practical exercise for a Computer Graphics course focused on 2D Translation and Scaling using C programming. It details the significance of transformations in graphics, expected outcomes for students, and provides a structured procedure for implementing the transformations. Additionally, it includes required resources, precautions, assessment schemes, and references for further reading.

Uploaded by

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

PR - 7 - Computer Graphics

This document outlines a practical exercise for a Computer Graphics course focused on 2D Translation and Scaling using C programming. It details the significance of transformations in graphics, expected outcomes for students, and provides a structured procedure for implementing the transformations. Additionally, it includes required resources, precautions, assessment schemes, and references for further reading.

Uploaded by

Atharva Mahajan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Computer Graphics(313014)

Practical No:07 - Write a C program for 2D Translation and Scaling.

I. Practical Significance:
One of the most common and important tasks in Computer Graphics is to transformation
the coordinates (positions, orientation, and size) of objects. Transformation are one of the
primary vehicles used in computer graphics to manipulate object in two or three
dimensional space. There are three different types of transformation such as
translation,scaling up or down , rotation,shearing,etc. When a transformation takes place
on 2D plane, it is called 2D transformation.

II. Industry, Employer Expected outcomes:


This practical aims to develop the following skills:
Develop C programs to draw basic graphics objects.
1. Write syntax for graphics functions.
2. Set up graphics driver, mode, and directory to run graphics programs.
3. Compile C programs using Turbo C.
4. Debug and execute programs effectively.

III. Course Level Learning Outcomes:


Develop programs in C applying standard graphics algorithms.
1. Develop and implement C programs using standard graphics algorithms.
2. Apply translation, scaling algorithm to draw graphical image.
3. Understand the principles of 2D translation, scaling in computer graphics.

IV. Laboratory Learning outcomes:


LLO 7.1 Implement a C program for 2D Translation and Scaling

V. Relevant Affective Domain Related Outcomes:


- Demonstrate patience and attention to detail when debugging graphics code.
- Show creativity in designing visual representations.

VI. Relevant Theoretical Domain Related outcomes(with Diagram if required):


Translation:
Giving linear displacement to an object along X and Y axis in a particular direction in a
plane is translation. A translation is a process of changing the position of an object in a
straight path from one coordinate location to another. We can translate a point 2D by adding
translation coordinates(tx, ty) to original coordinates(X,Y) to get the new coordinates(x’,y’).

Figure 1: 2D Translation

By adding translation vector,


𝐱′ = 𝐱 + 𝐭 𝐱
𝐲′ = 𝐲 + 𝐭 𝐲
Maharashtra State Board Of Technical Education 45
Computer Graphics(313014)

The pair (tx, ty) is called the translation vector or shift vector. The above equations can also
be represented using the column vectors.
[X] [X′] [t x ]
P= P′ = T=
[Y] [Y′] [t y ]

We can write it as-


P′ = P + T

Scaling:
Scaling is a process that increases and decreases original size of an object by virtue of it
the object can be made big or small. This transformation makes necessary changes in the
size of an object keeping its original shape in tact. The operation can be carried out for an
object by multiplying the coordinates value(x, y) of each vertex by scaling factors sx and
sy to produce the transformed coordinates (x’, y’), only condition is to ensure that the base
point is remained unaltered. Changing the size of an compress the dimension of the object.
Scaling can be archived by multiplying the original coordinates of the object with the
scaling factor to get desired result.
Let us assume that the original coordinates are (X, Y) the scaling factors are(Sx, Sy) and
the product coordinates are(X’,Y’). This can be mathematically represented as shown
below-

X′ = 𝐗 ∗ 𝐒𝐱 𝐚𝐧𝐝 𝐘′ = 𝐘 ∗ Sy

The scaling factor Sx, Sy scales the object in X and Y direction respectively. The above
equations can also be represented in matrix form as below.

𝑿′ 𝑿 𝑺𝒙 𝟎
( ′) = ( ) ∗ [ 𝟎 𝑺𝒚 ]
𝒀 𝒀

OR

P′ = 𝐏 ∗ S

Where S is scaling Matrix.


The Scaling s shown in following figure.

Maharashtra State Board Of Technical Education 46


Computer Graphics(313014)

[Link] Resources/apparatus/equipment with specification:

Sr. Name of Specification Qty. Remarks


Resource
Hardware: Computer(i3-i5preferable), RAM
Computer minimum 2Gb and onwards but
1. System not limited
As per batch For All
Operating Windows XP/ Windows Experiment
2. Size
System 7/LINUX version 5.0 or later s
Turbo C/C++ Version 3.0 or later
3. Software with DOSBOX

VIII. Precautions to be followed :


- Ensure the graphics library is properly installed and configured.
- Check for compatibility of the graphics library with the compiler.
- Handle errors and exceptions to avoid crashes.
IX. Procedure :
Step 1: Start the program
Step 2:Input the object coordinates
Step 3:For translation
a) Enter the translation factor tx,ty.
b) Move original coordinate position(x, y) to new position(x1, y1) ie. x=x+x1, y=y+y1
c) Display the object after translation
Step 4:For scaling
a) Enter the scaling factor sx,sy.
b) Move transform coordinate (x1, y1) ie. X1=x*sx, y1=y+sy
c) Display the object after scaling
Step 5:Stop Program

X. Resources used
Sr.
Name of Resource Specification
No.
Computer System
1.
with broad specifications
2. Software

3. Any other resource used


Algorithm

Maharashtra State Board Of Technical Education 47


Computer Graphics(313014)

Flowchart:

‘C’ program code

Maharashtra State Board Of Technical Education 48


Computer Graphics(313014)

XI. Result :

………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
[Link] and recommendation:

………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
XIII. Practical Related Questions:
Note: Below given are few sample questions for reference. Teachers must
design more such questions so as to ensure the achievement of identified CO.
1. Write a transformation matrix for 2D scaling.
2. Write a transformation matrix for 2D Translation.
3. What does scaling transformation do?
4. Whether size of object remains same or changed in case of translation?

(Space for Answer)


………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
Maharashtra State Board Of Technical Education 49
Computer Graphics(313014)

………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
XIV. Exercise:
1. Translate the polygon with co-ordinates A(2,5), B(7,10), C(10,2) by 3 units in x
direction and 5 units in y direction.
2. Scale the polygon with co-ordinates A(2,5), B(7,10), C(10,2) by 2 units in x direction
and 2 units in y direction.
3. Give a 3X3 homogeneous co-ordinates transformation matrix for each of the
following translation
a) Shift image to right 3 units
b) Shift image up 2 units
c) Move the image down 0.5 units and right 1 unit
d) Move the image down 1.5 units and left 5 units.

(Space for Answer)

………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
Maharashtra State Board Of Technical Education 50
Computer Graphics(313014)

………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………

Maharashtra State Board Of Technical Education 51


Computer Graphics(313014)

XV. References/Suggestions for further reading: include Website. Link:


1. [Link]
2. [Link]
3. [Link]
4. [Link]
[Link]#google_vignette

XVI. Assessment Scheme

Performance indicators Weightage


Process related: 15 Marks 60%
1. Debugging ability 20%

2. Correctness of Program codes 30%

3. Quality of output achieved(LLO mapped) 10%

Product related: 10 Marks 40%

1. Completion and submission of practical in time 20%


2. Answer to sample questions 20%
Total 25 Marks 100%

List of Student /Team Members

1. ………..………..………..

2. ………..………..………..

3. ………..………..………..

4. ………..………..………..

Marks obtained Dated Sign of Teacher

Process Product
Related(15) Related(10) Total(25)

Maharashtra State Board Of Technical Education 52

You might also like