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

  Program that will output the solution to the quadratic eq

Create a C++ program that will output the solution to the quadratic equation for any range of integer coefficients

  The game of life

The game of Life, invented by the mathematician John H. Conway, is intended to model life in a society of organisms. Consider a rectangular array of cells, each of which may contain an organism

  What are the primary differences between object-oriented

1. what is instruction explosion?2. what are the primary differences between object-oriented programming languages and

  Create class having constructor to recieve two ints

Create a class (in C++)named Card. The class should have two int data members named face and suit.The class should have a constructor that recieves the two ints and uses them to initialize the data members.

  Pre and post increament and decrement operators

We are going to overload the following operators in the fract class- pre and post increament (++) and decrement (--) operators

  Write a function that finds area and volume of a cube

write a function that finds area and volume of a cube when length is input and then write a program to test it. here is what i have so far.

  Generate a random number and guess what the number is

Prepare a program in c++ that generates a random number and asks the user to guess what the number is. If the user's guess is higher than the random number, the program should display "Too high, try again."

  Output the even numbers from 1 to 10 in ascending order

Output the even numbers from 1 to 10 in ascending order, then the odd numbers from 10 to 1 in descending order: 2 4 6 8 10 9 7 5 3 1. in C++

  Write an algorithm that converts a decimal number

Write an algorithm that converts a decimal number between 0 and 15 into its 4 bit unsigned binary representation and write an algorithm that converts a linear measurement in feet and inches into meters. One inch is equivalent to 2.54 centimeters.

  Write a recursive and iterative versions of binary search

in C++ write a recursive and iterative versions of binary search and compare their run times using the array a[i]=i, i=0,..., n-1

  Object oriented programming paradigm is better choice

Explain why object oriented programming paradigm is considered better choice than structured programming paradigm. Does it reflect our "natural" way of thinking or do you find it artificial?

  Write a program that reads a string from the keyboard

Write a program that reads a string from the keyboard and then display all vowels contained within a user-input string. (Vowels are: a e i o u)

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