Homework 5General CommentsHomework assignments will be drawn from a variety of sources. For programs, make sure you commit your solution to SVN by the assignment deadline!DetailsCreate a new project called Homework5 in your solution. Implement one of the following case studies: 3.4, 3.5, or 3.6; or implement case study 3.1 as specified below. Make sure you read carefully and fully implement what is asked.
As usual, make sure you commit your code to SVN before the deadline.
Chaos (based on Case Study 3.1)
Your job is to write an OpenGL program that shows the "orbit" of the point 0.1 when the function f(x) = 4*x*(1-x) is iterated. The orbit initially consists of two points: (0.1, 0) and (0.1, f(0.1)).
The paint handler for your OpenGL control should perform the following tasks:
- Plot the function f(x) in black over the domain 0<=x<=1. Note that the range of the function over this interval is 0<=f(x)<=1. There should always be a 10 pixel border between the window and the viewport on all sides.
Choose a viewport to draw within the Open GL control so that as much of the control as possible is used to draw, while keeping the viewport square (to match the world boundaries). The viewport should always be centered within the Open GL control.
-
Draw a blue rectangle around the viewport. Note that to avoid numerical inaccuracies, you may need to subtract just a tiny bit from the viewport boundary coordinates.
- Draw the line y=x in a light gray color
- Draw the entire orbit in black
Each time a key is pressed, two new points are added to the orbit. The new points to add to the orbit are determined as follows:
Let last be the y coordinate of the last point in the current orbit
Add the point (last, last) to the orbit
Add the point (last, f(last)) to the orbit
You may want to make use of the PolylineCollection class that we developed in class to keep track of the orbit points.
When your program works, experiment with changing the value of 4 in the formula for f(x) with other values to see if you can get a different sort of pattern. Submit your solution with your chosen constant.
There is an example solution in torque3/course/342/solutions named Chaos2.exe.
|