CS602 Assignment 2 Solution and Discussion Spring 2020
-
Re: CS602 Assignment 2 Solution and Discussion
Assignment No. 02
Semester: Spring 2020
CS602: Computer Graphics
Total Marks: 20Due Date: 15 June 2020
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 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.- Install Dev-C++ from your LMS.
- 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: - You should consult the recommended books, PowerPoint slides , Handouts and video lectures to clarify your concepts.
- You can take any help from your provided labs.
- 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 shearing (along x direction) of a rigid body. For this purpose, you must implement the following:-
You must make the pentagon having five corners as shown in figure. Mark this picture as ‘Original’.
-
Now apply shearing along x direction with shx=4 to the original pentagon. Mark the picture as ‘Sheared along x-axis’. (Your results of shearing could be different than the picture shown as per pixels taken)
-
Now scale the original pentagon by sx=2 and sy=3 and display it on the screen.
-
Translate the original picture somewhere on screen. Mark it as “Translated”.
Write a code in c++ to implement above functions. It will be a good programming practice that you implement it by creating pentagon class.
-
-
#include<stdio.h> #include<conio.h> #include<graphics.h> #include<math.h> #include<iostream> using namespace std; int main() { int gd, gm=DETECT; initgraph(&gd, &gm, ""); settextstyle(8,0,1); outtextxy(60,5,"CS602 Assignment No. 2 Solution by VU ACADEMY"); outtextxy(10,35,"1) Original"); setfillstyle(XHATCH_FILL, GREEN); int arr[] = {50, 90, 80,70, 110, 90, 110, 120, 50, 120, 50,90}; fillpoly(6, arr); // x = x+4y outtextxy(250,35,"2) Sheared Along X Axis"); setfillstyle(XHATCH_FILL, GREEN); //int arr2[] = {200, 70, 230,50, 260, 70, 260, 100, 200, 100, 200,70}; int arr2[] = {330, 90, 280,70, 390, 90, 510, 120, 450, 120, 330,90}; fillpoly(6, arr2); // x = 2x // y = 2y outtextxy(10,200,"3) Scaled"); setfillstyle(XHATCH_FILL, GREEN); //int arr3[] = {50, 300, 80,280, 110,300, 110, 330, 50, 330, 50,300}; int arr3[] = {50, 300, 110,240, 170,300, 170, 390, 50, 390, 50,300}; fillpoly(6, arr3); outtextxy(250,200,"1) Translated"); setfillstyle(XHATCH_FILL, GREEN); int arr4[] = {300, 300, 330,280, 360, 300, 360, 330, 300, 330, 300,300}; fillpoly(6, arr4); getch(); closegraph(); return 0; }


100% Off on Your FEE Join US! Ask Me How?


