computer graphics

8
Graphics Project: Composite Transformation of a Simple Object(House) SUBMITTED BY: Shiva Raj Luitel(BEX-070-24) Sagarmatha Engineering College Sanepa Lalitpur 08/27/2022 1

Upload: cvaraz

Post on 19-Feb-2017

80 views

Category:

Engineering


1 download

TRANSCRIPT

Page 1: Computer graphics

05/01/2023 1

Graphics Project:Composite Transformation of a

Simple Object(House)

SUBMITTED BY:Shiva Raj Luitel(BEX-070-24)

Sagarmatha Engineering College Sanepa Lalitpur

shivaraj luitel
Page 2: Computer graphics

05/01/2023 2

Main Objective of the projects

• To illustrate the concept of scaling about the origin• To illustrate the concept of scaling about the arbitrary points• To illustrate the concept of reflection about the line y=mx+c

Page 3: Computer graphics

05/01/2023 3

Scaling about the origin

Scaling is done by multiplying each coordinate of x and y with its scaling factors:

x=x*sx;y=y*sy;

Page 4: Computer graphics

05/01/2023 4

Scaling about the arbitrary point:

Þ Firstly the center(xc,yc) is translated to the origin x=x-xc;y=y-yc;

Þ Then the scaling is donex=x*sx;

y=y*sy;Þ Then finally the the object is translated as:

x=x+xc;y=y+yc;

Page 5: Computer graphics

05/01/2023 5

Reflection about a straight line y=mx+c

=>Firstly the y-intercept is translated to the origin x=x;

y=y-c;Þ Then the object is rotated through angle made with the origin

R(-a)Þ Then the object is reflected about the x-axis X=x;

Y=-y;Þ Now rerotate the objects as R(a)Þ Again the object is translated as:

X=x;Y=y+c

Page 6: Computer graphics

05/01/2023 6

How to draw the axis??• setlinestyle (DOTTED_LINE, 0, 1);//axis creation with dot line• line (320, 0, 320, 480);• line (0, 240, 640, 240);

Page 7: Computer graphics

05/01/2023 7

How to draw the object??

• Firstly the required point to create the object is calculated:val[9][2]={ 50, 50 },{ 75, 50 },{ 75, 75 },{ 100, 75 },{ 100, 50 },{ 125, 50 },{ 125, 100 },{ 87, 125 },{ 50, 100 }

• Then the object is placed at origin through translation as: for (i=0; i<9; i++) {

h[i][0] = val[i][0];h[i][1] = val[i][1];//(0,0),(25,0),(25,25),(50,25),(50,0),(75,0),(75,50),(37,75),(0,50)

}

Page 8: Computer graphics

05/01/2023 8

Contd..Now the object is drawn by the command assetlinestyle (SOLID_LINE, 0, 1);//for creating the object for (i=0; i<8; i++)

line (320+h[i][0], 240-h[i][1], 320+h[i+1][0], 240-h[i+1][1]); line (320+h[0][0], 240-h[0][1], 320+h[8][0], 240-h[8][1]);