Well my C++ class is mixed with CS majors and Engineer majors, so most of our labs are geared toward engineers. I'm still in precalculus so this is slightly confusing to me.
I have the entire program coded besides this equation.
The instructions state this:
Sin2θ=d*g/pow(V0,2.0)
2 θ in radians is asin(d*g/pow(V0,2.0))
Degree=radian*180/PI (PI=3.1416)
My professor explained it in class, but he has an extremely strong accent and I could not understand him.
I understand most of the equation, but when it talks about "Sin2θ" and "2 θ in radians is asin" I get lost.
Projectiles follow a parabolic path through the air, due to the acceleration of gravity. In this problem set, you will calculate the optimum, minimum, and maximum release angle for throwing a ball into a basket. The equation describing the relationship between release angle, θ, initial speed, v0, and distance, d:
d= V02 *sin2θ /g
where g = 9.8 m/s2 is the acceleration due to gravity
Your program should prompt the user for the following inputs:
· distance, d, from thrower’s hand to the center of the basket (in meters)
· diameter of the basket (in meters)
· initial ball speed v0 (in meters/second)
· height of the ceiling from the basket (in meters)
Assume that the diameter of the ball is too small to make any difference in the calculation.
Optimum angle : ball drops in the middle of the basket (distance d)
Minimum angle: ball drops on the left edge of the basket (d – diameter of the basket/2)
Maximum angle: ball drops on the right edge of the basket (d+ diameter of the basket/2)
Sin2θ=d*g/pow(V0,2.0)
2 θ in radians is asin(d*g/pow(V0,2.0))
Degree=radian*180/PI (PI=3.1416) Declare as named constant
Main should prompt the user for inputs and display the output.
Calculations must be done in a function called calcAngle
This function should return the angle in degrees.
NO GLOBAL Variables.
θ is an angle. 2*θ is double that. Lets call 2θ "A", i.e. A==2*θ.
You have: sin(A) == d * g / pow(v0, 2.0)
Take arc sine from both sides: asin(sin(A)) == asin(d * g / pow(v0, 2.0))
On the left side the asin and sin cancel each other: A == asin(d * g / pow(v0, 2.0))
In other words, by calculating the right side we will get A.
calcAngle should return an angle from the inputs. The only inputs it needs are d and v0:
1 2 3 4 5 6 7 8
// Given an initial velocity and the distance that an object travels,
// compute the angle that should be used. Return the angle in degrees.
double calcAngle(double d, double v0)
{
constdouble PI = 3.141592653589793;
constdouble g = 9.8;
// compute the angle and return it.
}
Your main program will call this function 3 times with 3 different distances: one to compute the minimum angle, one for the max angle and one for the optimum angle.
There's no reason to use the pow() function here. It would be faster and possibly more accurate to use (v0*v0) instead of pow(v0,2.0).
Have you studied trig? Do you know what sin() and asin() are?
No I have not studied trig, and I haven't gone over sin() and asin() since highschool (about 4 years ago). However I did check the link posted today and got some help from my instructor, so far I have this:
Do you mean distance 10m and diameter 2m? The other way the "near edge" would be at -3 m. Besides, 10m sounds like a big basket.
Anyway. Do you think that throwing a ball 5 m/s will make it fly far enough?
Range R == v^2 * sin(2θ) / g
At θ == 45 degrees the sin(2θ) == 1, and thus the maximal range is
R == v^2 / g == 25 / 9.8 m == 2.55 m
In other words: There is no angle that could get the ball in with those v and d.