<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CS602 Assignment 2 Solution and Discussion]]></title><description><![CDATA[<p dir="auto">Assignment No. 02<br />
Semester: Fall 2019<br />
CS602: Computer Graphics<br />
Total Marks: 20</p>
<p dir="auto">Due Date: 27th November 2019</p>
<p dir="auto">Objective<br />
The objective of this assignment is to;<br />
	Learn and practice basic concepts of computer graphics like pixels, lines, text etc using Dev-C++. (You can download Dev-C++ setup from LMS)<br />
	Learn to draw lines and rigid bodies by using graphics library functions.<br />
	Learn the concepts of filled area primitives.<br />
	Learn the basic transformations with fundamental matrix operations.<br />
Instructions:<br />
You have to do the following steps first in order to perform the task.</p>
<ol>
<li>Install Dev-C++ from your LMS.</li>
<li>Read out the file “Add graphics in Dev cpp” thoroughly and follow the instructions in the file properly provided to you on your LMS.<br />
Please read the following instructions carefully before submitting assignment:</li>
<li>You should consult the recommended books, PowerPoint slides , Handouts and video lectures to clarify your concepts.</li>
<li>You can take any help from your provided labs.</li>
<li>It should be clear that your assignment will not get any credit if:<br />
•	The assignment is submitted after due date.<br />
•	The assignment is copied from Internet or from any other student.<br />
•	The submitted assignment does not open or file is corrupt.<br />
Submission<br />
You are required to submit your solution through LMS in zip format containing following files.<br />
	Your Project in zipped form containing both .cpp and .exe file.</li>
</ol>
<p dir="auto">The word document (.doc/docx) or any other file format containing code will not be considered.<br />
If the code files are missing in zip folder, your assignment will be awarded as zero.</p>
<p dir="auto">Note: No assignment will be accepted after the due date through email in any case (load shedding, server down, internet malfunctioning etc.).<br />
It is recommended to upload solution file at least two days before its closing date.<br />
For any query about the assignment, contact at <a href="mailto:cs602@vu.edu.pk" target="_blank" rel="noopener noreferrer nofollow ugc">cs602@vu.edu.pk</a></p>
<p dir="auto">TASK                                                                                                                                       Marks=20<br />
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:</p>
<ol>
<li>
<p dir="auto">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’.<br />
<img src="https://i.imgur.com/LVTwJo8.png" alt="109685f2-892c-4b64-bde0-934172d11396-image.png" class=" img-fluid img-markdown" /></p>
</li>
<li>
<p dir="auto">Now apply translation to the original house and move it to new location on the screen. Mark the translated picture as ‘Translated’.<br />
<img src="https://i.imgur.com/SfFmXkG.png" alt="a7bd2850-75e2-4080-bf14-860a395c7cac-image.png" class=" img-fluid img-markdown" /></p>
</li>
<li>
<p dir="auto">Now scale the original house by sx=2 and sy=2 and display it somewhere on the screen.<br />
<img src="https://i.imgur.com/5XRLUR8.png" alt="e723754f-a3ef-4b7f-85ba-8f744b6f8a8b-image.png" class=" img-fluid img-markdown" /></p>
</li>
<li>
<p dir="auto">Take reflection along x axis of the original house and display it somewhere on the screen. Mark it as ‘Reflection along x axis’.<br />
<img src="https://i.imgur.com/w9uk2gx.png" alt="984f8434-11d7-47c8-b58a-4ac09b375760-image.png" class=" img-fluid img-markdown" /></p>
</li>
</ol>
<p dir="auto">Write a code in c++ to implement above functions. It will be a good programming practice that you implement it by creating house class.</p>
]]></description><link>https://community.secnto.com//topic/684/cs602-assignment-2-solution-and-discussion</link><generator>RSS for Node</generator><lastBuildDate>Tue, 09 Jun 2026 00:55:35 GMT</lastBuildDate><atom:link href="https://community.secnto.com//topic/684.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 28 Nov 2019 08:14:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CS602 Assignment 2 Solution and Discussion on Thu, 28 Nov 2019 08:17:17 GMT]]></title><description><![CDATA[<pre><code>//&lt;!--CS602 ASSIGNMENT 2 SOLUTION--&gt;
//&lt;!--FALL 2019--&gt;
//&lt;!--DUE DATE: 27 NOVEMBER, 2019--&gt;
//PRE-PARED BY: SUPERSTARWEBTECH.COM
//CONNECT WITH US:FACEBOOK.COM/SUPERSTARWEBTECH
//E-MAIL: SUPERSTARWEBTECH@GMAIL.COM

#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;conio.h&gt;
#include &lt;graphics.h&gt;
#include &lt;math.h&gt;

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(&amp;gd,&amp;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();

}
//&lt;!--NOTE--&gt;
//&lt;!--MAKE CHANGES ACCORDING TO YOUR REQUIREMENTS--&gt;
//&lt;!--DO NOT POST ON OTHER PORTALS THIS WILL LEAD TO COPYING OF CODE AND THEN YOU WILL GET ZERO MARKS FOR IT--&gt;
//&lt;!--PLUS TYPE YOUR OWN SOLUTION FOR NOT LOSING MARKS--&gt;
//&lt;!--DO NOT COPY PASTE--&gt;
//&lt;!--WE ARE NOT RESPONSIBLE FOR GETTING ZERO MARKS IN ASSIGNMENT--&gt;
//PRE-PARED BY: SUPERSTARWEBTECH.COM
//CONNECT WITH US:FACEBOOK.COM/SUPERSTARWEBTECH
//E-MAIL: SUPERSTARWEBTECH@GMAIL.COM

CS602_2_FALL_2019.txt
Displaying CS602_2_FALL_2019.txt.
</code></pre>
]]></description><link>https://community.secnto.com//post/1956</link><guid isPermaLink="true">https://community.secnto.com//post/1956</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Thu, 28 Nov 2019 08:17:17 GMT</pubDate></item><item><title><![CDATA[Reply to CS602 Assignment 2 Solution and Discussion on Thu, 28 Nov 2019 08:15:21 GMT]]></title><description><![CDATA[<p dir="auto"><a href="https://www.youtube.com/watch?v=NrCtdl-Cx38&amp;t=5s" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.youtube.com/watch?v=NrCtdl-Cx38&amp;t=5s</a></p>
]]></description><link>https://community.secnto.com//post/1955</link><guid isPermaLink="true">https://community.secnto.com//post/1955</guid><dc:creator><![CDATA[zareen]]></dc:creator><pubDate>Thu, 28 Nov 2019 08:15:21 GMT</pubDate></item></channel></rss>