Finding Angle with given distance

drt_t1gg3r

New member
Joined
Nov 2, 2007
Messages
4
Hi all, novice game designer here. Not much in the math department.(Never applied myself in High school). Any way, I think this question is supposed to be in this forum and do apologize if I am incorrect.

If objectA shot a round at objectB, at what angle would he aim his weapon?
given:
speed of round: 10 units per step
distance to objectB: 600 units away
gravity: gravity gains .5 units per step (.5, 1, 1.5, etc...)
friction: friction gains .1 units per step (.1, .2, .3, etc...)

Can an angle be found if all the above is given? In my game I am trying to have a turret shoot at another turret. The artificial intellegance is supposed to find an angle to shoot at if he has a constant speed, gravity, and friction.
angleproblem.png


btw:
speed propels object along direction
friction pulls against speed(decreases speed each step)
gravity pulls down
angle can only be between 0 and 180 (0 degree is a line exending horizontally right from the x,y axis, 90 degrees is a line extending vertically up from the x,y axis, 180 degrees is a line extending horizonally left from the x,y axis and 270 is a line extending vertically down from the x,y axis)

EDIT: ObectB is 600 units away,with a missile at a contstant speed of 10 units per step, angled at a degree of 0 with no friction, and no gravity, the misisle would reach objectB in 60 steps
 
drt_t1gg3r said:
Hi all, novice game designer here. Not much in the math department.(Never applied myself in High school). Any way, I think this question is supposed to be in this forum and do apologize if I am incorrect.

If objectA shot a round at objectB, at what angle would he aim his weapon?
given:
speed of round: 10 units per step
distance to objectB: 600 units away
gravity: gravity gains .5 units per step (.5, 1, 1.5, etc...)
friction: friction gains .1 units per step (.1, .2, .3, etc...)

Can an angle be found if all the above is given? In my game I am trying to have a turret shoot at another turret. The artificial intellegance is supposed to find an angle to shoot at if he has a constant speed, gravity, and friction.
angleproblem.png


btw:
speed propels object along direction
friction pulls against speed(decreases speed each step)
gravity pulls down
angle can only be between 0 and 180 (0 degree is a line exending horizontally right from the x,y axis, 90 degrees is a line extending vertically up from the x,y axis, 180 degrees is a line extending horizonally left from the x,y axis and 270 is a line extending vertically down from the x,y axis)

EDIT: ObectB is 600 units away,with a missile at a contstant speed of 10 units per step, angled at a degree of 0 with no friction, and no gravity, the misisle would reach objectB in 60 steps

The study of projectile motion is made easy by breaking the initial velocity into its vertical and horizontal components. Thus, If a projectile is fired with an initial velocity of Vo at an angle "µ" to the horizontal, Vv = Vvertical = (Vo)sin(µ) and Vh = Vhorizontal = (Vo)cos(µ). The time of flight may be obtained by summing the rise time with the fall time. From Vf = Vo - gt and Vf = 0, Vv = gt making the rise time t1 = Vv/t. During this period of time, the projectile travels horizontally d = Vht1. During the rise time, t1, the projectile rises to a height of h = Vvt1 - g(t1^2)/2 which can now be written as h = g(t1^2) - g(t1^2)/2 or h = g(t1^2)/2. Clearly, the time, t2, required for the projectile to fall back to the ground derives from -h = -g(t2^2)/2 making t1 = t2 or the total time t = 2t1.

Combining these expressions, d = Vocos(µ)t = 2Vot1cos(µ) = 2Vo[Vosin(µ)/g]cos(µ) or d = Vo^2(sin^2(µ))/2g.

Eliminating t1 from Vosin(µ) = gt1 and h = gt1^2/2 yields the maximum height reached as h = Vo^2(sin^2(µ))/2g.
 
Eliminating t1 from Vosin(µ) = gt1 and h = gt1^2/2 yields the maximum height reached as h = Vo^2(sin^2(µ))/2g.
Maybe you didn't get the part that said " Not much in the math department."
However, how does this equation give me an angle to fire at? How does it relate? And could you explain the proof again real slow like and with more words so I may under stand what it is you are trying to tell me.

:) Thanks for your assistance and patience with my ignorance
 
Contact a local math teacher. No blackboards and the likes here.
It's as if you're asking how to milk a cow but don't know where the udder is :wink:
 
drt_t1gg3r said:
Eliminating t1 from Vosin(µ) = gt1 and h = gt1^2/2 yields the maximum height reached as h = Vo^2(sin^2(µ))/2g.
Maybe you didn't get the part that said " Not much in the math department."
However, how does this equation give me an angle to fire at? How does it relate? And could you explain the proof again real slow like and with more words so I may under stand what it is you are trying to tell me.
In retrospect, the traditional equations of a projectile motion might not be applicable to your problem.

I translate your speed of units per step into feet per second; your gravity losses as .5 ft./sec.^2 and your drag losses as .10 ft./sec.^2. This translates to a vertical component of the inial speed, Vo, as Vv = Vvertical = (Vosinµ - .6t1)ft./sec. The time to maximum height is ten t1 = (Vosinµ - .6t1) or t1 = (Vosinµ)/1.6. The time back to the ground is the same making the total flight time T = 2(Vosinµ)/1.6. (.6t1 derives from the gravity loss + the drag loss)

The horizontal distance traveled is d = (Vocosµ - .1T)T = VocosµT - .1[2(Vosinµ)/1.6]^2. If I assume the 600 units to be 600 feet, VocosµT - .1[2(Vosinµ)/1.6]^2 = 600. Not quite sure how to find the optimum launch angle from this.

If I view this in the more traditional scenario as the target being 600 feet from the launch point, ignoring air drag and the gun is fired at a 45º angle to the ground (the angle for maximum range), we can say that the rise time is t1 = Vosinµ/32 = .707Vo/32 (32 = acceleration due to gravity).

The total flight time is then T = 2t1 =.707Vo/16.

The horizontal distance traveled is 600 feet.

Then, d = VocosµT = .707Vo(.707Vo/16) = 600 from which Vo = 138.56 ft/sec., not 10 ft/sec.

This says that the gun would have to fire the projectile with a speed of 138.56 ft/sec. at an angle of 45º to the horizontal to reach a target 600 feet away. (ignoring air drag).

I am not quite sure as to how to address the problem in the manner in which you outlined. I will take another look at it however.

Is it your intent to mean that .5 units per step are applied to the speed for every time step to account for gravity as well as .10 units per step subtracted from the speed for every time step?
 
Top