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 top-down modular approach to design program

Use the top-down modular approach and pseudocode to design a suitable program to solve it. Where appropriate, use defensive programming techniques.

  What is the approximate value of square root 41

What is the approximate value of square root 41?

  Attribute information about an array of floating point

Write a program that contains a main function and three other functions that will return various attribute information about an array of floating point

  Design class for textbook-data field for grade level of book

Design a class named TextBook that is child class of Book. Include new data field for grade level of book. Create a displayTextBookInfo () method so that you can accommodate new grade-level field.

  Write a program to calculate the twelve days of christmas

Write a program to calculate the Twelve Days Of Christmas. The program requests a integer from 1-12 and then lists the gift for that day and the costs.

  To arrange the elements of an integer array

Write a ‘C’ functions to arrange the elements of an integer array in such a way that all the negative elements are before the positive elements. The array is passed to it as an argument.

  What constructors do and when they are executed

Explain what constructors do and when they are executed. Explain the two types of constructors. Provide an example class that includes both types of constructor functions and demonstrate how an object would be instantiated using both types of constru..

  Task your task is to write a simple program that converts

task your task is to write a simple program that converts between app and ppm values. the screenshots below

  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 one input function to input one number

Write one input function to input one number, returning that value via the return statement to the calling function. You will need to call this function 4 times to get all 4 values

  Implement a function which finds the largest number

Write a function named largest which will receive the array as input and return the variable LargestNumber.

  Prompts the user to input the shipping cost per liter

Write a program that does the Prompts the user to input the dimensions (in feet) of the container (radius the container (radius of the base and the height)

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