Transformations of the graphic objects

Assignment Help C/C++ Programming
Reference no: EM13890560

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

Reference no: EM13890560

Questions Cloud

Home games on wednesday and saturday : A baseball team has home games on wednesday and saturday. the two games together earn $5180.00 for the team. wednesdays game generates $120.00 less than saturday's game. how much money was taken in at each game?
Even motivator needs motivating sometimes : Although, suicide is three times greater in police officers than the national average, I believe alcohol abuse is a more likely response to stress. Primarily, because a large number people of legal drinking age consume alcohol casually to relax fr..
Major challenges that this character is facing in his life : Existing learning - What types of learning mechanisms or processes are occurring in this case material? In other words, what is the character learning and how? Existing challenges - What are the major challenges that this character is facing in his..
Company''s income statement and statement of owner''s equity : 1.Following is the unadjusted trial balance for Augustus Institute as of December 31, 2013, which initially records prepaid expenses and unearned revenues in balance sheet accounts.
Transformations of the graphic objects : 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 b..
Identify how you would contact the program : Select a family related issue (i.e. substance abuse, domestic violence, military deployment) and locate an existing program in Texas that addresses this issue. In order to identify a program within your community, do an internet search for marriag..
How walker is managing depressing situations : There is especially potential for this method to be used later on in Walker's life when him and his wife begin to have trouble. Needless to say, appropriate coping strategies are key in order for police officer to maintain their mental health (Cro..
Differentiate between descriptive and inferential statistics : Differentiate between descriptive and inferential statistics. What information do they provide? What are their similarities and differences? Your answer should be 175 words
Explain the relevant points in the contentions of parties : Facts of the Case: Describe the key facts in the case with roles and responsibilities of forensic psychology professionals. Contentions of the Parties: Explain the relevant points in the contentions of the parties. Issue: Describe the issue from the ..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd