- #1
tomsiv
- 2
- 0
I'm working on my engineering capstone design and part of our design requires a code we have written to calculate the appropriate zenith angle for a nerf gun to fire a projectile so that the dart hits a certain target.
We are feeding the code a target coordinate (x,y,z). One section of our code tracks the azimuth angle simply using the x and y coordinates(arctan(y/x)), then the zenith angle will be based on the projected range (r = [itex]\sqrt{x^{2}+ y^{2}}[/itex]) and the z value. The basic equations we are using are
Δr = vtotal*cos(θ)*Δt + .5*d*cos(θ)*Δt[itex]^{2}[/itex]
Δz = vtotal*sin(θ)*Δt + .5*(d*sin(θ) + g)*Δt[itex]^{2}[/itex]
where
Δr = change in position along the projected range
Δz = change in position along the z axis (elevation)
vtotal = total velocity (at muzzle)
Δt = time after firing
d = drag = -k*v2 = (we are going to assume this as a constant even though it depends on velocity)
Now since we are feeding our Matlab/simulink code a desired (x,y,z) value, we will have a desired Δr and Δz (or if you want to think in 2 dimensions a desired X and Y). So what we are trying to do is have our program solve these two equations simultaneously so that we can have a necessary θ value (zenith angle) to hit our target. Two equations, two unknowns (θ and Δt). I'm just running into problems when trying to set these up as a matrix to solve.
I feel like we may be over complicating this, because I've done similar calculations for rail gun targeting, but we had range, etc. as the unknowns and we were selecting theta values. Am I leaving something out or missing an obvious matrix solving method?
Thank you for any help you can offer, sorry if my wording is somewhat confusing.
We are feeding the code a target coordinate (x,y,z). One section of our code tracks the azimuth angle simply using the x and y coordinates(arctan(y/x)), then the zenith angle will be based on the projected range (r = [itex]\sqrt{x^{2}+ y^{2}}[/itex]) and the z value. The basic equations we are using are
Δr = vtotal*cos(θ)*Δt + .5*d*cos(θ)*Δt[itex]^{2}[/itex]
Δz = vtotal*sin(θ)*Δt + .5*(d*sin(θ) + g)*Δt[itex]^{2}[/itex]
where
Δr = change in position along the projected range
Δz = change in position along the z axis (elevation)
vtotal = total velocity (at muzzle)
Δt = time after firing
d = drag = -k*v2 = (we are going to assume this as a constant even though it depends on velocity)
Now since we are feeding our Matlab/simulink code a desired (x,y,z) value, we will have a desired Δr and Δz (or if you want to think in 2 dimensions a desired X and Y). So what we are trying to do is have our program solve these two equations simultaneously so that we can have a necessary θ value (zenith angle) to hit our target. Two equations, two unknowns (θ and Δt). I'm just running into problems when trying to set these up as a matrix to solve.
I feel like we may be over complicating this, because I've done similar calculations for rail gun targeting, but we had range, etc. as the unknowns and we were selecting theta values. Am I leaving something out or missing an obvious matrix solving method?
Thank you for any help you can offer, sorry if my wording is somewhat confusing.