OK, let me preface this by saying i am not a physics student, nor have i ever been. I am a software engineer working on a development degree. So this is homework but the assignment was just to create an app, i chose to do this app and the teacher said he couldn't assist because this is a development class not a physics class.
This is what i have done:
First, I made an app to calculate the angle required for a projectile to hit a given target. (using bullets as the projectile). The first attempt was successful however the only force acting on the bullet wa gravity and i was able to calculate the correct angle.
NOW, I am attempting to do the same with regards to adjusting the shooting angle to hit a required target WITH air resistance. I have already taken the initial velocity and broken it into the x & y components, calculated a cross sectional area, have the weight of the bullet in grains, and the drag coefficient.
How do i calculate the angle required to hit a target?
lets assume the following: i am firing a bullet from (0,0) to hit a target 1000 yards away, my bullet weighs 170 grains, ballisticCoefficient of the bullet is .25 .
so i have this
muzzleVelocity = 2000 fps
velocityX = muzzleVelocity * cos(targetAngle)
velocityY = muzzleVelocity * sin(targetAngle)
airDensity = calculate elsewhere 1.168783
crossSectionalArea = calculate by using the bullet diameter ((1/2 Diameter)^2 * PI) = area of a circle
Drag = (airDensity * ballisticCoefficient * crossSectionalArea)
AccelrationX = -(drag/grain)*muzzleVelocity * velocityX)
AccelrationY = -g -(drag/grain)*muzzleVelocity * velocityX)
What do i do now?
Do i need to convert the crossSectionalArea to the same unit of measurement as the velocity?
The things i know are total velocity, bullet weight, bullet diameter, air density, distance and angle to the target. How can i determine the angle required to hit a target?
I am loosely following here http://wps.aw.com/wps/media/objects/877/898586/topics/topic01.pdf
however i am a computer programmer and this looks greek to me.
Thanks Jeff
AFTER RECIEVING A DOWNVOTE I ADDED THIS:
(void)calculateTrajectory{
float velocityX = 0;
float velocityY = 0;
float accellerationX = 0;
float accellerationY = 0;
float drag = 0;
float timeInterval = .001;
caliber = [self.caliberTextField.text floatValue];
ballisticCoefficient = [self.ballisticCoefficientTextField.text floatValue];
muzzleVelocity = [self.muzzleVelocityTextField.text floatValue];
grain = [self.bulletGrainTextField.text floatValue];
velocityX = muzzleVelocity * (cosf(targetAngle / 180 * M_PI));
velocityY = muzzleVelocity * (sinf(targetAngle / 180 * M_PI));
if(self.metricSwitch.on == YES){
crossSectionArea = pow(((caliber * 0.00109361)/2),2)* M_PI;
}else{
crossSectionArea = pow(((caliber / 36)/2),2)* M_PI; //pow(((caliber / 36)/2),2)* M_PI;
}
NSLog([NSString stringWithFormat:@"airdensity %f, BC %f, cross %f", airDensity, ballisticCoefficient, crossSectionArea]);
drag = (airDensity * ballisticCoefficient * crossSectionArea);
NSLog([NSString stringWithFormat:@"drag %f", drag]);
accellerationX = -(drag/grain)*muzzleVelocity*velocityX;
accellerationY = -g - (drag/grain)*muzzleVelocity*velocityY;
NSLog([NSString stringWithFormat:@"X %f, Y %f", accellerationX, accellerationY]);
/* LOOP THROUGH ANGLES??? NO THERE HAS TO BE A BETTER WAY
for (x=0; x<3; x+=.001) {
accellerationX = -(drag/grain)*muzzleVelocity*velocityX;
accellerationY = -g - (drag/grain)*muzzleVelocity*velocityY;
float nextx = (velocityX + );
}
*/
EDIT FOR CLARIFICATION So when you said "You need to use the current velocity at any step of the calculation", i was beginning to do that (in a small loop for test purposes).
I was going to test output using just three seconds in my for loop (x = seconds)
for (x=0; x<3; x+=.001) {
accellerationX = -(drag/grain)*muzzleVelocity*velocityX;
accellerationY = -g - (drag/grain)*muzzleVelocity*velocityY;
float nextx = (velocityX + );
}
I was planning on solving the NEW x,y locations based off of the negative acceleration in both the X,Y plane and then adjust the x & y velocity each iteration (every .001 seconds), and thats when it dawned on me that since I am down to thousandths of seconds and thousandths of a degree... This could be a VERY large computational process.
Suffice to say i could probably do split halves to narrow it down between whole degrees and then go from there with the other calculation methods. You have provided great info in the links... i had no clue what is what called. I just know what i needed to do and it looks like i was correct that there is no hard fast formula to plug in. I will finish reading the links provided and see if i can grasp a better understanding of either of the methods.
to recap: I will try (0,5,10,15,....90) to see what range the angle should fall between.
Then use the formula to further narrow it down to my desired precision level by calculating the next x,y by adjusting the position and current velocities.
an after thought, i suppose i could increase my time interval as well.