Project #2
(Hanging Paintings)
(Due 13 Feb 2008)
The Nouveaux Artes Museum has just acquired a collection of paintings of an exciting new artist and is planning to exhibit them in its Prestige Gallery. Many of the paintings are quite large and need to be placed on the gallery walls for optimum viewing. The museum curator has decreed that all pictures must be placed above eye-level and that the optimum angle of view must be 40o top to bottom. The curator also specified that eye-level for the average person is 5 feet 6 inches above the floor.
The gallery director needs to direct the hanging of the pictures so that the curator's requirements are met. The director will decide the height of the top and bottom of each picture but needs to calculate the appropriate distance that museum visitors must stand away from the painting to have the optimal 40o view. The director plans to place a rope barrier one foot short of the appropriate distance, to lead visitors to the place to stand and view each painting. Your job is to write a program which can take the director's choices for a painting placement and based on that and the curator's specifications tell the director how far to place each rope barrier from the wall holding the painting.
In
the drawing, the visitor stands at the right and views the painting on
the wall at the left such that the theta angle is 40o.
The bottom of the painting is at B, the top is at T; E
represents eye-level at the wall; and the angle alpha at the top
allows calculation of the distance. The rope placement
should be at one foot less than the distance. One way to make
the calculation of the distance is to first determine the tangent of alpha,
using the following equation in which above is the distance from
E to T and below is the distance from E to B.
This can be solved for the tangent of
alpha just like any quadratic equation, using the quadratic formula, in
which A is the coefficient of the first term, i.e., the coefficient of
the tan2 of alpha; B is the coefficient of the second term;
and C is the coefficient of the third term.
The roots are the two possible values for the tangent of alpha. To get the two possible distances, just multiply each of the roots by above. (This is because tan alpha = distance / above ) Then, subtract one foot from each distance to determine the rope barrier position.
Your program should prompt the director to get the heights of the top and bottom of the picture to be hung. The program should then display the position for the rope barrier, measured in feet from the wall. For example, if the director specifies that the top of the painting is 20 feet above the floor and the bottom is 8 feet above the floor, your program should display something like this:
Distances for the rope barrier are 10.01 feet and 2.29 feet from the wall
Approximately three days before the project is due, I will give you two sets of picture specifications that I want you to use when you execute the program. Note that the longer distance is what the director will actually use in placing the rope barrier. Depending on what the director specifies for the top and bottom, it is possible that the smaller distance may be negative (result of subtracting one from a very short distance). It is also possible that what the director specifies will make it impossible to have a view of 40o; when that happens, the results you get will be very strange.
Hand in a well-documented printout of your
program and a printout of the captured output from the two executions on
the data that I provide. Also, copy the program's .cpp file to the
handin folder on the P: drive for COSC 110 section 001 or 002. Be
sure to name the .cpp file after yourself so that it can be distinguished
from other student file names. For example, I would name my file
wolfep2.cpp