You are on page 1of 7

Annexure – II

Format for Micro-Project Report after Execution in about 8 to 15 pages to be submitted at end of
semester)
PART B – Micro-Project Report

Analog Clock
1.0 Rationale
Project work is the activity that is intended to integrate all the domains of learning i.e.
cognitive, psychomotor and affective domains wherever applicable, the hence it is very important
from the teacher and student point of view. Any project work is not a research, but an experience of
doing some complex work by students on their own, or ‘work-based learning’. Project can be of
micro, mini, minor and major levels depending on at what stage of learning (from first semester to
the last semester) it is incorporated; but all these categories will have the same characteristics. Only
the amount of effort put in and time required will be changing. Therefore, the project work is defined
as ‘A purposeful student activity planned, designed and performed by a student or group of
students to solve the identified problems (or complete a relatively complex task) which requires
them to integrate the various types of skills acquired over a period to help them to accomplish
higher level of cognitive and affective domain outcomes and sometimes the psychomotor domain
outcomes as well'. (Earnest, Joshua and S. K. Gupta). This definition means that the project work
leads to the integration of knowledge, skills and attitudes of the three domains of learning acquired
over a period of time.
2.0 Course Outcomes Addressed
a. Manipulate visual and geometric information of images
b. Develop programs for 2D and 3D transformation

3.0 Literature Review


Transformation means changing some graphics into something else by applying rules. We can
have various types of transformations such as translation, scaling up or down, rotation, shearing, etc.
When a transformation takes place on a 2D plane, it is called 2D transformation.

Transformations play an important role in computer graphics to reposition the graphics on the screen
and change their size or orientation.

Rotation
In rotation, we rotate the object at particular angle θ (theta) from its origin. From the following figure,
we can see that the point P(X, Y) is located at angle φ from the horizontal X coordinate with distance
r from the origin.

Let us suppose you want to rotate it at the angle θ. After rotating it to a new location, you will get a
new point P’ (X’, Y’).

Using standard trigonometric the original coordinate of point P(X, Y) can be represented as −
X = rcosϕ ......(1)
Y = rsinϕ ......(2)

Same way we can represent the point P’ (X’, Y’) as −


x′ = rcos(ϕ+θ) = rcosϕcosθ−rsinϕsinθ .......(3)
y′ = rsin(ϕ+θ) = rcosϕsinθ+rsinϕcosθ .......(4)
Substituting equation (1) & (2) in (3) & (4) respectively, we will get

x′ = xcosθ−ysinθ
y′ = xsinθ+ycosθ

Representing the above equation in matrix form,


P’ = P . R

Where R is the rotation matrix (in row major form)

𝑐𝑜𝑠𝜃 𝑠𝑖𝑛𝜃 0
R = [−𝑠𝑖𝑛𝜃 𝑐𝑜𝑠𝜃 0]
0 0 1
The rotation angle can be positive and negative.
For positive rotation angle, we can use the above rotation matrix. However, for negative angle
rotation, the matrix will change as shown below –

Rotation about arbitrary point:


i) Translate the object so that arbitrary point (xp, yp) is moved to origin.
ii) Rotate the object about origin.
iii) Translate the object so that arbitrary point is moved back to its original position.

Rp = T. R . T -1

1 0 0 𝑐𝑜𝑠𝜃 𝑠𝑖𝑛𝜃 0 1 0 0
Rp = [ 0 1 0] [−𝑠𝑖𝑛𝜃 𝑐𝑜𝑠𝜃 0] [ 0 1 0]
−xp −yp 1 0 0 1 xp yp 1

𝑐𝑜𝑠𝜃 𝑠𝑖𝑛𝜃 0
Rp = [ −𝑠𝑖𝑛𝜃 𝑐𝑜𝑠𝜃 0]
−xpcosθ + ypsinθ + xp −xpsinθ − ypcosθ + yp 1
References:
Books:
Computer Graphics by Donald Hearn and Baker M. Pauline
Computer Graphics by Maurya Rajesh K.
Websites:
https://www.tutorialspoint.com/computer_graphics/
http://www.nptelvideos.in/2012/11/computer-graphics.html

4.0 Actual Methodology Followed


In order to create any application/program following steps are followed.
• Defining and Analyzing the Problem. In this step, a programmer studies the problem
• Designing the Algorithm and drawing flowcharts
• Coding or Writing the Program
• Test Execution
• Debugging
• Final Documentation.
As each member wanted to learn all the steps, we have done all the activities as a team. each member
was involved in every step.
 On the graph paper, the object is drawn.
 Object coordinates are determined and noted down.
 Apply the transformation to the object or to a required part of object.

Algorithm:
1. Start
2. Find the screen coordinates of object.
3. Set up hour, minute and second counters and initialize to zero.
4. Initialize graphics mode.
5. Draw the object on screen.
6. while (true)
{
apply the rotation transformation to “second” hand of clock.
seconds++;
if (second > 59)
{
seconds = 0;
minutes++;
apply the rotation transformation to “minutes” hand of clock.
}
if (minutes > 59)
{
minutes = 0;
hours++;
apply the rotation transformation to “hours” hand of clock.
}
draw the new object.
delay() of 1 second;
}
7. Stop.

5.0 Actual Resources Used (Mention the actual resources used).

S. No. Name of Specifications Qty Remarks


Resource/material
1 PC Core i3, RAM 4GB 1
2 Operating System Windows 7 1
3 Software Turbo C 1

6.0 Outputs of the Micro-Project


Coding:

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<dos.h>
#define ROUND(a) ((int) a+0.5)

void draw_clock()
{
circle(320,240,100);
circle(320,142,3);
circle(320,338,3);
circle(222,240,3);
circle(418,240,3);
circle(320,240,5);
}

void main()
{

int gd=DETECT,gm,i,j,k;
int px=320, py=240;
double sx1=320,sy1=240,sx2=320,sy2=150;
double mx1=320,my1=240,mx2=320,my2=150;
double hx1=320,hy1=240,hx2=365,hy2=240;
double angle_r = M_PI/30.0;
double xtemp1, ytemp1, xtemp2, ytemp2;
initgraph(&gd,&gm,"c:\\turboc3\\bgi");

draw_clock();
line(sx1,sy1,sx2,sy2);
line(mx1,my1,mx2,my2);
line(hx1,hy1,hx2,hy2);
for(k=0;k<60;k++)
{
for(j=0;j<60;j++)
{
for(i=0;i<60;i++)
{
delay(1000);
xtemp1=sx1; ytemp1=sy1; xtemp2=sx2; ytemp2=sy2;
sx1=cos(angle_r)*xtemp1-sin(angle_r)*ytemp1-px*cos(angle_r)+py*sin(angle_r)+px;
sy1=sin(angle_r)*xtemp1+cos(angle_r)*ytemp1-px*sin(angle_r)-py*cos(angle_r)+py;
sx2=cos(angle_r)*xtemp2-sin(angle_r)*ytemp2-px*cos(angle_r)+py*sin(angle_r)+px;
sy2=sin(angle_r)*xtemp2+cos(angle_r)*ytemp2-px*sin(angle_r)-py*cos(angle_r)+py;

cleardevice();
draw_clock();
line(ROUND(sx1),ROUND(sy1),ROUND(sx2),ROUND(sy2));
line(ROUND(mx1),ROUND(my1),ROUND(mx2),ROUND(my2));
line(ROUND(hx1),ROUND(hy1),ROUND(hx2),ROUND(hy2));
}
sx1=320,sy1=240,sx2=320,sy2=150;
xtemp1=mx1; ytemp1=my1; xtemp2=mx2; ytemp2=my2;
mx1=cos(angle_r)*xtemp1-sin(angle_r)*ytemp1-px*cos(angle_r)+py*sin(angle_r)+px;
my1=sin(angle_r)*xtemp1+cos(angle_r)*ytemp1-px*sin(angle_r)-py*cos(angle_r)+py;
mx2=cos(angle_r)*xtemp2-sin(angle_r)*ytemp2-px*cos(angle_r)+py*sin(angle_r)+px;
my2=sin(angle_r)*xtemp2+cos(angle_r)*ytemp2-px*sin(angle_r)-py*cos(angle_r)+py;

cleardevice();
draw_clock();
line(ROUND(mx1),ROUND(my1),ROUND(mx2),ROUND(my2));
line(ROUND(sx1),ROUND(sy1),ROUND(sx2),ROUND(sy2));
line(ROUND(hx1),ROUND(hy1),ROUND(hx2),ROUND(hy2));

}
mx1=320,my1=240,mx2=320,my2=150;
xtemp1=hx1; ytemp1=hy1; xtemp2=hx2; ytemp2=hy2;
hx1=cos(angle_r)*xtemp1-sin(angle_r)*ytemp1-px*cos(angle_r)+py*sin(angle_r)+px;
hy1=sin(angle_r)*xtemp1+cos(angle_r)*ytemp1-px*sin(angle_r)-py*cos(angle_r)+py;
hx2=cos(angle_r)*xtemp2-sin(angle_r)*ytemp2-px*cos(angle_r)+py*sin(angle_r)+px;
hy2=sin(angle_r)*xtemp2+cos(angle_r)*ytemp2-px*sin(angle_r)-py*cos(angle_r)+py;

cleardevice();
draw_clock();
line(ROUND(hx1),ROUND(hy1),ROUND(hx2),ROUND(hy2));
line(ROUND(mx1),ROUND(my1),ROUND(mx2),ROUND(my2));
line(ROUND(sx1),ROUND(sy1),ROUND(sx2),ROUND(sy2));
}
getch();
closegraph();
}

Output screen snapshot:

7.0 Skill Developed / learning out of this Micro-Project


 Programs to use graphics mode
 Drawing of shapes at desired location of screen
 Applying the transformation operation to objects
 Using delay( ) function

8.0 Applications of this Micro-Project


In animation applications, this project can be used where circular movement of shapes is
required.
9.0 Area of Future Improvement
 Numbers can be added on dial.
 Different color can be used for different hands.
 Instead of only lines, suitable shapes can be used for hands.
 Digital clock can be added inside analog clock.

**************
Roll Name Process Assessment Product Assessment Total
No. Marks

Project Project Project Individual 10


Proposal (2 Methodology Report/ Presentation
marks) (2 marks) Working (4 Marks)
model (2
marks)

You might also like