Assignment 02

Due: Friday, Feb 6, 2015 at noon 100 points

For this assignment, you will submit a single C++ compilable file containing a program written in C++. Remember, to electronically submit a file to for this course, first change to the directory in which the file resides and then type in, at the UNIX prompt, the command:

Be sure that only the file you want to submit is in that directory - make a directory for every assignment! Remember that the submit system will deliver every .cpp file in the current directory to me, so you should only have the file for hw 2 in that directory. Name your file a meaningful name and give it a .cpp extension since you will be compiling it. Also, make sure that you compile and run your program using the GNU (g++) compiler before submitting to make sure that it will work for the submit script.Background: This semester, the plan is to base all the assignments on a forensics theme. Forensics is the study of evidence that will lead to a conclusion you wish to argue. In the popular jargon, it refers to studying evidence of a crime to discover the perpetrator (a.k.a. perp). Our hero this semester is going to be the investigator, Stephen "Action" Jackson, pictured at right with associates. We will ... you will be helping him out by programming concepts in (criminal) forensics.

cssubmit 1570 section_letter assignment_number

Your first study in forensics is blood pattern analysis (bpa). Experts can take measurements from a spatter of blood on a wall and subsequently determine the origin of the blood, hence the whereabouts of the victim when the crime was committed. This is really cool, but a bit unnerving for some people with week stomachs for violent crimes. So, we're going to switch things up a bit so as not to offend the sensibilities. Thus, GGPA (Green Goo Pattern Analysis) is the study of green goo spatters on a surface to be able to determine the origins of the goo and hence the location of a space alien when it was shot. You see from the picture at the right that a goo spatter is elongated. The measurement of the width and length will help in determination of origins. From

And so you can see that if we know width and length, we can find angle α from the first equation. Knowing α, and being able to measure angle γ, we can then calculate β from the second equation. Once we know all these quantities, we can locate the spot on the floor where the trajectory of the green goo (that's the red line) hits. Of course, we must know the height of the green goo spatter off the floor. We'll call this point on the floor the "origination point". For simplicity, let's say the coordinates of the origination point are vx and vy. We are seeking the origination point.

Let's start by rewriting the above equations as

(1) α = arcsin (width / length)

β = arctan (tan(α) / sin(γ))

Then, from trigonometry, we also find

(2) vy = (height) * tan(α) note: * means multiplication

vx = vy * tan(β)

Thus you can see that with inputs of width and length of the spatter, the height of the spatter on the wall, and the angle γ, you can compute the origination point. But there is one other thing to know about alien blood. It is known that green goo will spread as it dries. So, to get an accurate measure of the dimensions of the spatter, you must subtract from the measurements of the width and length of the spatter that constant green goo expansion factor equal to 1 inch. (This should be part of your formulation.)

Specifications: Your program is to greet the user with a welcoming message such as "Welcome. You are running the GGPA program ...." or something similar. Next, it should prompt the user for inputs for

  1. the height from the floor of the green goo spatter in whole inches (use an int-type for this variable)

  2. the width of the spatter in inches (an int-type)

  3. the length of the spatter in inches (an int-type)

  4. the angle γ (refer to it as "gamma") in radians (use a float variable for this)1

The program should then compute the values of vx and vy. Your output should be "user friendly" in the sense that you should, in some fashion, echo the inputs and present the resulting calculated values in a way that makes it easy to understand. Just outputting final numbers is not good enough:

5 and 8

See, there is no explanation of what those numbers are. Here's an example of good output:

You have input:

ht = 67

width = 5

length = 12

gamma = .9

The origination coordinates are x = 13.03 and y = 26.15

Your program (as all programs) should end with a signoff message.

Notes: You are going to need to compute the arcsin and arctan of values. This capability is included in the cmath library. In order for you to use it in your program, put #include <cmath> just after (or before) the other include you have in your program. Then, as an example, this code would store the value of the arcsin(.5) and arctan(.5).

float angle1, angle2;

angle1 = asin(0.5);

angle2 = atan(0.5);

These are function calls and we will learn more about functions in general in about 4 weeks.

When you submit: the submit script will compile and run your program during the submission process. Thus, you will be the "user" of the program and will have to enter information at your own prompts. Now, in order to NOT drive the grader nuts with different answers, you will ALL enter the same values. Thus,

  • enter width 5

  • enter length 10

  • enter gamma 0.6 (radians)

  • enter 72 (inches) for height

As usual, if you have any questions or concerns about this assignment, don't hesitate to ask your instructor or go for help at the LEAD sessions. Note: no little green aliens were harmed during the preparation of this web page. We might have offended some, but that's life.

1I realize that it's a stretch that crime scene investigators know what radians are. Even many engineers don't know! So it goes....

tan(β) = ( tan(α) / sin(γ) )

sin(α) = ( width / length )

the second picture, you see that knowing certain angles will complete the picture for the investigator - Action Jackson, in our case. Now, any reasonable person can see that we can measure angle γ, but not angles α and β. But we are in luck! There are formulas that some smart guy devised relating all these quantities. They are: