Jump to content
crewt

Calculating the distance a Bomb would travel.

Recommended Posts

Hey there,

as I reached the limitation of my physic knowledge, I require some help from you :/

 

I currently work on some Commander that is capable to manage all given Units  etc.

So far, quite satisfying, but for more than a week now, I struggle with a problem.

 

My current goal is to the 'last' AI support module, to get undirected bombs into a Target (Or more at a certain Position). So I have a stable flight height ( Thanks to flyinHeightASL).

I don't want direct Hits, but for a stationary Target  it should hit at a 10^2 m radius.

 

 

This is the fnc written to calculate the impact distance, witch is for some reason always around 200-270m to short. As I don't want to just add 200m, as It would be a messy solution. Any Idea  why the Bombs come to short? Maybe the Airfriction in arma or, the possibility of bombs to glide ? 

If so, any Idea how to add these factors?

 

 

/*
Parameter:
		0: Vehicle -  Plane
		1: String - Weapon
		2: Number - Targetheight (ASL)
*/
params ["_veh", ["_weapongiv", "", [""]], ["_targetpos", 0]];
if (_weapongiv == "") then { 
	_weapongiv = if ( ([_veh] call CR_gcmd_getBomb) isEqualTo ["",0]) then {
		([_veh] call CR_gcmd_getBomb) select 0
	} else { currentWeapon _veh };
};
private _magazine = "";
private _initSpeed = -0.0005;
private _airFriction = 0;
private _magazines = getArray (configFile >> "CfgWeapons" >> _weapongiv >> "magazines");
if (count _magazines != 0) then {
	_magazine = _magazines select 0;
	private _ammoName = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo");
	_initSpeed = getNumber(configFile >> "CfgMagazines" >> _magazine >> "initSpeed");
	//_airFriction = getNumber(configFile >> "CfgAmmo" >> _ammoName >> "airFriction");
};

private _g  = 9.80665;
private _v = vectorMagnitude (velocity _veh) + _initSpeed;
private _degrees = (_veh weaponDirection _weapongiv) select 2;
private _h = (getPosATL _veh select  2) - _targetpos;

private _tF = sqrt((2*_h)/_g);
private _acc = _tF * _g;
private _sD = (_v + _acc)*_tF;

_sD

Some Values to mess with: 

Weapon:  "GBU12BombLauncher_Plane_Fighter_03_F"
magazine: "2Rnd_GBU12_LGB"
Ammo: "Bo_GBU12_LGB"
InitSpeed: 0
Airfriciton: -0.0005

Any help (or suggestions) is really appreciated  :)

Share this post


Link to post
Share on other sites

I would assume the weight and what type of bomb it is would be the most important factors in this. As i dont see much air affecting the dropping of bombs (correct me if i am wrong). Maybe consider the height of the plane when dropping and the distance between impact area and the plane. 

Share this post


Link to post
Share on other sites

I played around with this last year, bombs have a weird glideslope that makes any freefall formulas fail.

Which resulted in me visiting weird NASA sites about glideslopes and obscure physics pages on the interwebz, so I decided to spend my time someplace else, heh.

 

Cheers

Share this post


Link to post
Share on other sites

Sadly, the weight is 0 (wonder wonder).

The Height is in there (somewhere).

Maybe I have some logic error in there, witch I simply don't see anymore, as I spent hours over these lines of code.

 

I wounder if weather or not I could create a function out of the velocity and Height of a Bomb that is falling,... Might be worth a try, but It sure as hell will stress the hell out of me.

Share this post


Link to post
Share on other sites

The formula is allright, exactly same one I used.

Just be sure to use posASL for both launch and impact position.

If you use a regular object (player works best, heh) the calculation is 100% exact and you land according to calculations.

It's the bombs glideslope.

 

Cheers

Share this post


Link to post
Share on other sites

To bad. Soooo basicly the only working theorie is creating a Function based on the flightpath of an bomb? by test? 

That will be fun. Maybe I could try calculating the impact pos based on force :/

Share this post


Link to post
Share on other sites

As I failed at multiple methods regarding adjusting the function, I came  to a solution ( at 0130, somehow solutions always come late)

I had the total distance the bomb traveled, and all Values  ( Height, Speed etc.)

So I came to the conclusion that Arma 3 must have some strange g force for Bombs, or the air friction and the not existing Mass do their thing.

 

And tada, G_force  for the function above is... 44 ...  (Seemd to be the solution for this specific equation, not a general one -.-)

Whatever, I will continue to search for a more logical solution, as this one is quite ... messy. But hey, maybe this is of use for someone with a similar problem :)

Edited by crewt
  • Like 1

Share this post


Link to post
Share on other sites

Same for mortar calculation. Doesn't work with physic equations and impossible to find the Artillery computer formula.

  • Like 1

Share this post


Link to post
Share on other sites

I ve not the time actually to take a further look at your formula but I did a similar thread a year ago. In that thread I ve calculated the flight path of a self propelled rocket. This calculation should be the same as for bombs but for bombs it is without any thrust. So it should be easier ;-)

I found out that air friction is an important value for calculating the path. The formula for it is:

 

f=a/v².

f - force  f - air friction

v - velocity

a = air friction  a - acceleration

 

I strongly recommend to read my entire thread because my script is working perfectly and the rockets hit their targets.

Here it is:

 

the complete script for predicting rockets flight path can be found here:

 

EDIT:

I corrected the above formula for air friction due to an formating mistake by the new forum design...

If you read those old thread then you should consider that this form,ating error exists. It occurs at all square signs:

 

²   =   ²

Share this post


Link to post
Share on other sites

@sarogahtyp Sadly I've never been to good at physic, so, im just taking a guess here: 

I'm confused, as far as I can tell your solution is incremental calculating the Speed of you projectile, leaving G out of it and mainly reducing Speed based on the Airfriction (On witch I can't wrap my Head around btw). Sadly I don't have Thrust, witch seems to be key to your equation, except I take the unknown G_force ( Or the G_force with an unknown influence of gliding).

Maybe you could elaborate the usage of Air friction? Adjusting the acceleration the projectile seems wired with a Value of -0.005.

 

f=a/v².
v - 200
a = -0.0005

<=>  f= -20 

Assuming that the Bomb has a weight of 1, because 0 wouldn't work^^  I can assume that the force is the 'same' as m/s (At least at this point I know a few people that would rip my head of). What to do with a negative force/speed? 

 

 

On thing cought  my Eye: maxSpeed 

Any acc impact on the Speed of the Projectile?

made 2 very fast tests, taking Height and Velocity (m/s) of a Bomb, droped at diffrent Height and Speed. 

Spoiler

[
	[440.707,59.6742],
	[434.382,59.7907],
	[425.764,60.1183],
	[415.148,60.7584],
	[402.391,61.7287],
	[387.696,63.0061],
	[370.808,64.6023],
	[351.708,66.502],
	[330.041,68.7262],
	[306.217,71.2104],
	[279.594,73.9979],
	[250.165,77.0638],
	[217.647,80.409],
	[181.489,84.0607],
	[142.213,87.936],
	[99.558,92.0323],
	[52.7978,96.3893],
	[8.48073,100.395],
	[8.48073,100.395]
]



[
	[420.487,203.836],
	[402.714,204.528],
	[380.184,205.431],
	[353.303,206.54],
	[321.81,207.863],
	[285.757,209.393],
	[244.752,211.142],
	[198.955,213.1],
	[148.074,215.273],
	[92.1508,217.653],
	[31.327,220.23]
]

 

From this point of View it seems not only that they can very well be faster than given maxSpeed Value (with lays at 100 btw.),

but also it showed me that my so called solution from yesterday was only correct for the tested values or better for the specific equation. 

 

Cheers

Share this post


Link to post
Share on other sites

I read some of my older posts again and it turns out that the above formula was incorrect. (view this post)

I misread the formula. It has to be:

airfriction = a/v²

a - acceleration

v- velocity

 

with this you get a negative value for the current acceleration and so you dont need any mass.

I used this for calculating the speed for the next simulation cycle.

 

 !!! The important thing is: You must not use any force (like g) or any mass for the calculation. This will always fail with wrong results because armas mass is zero. !!!

They used non physics formula for these simulations to reduce performance consumption.

Share this post


Link to post
Share on other sites
1 hour ago, crewt said:

Sadly I don't have Thrust, witch seems to be key to your equation,

 

This is not sad but luck!

The calculation with thrust is more complex. You only have to brake ur bomb and not to accelerate it first as I had to do...

Share this post


Link to post
Share on other sites

To clarify my explanations a bit more.

what I mean with braking the bomb is that u have to brake it in flight direction because of air friction. This means you have to use the air friction formula to brake the bomb in flight direction. Therefore you need a negative acceleration value.

 

This is also the point why your bomb drops are to short. you did not consider air friction correctly.

Share this post


Link to post
Share on other sites

Here is how BIS seems to simulate free falling bombs: https://pastebin.com/teQntUBp (already stripped down most of the unimportant code). Maybe you can deduce a formula from this.

Let me know if something is unclear and I will try to explain.

 

Vector3Val position = FutureVisualState().Position();
  Vector3Val speed = FutureVisualState().ModelSpeed();
  float mass = GetMass();
 
  Vector3 force(VZero), torque(VZero);
  Vector3 friction(VZero), torqueFriction(VZero);
  Vector3 pForce(VZero), pCenter(VZero);
  // body air friction
  pForce[0] = speed[0] * speed[0] * speed[0] * 5e-4f + speed[0] * fabs(speed[0]) * 10.0f + speed[0] * 10.0f;
  pForce[1] = speed[1] * speed[1] * speed[1] * 5e-4f + speed[1] * fabs(speed[1]) * 10.0f + speed[1] * 10.0f;
  pForce[2] = speed[2] * speed[2] * speed[2] * 1e-5f + speed[2] * fabs(speed[2]) * 0.01f + speed[2] * 2.0f;
 
  pForce[0] *= ammoType->sideAirFriction;
  pForce[1] *= ammoType->sideAirFriction;
  pForce[2] *= ammoType->_airFriction;
 
  pForce *= mass * (1.0f / 10.0f);
  friction += pForce;
 
  // aerodynamic non-stability makes direction aligned with speed
  pForce[0] *= 0.1f;
  pForce[1] *= 0.1f;
  pCenter = Vector3(0.0f, 0.0f, +0.3f);
  torque += pCenter.CrossProduct(pForce);
 
  // calculate draconic force (which makes direction aligned with speed)
  // note: this should be calculated for all missiles, but it is too late to add it now, as it might cause some changed behavior.
  pForce[0] = speed[0] * fabs(speed[0]) * -0.00033f + speed[0] * -0.005f;
  pForce[1] = speed[1] * fabs(speed[1]) * -0.00033f + speed[1] * -0.005f;
  pForce[2] = 0.0f;
  pForce *= mass;
  force += pForce;
 
  // convert to world space
  FutureVisualState().DirectionModelToWorld(friction, friction);
  FutureVisualState().DirectionModelToWorld(force, force);
  FutureVisualState().DirectionModelToWorld(torque, torque);
 
  torqueFriction = _angMomentum * 5.0f;
 
  // add gravity
  pForce = Vector3(0.0f, -G_CONST, 0.0f) * mass;
  force += pForce;
 
  // calculate new position
  VisualState moveTrans = PredictPos<VisualState>(deltaT);
 
  ApplyRemoteStateAdjustSpeed(deltaT,moveTrans);
 
  Vector3Val newPos = moveTrans.Position();
  Vector3 lDir = newPos - position;
 
  Move(moveTrans);
  DirectionWorldToModel(FutureVisualState()._modelSpeed, FutureVisualState()._speed);
  ApplyForces(deltaT, force, torque, friction, torqueFriction);

 

  • Like 2

Share this post


Link to post
Share on other sites

I am at work and cant use pastebin here. Please use a spoiler instead.

Share this post


Link to post
Share on other sites
3 minutes ago, sarogahtyp said:

I am at work and cant use pastebin here. Please use a spoiler instead.

Spoiler

  Vector3Val position = FutureVisualState().Position();
  Vector3Val speed = FutureVisualState().ModelSpeed();
  float mass = GetMass();
 
  Vector3 force(VZero), torque(VZero);
  Vector3 friction(VZero), torqueFriction(VZero);
  Vector3 pForce(VZero), pCenter(VZero);
  // body air friction
  pForce[0] = speed[0] * speed[0] * speed[0] * 5e-4f + speed[0] * fabs(speed[0]) * 10.0f + speed[0] * 10.0f;
  pForce[1] = speed[1] * speed[1] * speed[1] * 5e-4f + speed[1] * fabs(speed[1]) * 10.0f + speed[1] * 10.0f;
  pForce[2] = speed[2] * speed[2] * speed[2] * 1e-5f + speed[2] * fabs(speed[2]) * 0.01f + speed[2] * 2.0f;
 
  pForce[0] *= ammoType->sideAirFriction;
  pForce[1] *= ammoType->sideAirFriction;
  pForce[2] *= ammoType->_airFriction;
 
  pForce *= mass * (1.0f / 10.0f);
  friction += pForce;
 
  // aerodynamic non-stability makes direction aligned with speed
  pForce[0] *= 0.1f;
  pForce[1] *= 0.1f;
  pCenter = Vector3(0.0f, 0.0f, +0.3f);
  torque += pCenter.CrossProduct(pForce);
 
  // calculate draconic force (which makes direction aligned with speed)
  // note: this should be calculated for all missiles, but it is too late to add it now, as it might cause some changed behavior.
  pForce[0] = speed[0] * fabs(speed[0]) * -0.00033f + speed[0] * -0.005f;
  pForce[1] = speed[1] * fabs(speed[1]) * -0.00033f + speed[1] * -0.005f;
  pForce[2] = 0.0f;
  pForce *= mass;
  force += pForce;
 
  // convert to world space
  FutureVisualState().DirectionModelToWorld(friction, friction);
  FutureVisualState().DirectionModelToWorld(force, force);
  FutureVisualState().DirectionModelToWorld(torque, torque);
 
  torqueFriction = _angMomentum * 5.0f;
 
  // add gravity
  pForce = Vector3(0.0f, -G_CONST, 0.0f) * mass;
  force += pForce;
 
  // calculate new position
  VisualState moveTrans = PredictPos<VisualState>(deltaT);
 
  ApplyRemoteStateAdjustSpeed(deltaT,moveTrans);
 
  Vector3Val newPos = moveTrans.Position();
  Vector3 lDir = newPos - position;
 
  Move(moveTrans);
  DirectionWorldToModel(FutureVisualState()._modelSpeed, FutureVisualState()._speed);
  ApplyForces(deltaT, force, torque, friction, torqueFriction);

 

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

There is no simple formula to get the point where the bomb touches the ground. I think the easiest way is to simulate the complete flight path similar to what I did with rockets.

BI did the same in that code. They just calculate the next simulation cycle

sent from mobile using Tapatalk

Share this post


Link to post
Share on other sites

This project keeps reminding me why I hated physic back in school.

Would be simple, isn't as it only applies for something that can't ever happen.

 

But, from what I can see at this point, all this information combined might work.

The Script from sarogahtyp has to be transformed because I search for the distance, but as I'm still missing the Thrust, witch I have to replace with well the not existing G_force, witch I hopefully can get from this nice C++ code. ( Witch again calculates with not existing Mass -.- ).

 

If I don't have any thrust, the bombs would fall around 200 m, at a release speed of 440m/s and an altitude of 700m.

So the missing Part is the Thrust. But From what I have, it looks promising. But before I can tell for certain, I have to test it. again.

 

Anyway thanks a lot, as soon as I have a solution I will post it here :P

 

@t_d Where did you get that code? Any chance for more where that come from? :)

 

 

Share this post


Link to post
Share on other sites

@crewt or someone else :-)

 

I think about writing something for this problem but I need some values to calculate physics.

could you ( or someone else :-) please extract some data for several bombs?

 

I need maxSpeed, airfriction, sideAirFriction and coefGravity. The return value of getMass could be interesting as well. But it should used after spwning a single bomb midair (not mounted on plane).

 

Also some measured data bout bomb height (getPosASL), 3D speed vector and time since bomb dropped are useful to resolve arma physics. And if u measure it then the bomb drop should be much higher because I want to see if the bomb breaks maxSpeed value or not... A good test scenario could be a bomb drop at 2000 meters at a plane speed of 500 km/h and mesuring the data every 5 seconds.

 

I used your above data to calculate bombs acceleration but it gives just nonesense (maybe u did use height ATL and not ASL). so I need some more data.

height	    velocity 	time		acceleration
440,7070	59,6742		
434,3820	59,7907	54,29184549	0,00214581
425,7640	60,1183	26,30647131	0,01245321
415,1480	60,7584	16,58490861	0,038595329
402,3910	61,7287	13,14748016	0,073801214
387,6960	63,0061	11,50383592	0,111041222
370,8080	64,6023	10,5801278	0,150867743
351,7080	66,5020	10,05421909	0,188945554
330,0410	68,7262	9,741480083	0,228322594
306,2170	71,2104	9,590210128	0,259034992
279,5940	73,9979	9,550852018	0,291858778
250,1650	77,0638	9,598812747	0,319404085
217,6470	80,4090	9,720793973	0,344128269
181,4890	84,0607	9,901689624	0,368795644
142,2130	87,9360	10,13495729	0,382369643
99,5580		92,0323	10,41305568	0,393381167
52,7978		96,3893	10,73220106	0,405974504
8,4807		100,395 11,06350201	0,36206438

those commas above are points. I m just a german ;-)

Share this post


Link to post
Share on other sites

This script in a fired EH can be used to measure the needed data. It should be execVM'ed or spawned!:

/*
    Author: Sarogahtyp
    File: track_bomb.sqf
    
    Parameter(s):
    0: object - bomb to track (from EH fired)

    Returns:
     nothing - data is copied to clipboard for use in e.g. excel
*/

params [["_bomb", objNull, [objNull]]];

if (isNull _bomb) exitWith {};

_string = "";
_tab = toString [9];
_crlf = toString [13,10];

_end_height = 15;

_time_delay = 5;

_start_time = diag_tickTime;
_delay_end = diag_tickTime + _time_delay;

while{!(isNull _bomb) && !(_end_height > (getPos _bomb) select 2)} do
{
 if(_delay_end < diag_tickTime)
 {
  // getting time, height (ASL) and velocity vector
  _string = _string + format["%1 %2 %3 %4 %5 %6 %7 %8 %9 %10", (diag_tickTime - _start_time), _tab, ((getPosASL _bomb) select 2), _tab, ((velocity _bomb) select 0), _tab, ((velocity _bomb) select 1), _tab, ((velocity _bomb) select 2), _crlf];
  _delay_end = diag_tickTime + _time_delay;
 };

};

systemChat format ["TOF %1", (diag_tickTime - _start_time)];
copyToClipboard _string;

I cant do that because Im at work...

Share this post


Link to post
Share on other sites

Mit Home either: data was ASL every 0.5sec ,  getMass returns 0 on plane or not, maxspeed was 100 (default for bombs) so it seems to break that speed.

 

 

Will be home in nearly an hour, than I can give you more.

Share this post


Link to post
Share on other sites
12 minutes ago, crewt said:

Mit Home either: data was ASL every 0.5sec ,  getMass returns 0 on plane or not, maxspeed was 100 (default for bombs) so it seems to break that speed.

 

 

Will be home in nearly an hour, than I can give you more.

 

100.395  is not really braking it...

Share this post


Link to post
Share on other sites
14 minutes ago, sarogahtyp said:

 

100.395  is not really braking it...

But 220 kindof is? Except if its not the maximal Speed more of the maximal acceleration 

  • Like 1

Share this post


Link to post
Share on other sites
2 minutes ago, crewt said:

But 220 kindof is? Except if its not the maximal Speed more of the maximal acceleration 

yeah. I did not check ur second measurement.

 

But what is that speed value about? is it just z-velocity or is it the magnitude of the speed vector?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×