# Putting Trajectory of a Projectile formula in Java form.

• March 2nd, 2012, 06:03 PM
mwebb
Putting Trajectory of a Projectile formula in Java form.
It's part of my assignment. Though, I keep getting different and negative numbers but I'm not sure why. I'm supposed to use the formula:

V^2*sin(2*A)
g

Where V = launch speed A = Angle (A is actually supposed to be theta) and g = gravity.

Instead of using meters, I used the feet conversion to go from Miles Per Hour to feet because the output has to be in feet. So I had to multiply the result by the number of feet in a mile. I also used the force of Earths gravity in feet (32.2). First I did the formula in Java by doing:

Code :

```//Pretend that mySpeed[row] = 20 MPH and myAngle[col] = 25 degrees   variable = (Math.pow(mySpeed[row],2) * Math.sin(2 * myAngle[col]) / 32.2) * 5280;```

The output seems to be -17209. But I get 50,244.9 on the calc. And the debugger won't get that specific for me so I can't pinpoint where things go wrong. Can someone spot what I did wrong. I assume it's my parenthesis.
• March 2nd, 2012, 07:03 PM
Sean4u
Re: Putting Trajectory of a Projectile formula in Java form.
Quote:

the force of Earths gravity in feet.
My eyes!

Should the argument to Math.sin be in degrees? It might be worth checking the API docs.
• March 2nd, 2012, 07:23 PM
mwebb
Re: Putting Trajectory of a Projectile formula in Java form.
Hmm, interesting point. Well I am supposed to use the toRadians() method but I haven't figured out what to use that for. I'll try that.

EDIT: Well, turned out I am getting a closer figure when using that method. This time the output was 50559. So I think that data is close enough to be considered true. My teacher isn't so concerned about data accuracy. Well, good job mate! I overlooked something.