Ask C/C++ Expert


Home >> C/C++

The second project builds on the first project by adding the ability to specify transformations of some of the graphic objects. The specification for those objects now will require less information about their position and size because both will be able to be modified using the transformations. As before, you must complete the skeleton project provided by defining some of the remaining classes. The UML diagram for the whole project is shown below:

The code for all the classes shown in black is provided in the attached .zip file.  You must complete the project by writing those classes shown in red. The skeleton project contains a parser that will parse a scene definition file that defines the scene to be displayed. The new grammar for the scene definition file is shown below:

        scene -> SCENE IDENTIFIER number_list graphics END '.'

        graphics -> graphic graphics | graphic

        graphic -> text | transformable_graphic transformations END

        transformable_graphic -> isosceles | parallelogram | regular_polygon

        isosceles -> ISOSCELES COLOR number_list ANGLE NUMBER ';'

        parallelogram -> PARALLELOGRAM COLOR number_list ANGLE NUMBER ';'

        regular_polygon -> REGULAR_POLYGON COLOR number_list SIDES NUMBER RADIUS NUMBER ';'

        text -> TEXT COLOR number_list AT number_list STRING ';'

        transformations -> transformation transformations | transformation

        transformation -> rotation | scaling | translation

        rotation -> ROTATE ANGLE NUMBER ';'

        scaling -> SCALE number_list ';'

        translation -> TRANSLATE number_list ';'

        number_list -> '(' numbers ')'

        numbers -> NUMBER | NUMBER ',' numbers

Below is a description of the modifications required to each of the five classes from the first project:

1.The Text class is unchanged from the first project.

2.The ConvexPolygon class must now have an additional data element, which is a vector of pointers to Transformations. The constructor must now be passed this vector in addition to what was previously required. The draw function must now perform each of the transformations before drawing the object.

3.The constructor for the IsoscelesTriangle class will now require the list of transformation and the color, but the only information specifying the shape will the angle of the top vertex. The base of the triangle should be centered at the origin and the height of the triangle should be 1.  It should perform the transformations using the built in functions of OpenGL, glTranslatedglRotated, and glScaled for translating, rotating and scaling respectively.

4.The constructor for the Parallelogram class will now require the list of transformation and the color, but the only information specifying the shape will be the angle of the lower left vertex. The lower left vertex should be placed at the origin, the top and bottom sides should be parallel to the x-axis and all sizes should have a length of 1. It should perform the transformations using the built in matrix multiplication function of OpenGL, glMultMatrixd.

5.The constructor of the RegularPolygon class will now require the list of transformation and the color, but the only information specifying the shape will be the number of sides. The center of the polygon should be placed at the origin and the radius should be 1.   It should perform the transformations using the built in functions of OpenGL, glTranslatedglRotated, and glScaled for translating, rotating and scaling respectively.

In addition to modifying the above classes, you must write the following new classes:

1.The Rotation class must have a member variable containing the angle of rotation, which is passed to and saved by the constructor, so that it can be used to call the rotate method defined in the Transformable interface, when the transform method that it is required to implement, is called.

2.The Translation class must have member variables containing the x and y distances of translation, which are passed to and saved by the constructor, so that they can be used to call the translate method defined in the Transformable interface, when the transform method that it is required to implement, is called.

3.The Scaling class must have member variables containing the x and y scale factors, which are passed to and saved by the constructor, so that they can be used to call the scale method defined in the Transformable interface, when the transform method that it is required to implement, is called.

Sample Input and Output

Below is a sample of a scene definition file that would provide input to the program:

        Scene Polygons (500, 500)

          Isosceles Color (0.0, 0.0, 1.0) Angle 90;

            Rotate Angle 45;

            Translate (100.0, 0.0);

            Scale (50.0, 50.0);

          End

          RegularPolygon Color (1.0, 0.0, 0.0) Sides 7;

            Translate (-100.0, 0.0);

            Scale (75.0, 75.0);

          End

          Parallelogram Color (0.0, 1.0, 0.0) Angle 45;

            Rotate Angle 45;

            Translate (100.0, -100.0);

            Scale (90.0, 90.0);

          End

          Text Color(0.0, 0.0, 0.0) at (-200., 200.) "Hello World";

        End.

Shown below is the scene that should be produced when the program is provided with the above scene definition.

1466_Scene.png

Project Questions

If you have any questions about the this project, post them in the "Ask the Professor" discussion.

Attachment:- Project.zip

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M91564644
  • Price:- $65

Priced at Now at $65, Verified Solution

Have any Question?


Related Questions in C/C++

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As