CS602 Assignment 2 Solution and Discussion


  • Cyberian's Gold

    Assignment No. 02
    Semester: Fall 2019
    CS602: Computer Graphics
    Total Marks: 20

    Due Date: 27th November 2019

    Objective
    The objective of this assignment is to;
     Learn and practice basic concepts of computer graphics like pixels, lines, text etc using Dev-C++. (You can download Dev-C++ setup from LMS)
     Learn to draw lines and rigid bodies by using graphics library functions.
     Learn the concepts of filled area primitives.
     Learn the basic transformations with fundamental matrix operations.
    Instructions:
    You have to do the following steps first in order to perform the task.

    1. Install Dev-C++ from your LMS.
    2. Read out the file “Add graphics in Dev cpp” thoroughly and follow the instructions in the file properly provided to you on your LMS.
      Please read the following instructions carefully before submitting assignment:
    3. You should consult the recommended books, PowerPoint slides , Handouts and video lectures to clarify your concepts.
    4. You can take any help from your provided labs.
    5. It should be clear that your assignment will not get any credit if:
      • The assignment is submitted after due date.
      • The assignment is copied from Internet or from any other student.
      • The submitted assignment does not open or file is corrupt.
      Submission
      You are required to submit your solution through LMS in zip format containing following files.
       Your Project in zipped form containing both .cpp and .exe file.

    The word document (.doc/docx) or any other file format containing code will not be considered.
    If the code files are missing in zip folder, your assignment will be awarded as zero.

    Note: No assignment will be accepted after the due date through email in any case (load shedding, server down, internet malfunctioning etc.).
    It is recommended to upload solution file at least two days before its closing date.
    For any query about the assignment, contact at [email protected]

    TASK Marks=20
    This task is based on the concepts of basic transformations like translation, scaling and reflection (along axis) of a rigid body. For this purpose you have to implement the following:

    1. You have to make the house with basic shapes as shown in figure. At the top right corner, your VU-ID must be displayed. Mark this picture as ‘Original’.
      109685f2-892c-4b64-bde0-934172d11396-image.png

    2. Now apply translation to the original house and move it to new location on the screen. Mark the translated picture as ‘Translated’.
      a7bd2850-75e2-4080-bf14-860a395c7cac-image.png

    3. Now scale the original house by sx=2 and sy=2 and display it somewhere on the screen.
      e723754f-a3ef-4b7f-85ba-8f744b6f8a8b-image.png

    4. Take reflection along x axis of the original house and display it somewhere on the screen. Mark it as ‘Reflection along x axis’.
      984f8434-11d7-47c8-b58a-4ac09b375760-image.png

    Write a code in c++ to implement above functions. It will be a good programming practice that you implement it by creating house class.


  • Cyberian's Gold

    //<!--CS602 ASSIGNMENT 2 SOLUTION-->
    //<!--FALL 2019-->
    //<!--DUE DATE: 27 NOVEMBER, 2019-->
    //PRE-PARED BY: SUPERSTARWEBTECH.COM
    //CONNECT WITH US:FACEBOOK.COM/SUPERSTARWEBTECH
    //E-MAIL: [email protected]
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <graphics.h>
    #include <math.h>
    
    class House
    {
    	private:
    		int x1,x2,x3,x4,x5;
    		int y1,y2,y3;
    		int dx1, dx2;
    		int dy1, dy2;
    		
    		int xc,yc;
    		
    	public:
    		House()
    		{
    		xc=45;
    		yc=65; //center of figure
    		
    		x1=30;
    		x2=x1+50;
    		x3=20;
    		x4=x3+20;
    		x5=x4+50;
    
    		y1=30;
    		y2=y1+20;
    		y3=y2+50;
    
    		dx1=x3+5;
    		dx2=dx1+10;
    		dy1=y2+30;
    		dy2=dy1+20;
    		}
    		
    		void translate(int tx, int ty) //draw translate house
    		{
    			x1+=tx;
    			x2+=tx;
    			x3+=tx;
    			x4+=tx;
    			x5+=tx;
    		
    			y1+=ty;
    			y2+=ty;
    			y3+=ty;
    			
    			dx1+=tx;
    			dx2+=tx;
    			
    			dy1+=ty;
    			dy2+=ty;
    		}
    		
    		void scale(int sx, int sy) //draw scaled house
    		{
    			x1=xc+(x1-xc)*sx;
    			x2=xc+(x2-xc)*sx;
    			x3=xc+(x3-xc)*sx;
    			x4=xc+(x4-xc)*sx;
    			x5=xc+(x5-xc)*sx;
    			
    			y1=yc+(y1-yc)*sy;
    			y2=yc+(y2-yc)*sy;
    			y3=yc+(y3-yc)*sy;
    			
    			dx1=xc+(dx1-xc)*sx;
    			dx2=xc+(dx2-xc)*sx;
    			
    			dy1=yc+(dy1-yc)*sy;
    			dy2=yc+(dy2-yc)*sy;
    			
    		}
    
    		void reflectx(int rx)
    		{
    			y1=-y1+rx;
    			y2=-y2+rx;
    			y3=-y3+rx;
    		
    			dy1=-dy1+rx;
    			dy2=-dy2+rx;
    		}
    		
    		void reflecty(int ry)
    		{
    			x1=-x1+ry;
    			x2=-x2+ry;
    			x3=-x3+ry;
    			x4=-x4+ry;
    			x5=-x5+ry;
    			
    			dx1=-dx1+ry;
    			dx2=-dx2+ry;
    		}
    		
    		void drawH() //draw house
    		{
    			int arr[]={x1,y1,x2,y1,x5,y2,x5,y3,x3,y3,x3,y2,x1,y1,x4,y2,x4,y3,x3,y3,x3,y2,x5,y2};
    			drawpoly(12,arr); //draw house
    
    			rectangle(dx1,dy1,dx2,dy2); //draw house door
    
    		}
    		void fillH()
    		{
    			setfillstyle(HATCH_FILL,GREEN);
    			floodfill(x1+1,y1+10,WHITE);
    			floodfill(x1+1,y1+1,WHITE);
    
    			setfillstyle(SOLID_FILL,RED);
    			floodfill(x3+1,y2+1,WHITE);
    
    			setfillstyle(SOLID_FILL,YELLOW);
    			floodfill(x4+1,y2+1,WHITE);
    
    			setfillstyle(SOLID_FILL,GREEN);
    			floodfill(dx1+1,dy1+1,WHITE);
    		}
    		
    		void fillH2(){
    			setfillstyle(HATCH_FILL,GREEN);
    			floodfill(x1+1,y1-10,WHITE);
    			floodfill(x1+1,y1-1,WHITE);
    
    			setfillstyle(SOLID_FILL,RED);
    			floodfill(x3+1,y2-1,WHITE);
    
    			setfillstyle(SOLID_FILL,YELLOW);
    			floodfill(x4+1,y2-1,WHITE);
    
    			setfillstyle(SOLID_FILL,GREEN);
    			floodfill(dx1+1,dy1-1,WHITE);
    		}
    };
    
    int main()
    {
    int gd=DETECT, gm;
    initgraph(&gd,&gm,(char*)" ");
    setcolor(WHITE);
    settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);
    outtextxy(2, 2, (char*)"BC123456789");
    
    House house;
    
    //draw main house
    house.drawH();
    house.fillH();
    outtextxy(2, 110, (char*)"1) Original");
    //draw translated house
    house.translate(200,0);
    house.drawH();
    house.fillH();
    outtextxy(200, 110, (char*)"2) Translated");
    
    //draw scaled house
    house.translate(-190,70);
    house.scale(2,2);
    house.drawH();
    house.fillH();
    outtextxy(2, 280, (char*)"3) Scaled");
    
    int x=90;
    int y=350;
    
    House h2;
    // draw reflected house
    h2.translate(200,70);
    h2.reflecty(x);
    h2.reflectx(y);
    h2.reflecty(x);
    h2.drawH();
    h2.fillH2();
    outtextxy(200, 270, (char*)"4) Reflected");
    
    getch();
    closegraph();
    
    }
    //<!--NOTE-->
    //<!--MAKE CHANGES ACCORDING TO YOUR REQUIREMENTS-->
    //<!--DO NOT POST ON OTHER PORTALS THIS WILL LEAD TO COPYING OF CODE AND THEN YOU WILL GET ZERO MARKS FOR IT-->
    //<!--PLUS TYPE YOUR OWN SOLUTION FOR NOT LOSING MARKS-->
    //<!--DO NOT COPY PASTE-->
    //<!--WE ARE NOT RESPONSIBLE FOR GETTING ZERO MARKS IN ASSIGNMENT-->
    //PRE-PARED BY: SUPERSTARWEBTECH.COM
    //CONNECT WITH US:FACEBOOK.COM/SUPERSTARWEBTECH
    //E-MAIL: [email protected]
    
    CS602_2_FALL_2019.txt
    Displaying CS602_2_FALL_2019.txt.
    

  • Cyberian's Gold



Jan
27
(2 Views / 0 Upvotes)
0 Replies

10. COGNITIVE | CLOUD COMPUTING
709a4b58-3423-4963-9e29-bd995cadb5fc-image.png
Cloud computing is the on-demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. The term is generally used to describe data centers available to many users over the Internet.

Aug
19
(33 Views / 0 Upvotes)
2 Replies

Dear Students if you have any query regarding Final Term Exam
Please Feel Free to Ask Cyberian’s

Sep
18
(29 Views / 0 Upvotes)
0 Replies

یہ ۵ جی کیا ہے؟
دوسرے سیلولر نیٹ ورکوں کی طرح ، 5 جی نیٹ ورک سیلولرکلز کرنے کے انتظامات کو استعمال کرتے ہیں جو اپنے ڈومین کو علاقوں میں الگ کرتے ہیں اور ریڈیو لہروں کے ذریعہ انکوڈڈ معلومات بھیجتے ہیں۔ ہر سیل سائٹ کو سسٹم کی ریڑھ کی ہڈی سے وابستہ ہوتا ہے، اس سے قطع نظر کہ وائرڈ یا ریموٹ بیک ہاؤل ایسوسی ایشن کے ذریعے۔ 5 جی نیٹ ورک ایک قسم کی انکوڈنگ کا استعمال کریں گے جسے آف ڈی ایم کہتے ہیں ، جو انکوڈنگ کی طرح ہے جس میں 4 جی ایل ٹی ای کام کرتا ہے۔ تاہم ، ہوائی انٹرفیس کا مقصد...

Dec
17
(15 Views / 0 Upvotes)
21 Replies

Live Updates:
Pakistan’s former dictator Pervez Musharraf was on Tuesday sentenced to loss of life in the excessive treason case by way of a special court docket here, turning into the first navy ruler to get hold of the capital punishment in the country’s history.
567e9088-009d-47b4-a689-988ca233129e-image.png
A three-member bench of the special courtroom, hea...

Sep
6
(44 Views / 0 Upvotes)
0 Replies

فیس بک ڈیٹنگ اپنی پسند کی چیزوں کے ذریعہ پیار تلاش کرنا آسان بناتا ہے - اپنی مشترکہ چیزوں ، جیسے مفادات ، واقعات اور گروہوں کے ذریعہ معنی خیز تعلقات شروع کرنے میں مدد کرتا ہے۔ یہ ڈیٹنگ پروفائل بنانے میں کام کرتا ہے اور آپ کو زیادہ مستند نظر دیتا ہے کہ کوئی کون ہے۔
a5068e0f-944c-4e27-b28d-bec69b167543-image.png
آج ، ہم امریکہ میں فیس بک ڈیٹنگ کا آغاز کر رہے ہیں۔ ہم لوگوں کو انسٹاگرام ...

Aug
22
(101 Views / 1 Upvotes)
1 Replies

I’d say as a blogger and a IT student that it’s a great achievement for a local operator. As we know, communication is expanding globally and we do need faster networks to communicate.
IMG_20190822_194412.jpg

I’d say as a blogger and a IT student that it’s a great achievement for a local operator. As we know, communication is expanding globally and we do need faster netwo...

Sep
6
(15 Views / 0 Upvotes)
0 Replies

b244dd88-39a0-47bb-95f5-5af7cf1991c7-image.png

Image: justin sullivan / Getty Images

کمپنی نے منگل کو اعلان کیا کہ فیس بک اپنی چہرے کی شناخت کی خصوصیات کو بند کرنے میں آسان تر بنا رہا ہے اور اب وہ خود بخود نئے صارفین کو فیس ٹیگنگ کا انتخاب نہیں کرے گا۔

فیس بک اپنے صارفین کے اپ لوڈ کردہ فوٹو میں چہروں کی شناخت کے لئے چہرے کی پہچان کا استعمال...

Aug
6
(22 Views / 0 Upvotes)
0 Replies

Join the celebration at the all-new Apple Aventura.
Our new location opens Saturday, August 10 at 10:00 a.m.
Join us for the grand opening of our new store - located in a bigger space right across from the Aventura Slide Tower. Come celebrate your creativity during opening weekend with free Today at Apple sessions in music, photography, art, and more. And enjoy our vibrant Latin Music Fridays happening throughout the month of August.

Sep
6
(21 Views / 0 Upvotes)
0 Replies

آئی فونز اور ہیکرز پر حالیہ ہیک حملے کی وجہ سے جس کو دنیا میں سب سے زیادہ محفوظ فون سمجھا جاتا تھا اس کی سیکیورٹی کو نظرانداز کیا جارہا ہے۔ کیا آپ کو ایسی کوششوں سے بچایا گیا ہے؟ آپ خود کو ڈیجیٹل طور پر کیسے محفوظ کرسکتے ہیں؟

آئی فون ہیکنگ آپریشنوں کی ایک حالیہ لہر جنہوں نے جنوری تک “ایک ہفتے میں ہزاروں صارفین” کو متاثر کیا ، گوگل کے پروجیکٹ زیرو سیکیورٹی ٹیم کے محققین نے انکشاف کیا ہے۔ ایپل کے آئی فونز کو بڑے پیمانے پر وہاں کے سب سے محفوظ آلات سمجھا جاتا ہے۔ واقع...

Jul
31
(144 Views / 0 Upvotes)
1 Replies

To register your device, go to this link and create your account as an individual user. Select your user type International traveler
On submission of Signup form, a confirmation link will be received in your provided email address. Cl...

    Recent Topics


  • 1
  • 4
  • 1
  • 5
  • 2
  • 1
  • 1
  • 8
| DMCA.com Protection Status