Compute overall scale factors by raising the scale factor

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

The third project builds on the second project by adding the ability to specify animations of the transformations. The UML diagram for the new version of the project is shown below:

1305_UML diagram.png

All the classes shown in black are unchanged from project 2. There is only one new class shown in red, Animator, which should be a singleton object. It should keep track of whether an animation is currently in process and if so, what step of the animation is currently being drawn. It should have functions to start, pause, and reset the animation. These functions need to be called by the keyboard callback function. It should also have a function to advance to the next step of the animation, which should be called by the timer callback function. Finally it needs functions to return whether an animation is in progress and one to return the current step of the animation. Those functions will need to be called by the Transformation class.

The remaining classes shown in blue will require the following modifications:

1. Two new callback functions must be added to the main project3.cpp source file. The first function is one that is called when a timer is fired. If the animation is running it advances to the next step by calling the appropriate function in the Animator class described above and then redraws the scene. The second is one that is called when a character is typed on the keyboard. It should start the animation when the letter s is typed, pause it when p is typed and reset the animation back to the initial state when an r is typed. Callbacks for both of these functions must be registered in main.

2. The Parser class must be modified to add the option of including animation steps on each transformation. The revised grammar is shown below, with the change highlighted in red:

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 -> action steps
action -> rotation | scaling | translation
steps -> STEP NUMBER TO NUMBER ';' | ';'
rotation -> ROTATE ANGLE NUMBER
scaling -> SCALE number_list
translation -> TRANSLATE number_list
number_list -> '(' numbers ')'
numbers -> NUMBER | NUMBER ',' numbers

The modified parser and corresponding token file are provided in the attached .zip file.

3. TheTransformation interface from project 2 must now become an abstract class, which now will contain an overloaded function transform, which is not a virtual function. It should determine whether the animation is currently running and if necessary, invoke the virtual transform function supplying it the current step of the animation.

4. The Rotation class must be modified so the the transform function computes the total rotation angle by multiplying the angle of rotation by the step of the animation, before performing the rotation.

5. The Translation class must must be modified so the the transform function computes the total translation distances by multiplying the translation distances by the step of the animation, before performing the translation.

6. The Scaling class must must be modified so the the transform function computes the overall scale factors by raising the scale factor to the power defined by the current step of the animation.

Sample Input and Output

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

Scene Polygons (500, 500)

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

Scale (20.0, 20.0);

Translate (-0.2, 0.2) Step 1 to 25;

Scale (1.3, 1.3) Step 25 to 28;

Rotate Angle 30 Step 31 to 42;

End

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

Scale (1.5, 1.5) Step 61 to 71;

Translate (0.1, 0.1) Step 72 to 80;

Rotate Angle 45 Step 81 to 84;

End

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

Scale (50.0, 50.0);

Rotate Angle 36.0 Step 91 to 100;

End

Text Color(0.0, 0.0, 0.0) at (5.0, 150.) "Hello World";

End.

Shown below is a Flash movie of how the above input should look when run.

Attachment:- cp.zip

Reference no: EM13896117

Questions Cloud

Proper coding conventions required the first letter of class : The files must be called  (driver) (handles house variables and methods) Proper coding conventions required the first letter of the class start with a capital letter
Is the information contained in the articles reliable? : Is the information contained in the articles reliable? Explain
What does the result of part a tell us : A random sample of 64 with a mean of 50 and a standard deviation of 20 is taken from a population of 800. Find an interval estimate for the population mean such that we are 95% con?dent that the interval includes the population mean.
What is the main advantage of assessing the welfare impact : What is the main advantage of assessing the welfare impact of a merger by looking at its ‘external effect'? Explain in words the condition under which this external effect is positive.
Compute overall scale factors by raising the scale factor : Finally it needs functions to return whether an animation is in progress and one to return the current step of the animation. Those functions will need to be called by the Transformation class and the Scaling class must must be modified so the the ..
Establishing families through adoption : One can consider the financial status of fathers; fathers stepping up and taking on the role and regaining their parental rights; and, gay men are more open and accepted to live their lives freely by establishing families through adoption.
What is the fetishism of commodities : What is the fetishism of commodities, where does it come from, and how does Marx establish the existence of the fetish aspect of the commodity? Be sure to relate the concept of commodity fetishism to the discussion of the value and exchange value ..
Reggit company held the following short term investments : Prepare the December 31, 2013, adjusting entry to report these investments at fairvalue.
Explain why competition authorities encourage colluding firm : Explain why competition authorities encourage colluding firms and their employees to report incriminating evidence through leniency and whistleblowing programmes.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a function named read_line

supposes you have a directory whose name is stored in 'specs.file_dir' which contains a file whose name is stored in 'specs.file_name'.

  Create a text file named grades.txt

Write a program to calculate students' average test scores and their grades. Creat a text file named  grades.txt

  How the project teams and coaches master agile methodology

Analyze how the project teams and coaches master the agile methodology to solve business problems. Highlight the one that you believe is the most effective and support your answer.

  Principles of programming with c++

Name The players name, formatted as I.s where I is the initial of the player's first name and s is the player's surname.

  Implement a class to represent a matrix

Implement a class to represent a matrix. While doing this exercise, you are allowed only to use C++ primitive types and arrays. You may not use STL in your Matrix definition. You must use dynamic memory.

  Write a c++ program containing a linked list of 10 integer

Write a C++ program containing a linked list of 10 integer numbers. Have the program display the numbers in the list.

  Perpetual preferred stock

1) Johnson Corporation JUST PAID a dividend of $4.63.  The expected growth rate on dividends is 8 percent.  What is the current price of this stock if the required rate of return is 10 percent?

  Write c program to find smallest-largest values

Write a program c that will find the smallest, largest and average values in a collection of N numbers.Get the value of N before scanning each value in the collection of N numbers.

  Use gets() to input the user name into name

Use strcpy() and strcat() to build the anwer into fullname that consists of.

  C program to mips program

Convert the following C program to MIPS program. Assuming that i, j, k, f, are stored in registers $s0, $s1, $s2, $s3 already.

  Create valle products accdb database file

Create a new table named Orders using the table design below. You may create your table in design view or datasheet view. Save the Orders table as Orders Your Name. Define a one-to-many relationship between the Customer table and Orders table. Ri..

  Write a program that creates an array of 200 random numbers

Write a program that creates an array of 200 random real numbers between 0 and 200.  Using the statistics library, calculate and output the following: mean, median, variance, standard deviation, maximum value, and minimum value.

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