Assignment 5

Rachel Shiner (cs184-dp)

For this assignment, I extended assignment 2 to include the option of generating a surface of revolution from a curve.

When the program opens, the command prompt appears along with the 2D Curve window. Information on how to use the program is printed on the command prompt, and relevant information (i.e. type of curve, level of detail) is printed out while the program is running. The 2D Curve window is essentially the same as assignment 2. The user picks what type of curve to draw (0 for lines, 1 for Bezier curve, 2 for B-spline, 3 for subdivided Bezier curve) and can adjust the level of detail it is drawn with by pressing the + and - keys. Points are added by left-clicking, moved by dragging, and removed by right-clicking. The user can start a new curve at any time by just specifying the type. The extended part of the assignment is that the user can revolve the curve to form a surface. Pressing the r key opens the 3D Surface of Revolution window and draws the current curve's surface of revolution in that window. Once that window has been opened, all adjustments to the surface of revolution are done in the 3D Surface of Revolution window. For example, if the user has already opened that window and has since made a new curve that they want to view the surface of revolution for, then they must go to the 3D Surface of Revolution and type the appropriate keys to view it.

Most of the new aspects of this assignment are in the 3D Surface of Revolution window. Pressing the arrow keys rotates the user's viewpoint around the surface. Pressing the r key draws the surface of revolution of the 2D Curve window's curve in the default starting viewpoint. Pressing the v key also draws that curve, but views it from whatever the last viewpoint used was.

Overview

Command Prompt
- displays information about how to use the program and the details about the curve the user is making
- Commands:
	- none (all commands will be entered in the other windows)
2D Curve window
- used for making a 2D curve
- Commands:
	0 - start making an image out of lines
	1 - start making a new Bezier curve
	2 - start making a new cubic B-spline curve
	3 - start making a new recursively subdivided Bezier curve
	+ - increase the level of detail by 1
	- - decrease the level of detail by 1
	r - open up the 3D Surface of Revolution window
	h - print information about how to use this window
	q - quit the program
3D Surface of Revolution window
- used for viewing the 3D surface of revolution generated by a 2D curve
- Commands:
	up, down, left, and right arrow keys - rotate the user's view of the surface in that direction
	r - generate a surface of revolution from the curve in the 2D Curve window (viewpoint is the default starting viewpoint)
	v - generate a surface of revolution from the curve in the 2D Curve window (viewpoint is whatever the last viewpoint used was)
	h - print information about how to use this window
	q - quit the program

Pictures

The following are some screenshots of curves and surfaces generated with the program. For each type of curve, there is the 2D curve, that curve's surface of revolution viewed from the default starting viewpoint, and and the surface from two other viewpoints.

Lines







Bezier Curve







B-spline Curve







Bezier2 Curve (recursively subdivided Bezier)






Here is the source code to be run in Visual Studio:

hw5.zip