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

  Use the lengthof the side as a member variable of the class

write a class including four member functions to compute the areas of an equilateral triangle ,square,hexagon and octagon respectively .Use the lengthof the side as a member variable of the class.

  Write a function named xytopolar

Write a function named "XYtoPolar" that has 2 double value parameters and 2 double reference parameters that converts x,y coordinates to polar coordinates. The prototype is: void XYtoPolar(double x, double y, double* angle, double* radius);

  Write a program that allows users to enter a dollar amount

Write a program that allows users to enter a dollar amount for their bank account balance at the beginning of the month. Then ask the user to enter a dollar amount for any number of checks written in a month, up to 50. Include an approriate sentinel ..

  The actual solution of the equation shall be done

The actual solution of the equation shall be done by a function named equSolver(), which takes three coefficients as parameters and returns a structure of three fields: two roots (if they exist) and a boolean indicator, whether the roots do exist.

  Create a template class

Create a template class, SVector, that implements a constructor

  Implement a standard sorted linked list class

Write C++ Program:Implement a standard SORTED linked list class. Be sure to include constructor/copy constructor, destructor, and assignment operator overload.

  The second argument to the function is the string

The function fnUserBinaryInputX has 2 input arguments, each is a string. The first string is the "prompt" string displayed to the user when asked to enter a string. The second argument to the function is the string to compare the user entered stri..

  Create the switch statement to implement set of conditions

Create the necessary switch statement to implement this set of conditions.

  Program reads the contents of employees

Design a program that reads the contents of the employees.dat file and prints all the data within it. Format the report as designated in the Printer Spacing Chart below.

  Create a graphical (not text-based) visual c++ program

Create a graphical (not text-based) Visual C++ program that allows the user to enter the coefficients for a system of four equations with four unknowns. Include a button that when clicked, will solve the system of equations and display the results in..

  Write a class with name time

Write a class with name Time. Make a constructor which calculates the given time in minutes

  Compute for the monthly billing of their customers

An electric company wants to compute for the monthly billing of their customers. the company charges P2.50 per kwh and utility tax of 3% of the current bill shall be added.

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