Jump to content
sarogahtyp

[SOLVED] Simulate rocket flight - airFriction correction - thrust in CfgAmmo is equal to acceleration

Recommended Posts

Prologue:

I d like to write an aiming help for any weapon which draws a crosshair at the point of the screen where u have to aim to get a hit.

It should help to get the offset caused by moving speed only. The offset caused by weapon ranging is not covered.

What I did until now is to calculate the time which a non propelled bullet flies from weapons muzzle to target.

I did that with this formula for evenly accelerated motion:

s(t) = 1/2 a t + v(0) t

where is

s(t) - length of passed way at time t

a - acceleration value

t - time value

v(0) - speed at start of the motion

I converted that formular to get the time after object passed a specific length:

t(1,2) = +/- SQRT(2 s / a + (v(0) / a)²) - v(0) / a

that formula seems to be correct and is working.

Then I discovered that arma does not calculates this with an evenly accelerated motion.

Arma ´slows the bullet down with a non evenly accelerated motion which depends on the current speed.

That fact is represented in armas formula and description for air friction:

f = a / v²

this means that

a = f * v²

which means that acceleration is changing with speed.

I tried to get some formula similar to the above to get a solution for the flight time but I got a 4th degree equation and my math abilities r not able to solve that to get the flight time.

Accepting this fact, I decided to simulate the flight to get the time instead of calculating it.

This is what I did in this script:

/*    Author: Sarogahtyp    File: sim_shot.sqf    Parameter(s):    0: speed - initial speed of bullet    1: air friction - armas value from CfgAmmo (f=a/v²)    2: distance - distance between firing and target position    Returns:    time - flight time of bullet*/params ["_init_speed", "_air_friction", "_distance"];if((_init_speed = 0) or (_distance  5000)) exitWith {0};_dist_step = _distance / (10*diag_fps);_last_dist = 0;_last_time = 0;_time_diff = 0;_last_speed = _init_speed;_last_accel = _air_friction * _init_speed^2;while {_last_dist < _distance} do{ _new_dist = _last_dist + _dist_step; //calculate time from last position to actual position (_time_diff) if (_last_accel < 0) then // standard case {  _term = _last_speed/_last_accel;  _time_diff = -1*sqrt(_term^2 + 2 * _dist_step / _last_accel) - _term; } else {  if(_last_accel == 0) then  //maybe no value for air friction stored in config then we have just t=s/v  {   _time_diff = _dist_step/_last_speed;  }  else  // positive acceleration should never happen for a bullet  {   _term = _last_speed/_last_accel;   _time_diff = sqrt(_term^2 + 2 * _dist_step / _last_accel) - _term;  }; };  _new_time = _time_diff + _last_time; _new_speed = _last_speed + _last_accel * _time_diff; if(_new_speed <= 0) exitWith {0}; _new_accel = _air_friction * _new_speed^2;  _last_dist = _new_dist; _last_time = _new_time; _last_speed = _new_speed; _last_accel = _new_accel;};_last_time

Thats already done work now:

Whats the problem?

What I want to do now is simualte the flight for a self propelled unguided rocket like titan or rpg.

The values I need r given by CfgAmmo an here they are:

initTime - How long (in seconds) the projectile waits before starting it's motor.

maxSpeed - Declares the maximum speed (metres per second).

thrust - Engine power for missiles and rockets.

thrustTime - Engine burn time for missiles and rockets.

but as I tried to get it all from CfgAmmo I got the following values for titan and RPG:

weapon initTime maxSpeed thrust thrustTime

----------------------------------------------------

titan | 0.25 s || 200 m/s | 130 ? | 3 s

----------------------------------------------------

RPG | 0 ||||||||| 140 ||||| 0.1 ||| 0.1

the values for titan r looking good but I cant do anything with the values for RPG...

How can I get the correct values for every self propelled weapon?

An another big question, what is the unit of thrust?

Share this post


Link to post
Share on other sites

Unit of thrust is most likely in Newton (a force).

 

And when you are calculating trajectories keep in mind armas physics simulation is not the best. I already encountered some discrepancy between physical correct calculations and ingame results.

Share this post


Link to post
Share on other sites

Unit of thrust is most likely in Newton (a force).

Thank you for ur reply.

R u sure about that in arma?

1 N = 1 kg * m / s²

that means F = m * a

but afaik there is no weight stored in armas ammo. how can I calculate the acceleration without the weight?

I guess that thrust is a value which manipulates the acceleration (like air friction) without use of mass.

Thats why I m asking if u r sur...

Share this post


Link to post
Share on other sites

but afaik there is no weight stored in armas ammo. how can I calculate the acceleration without the weight?

I guess that thrust is a value which manipulates the acceleration (like air friction) without use of mass.

Thats why I m asking if u r sur...

 

The mass is stored in the model p3d.

Share this post


Link to post
Share on other sites

The mass is stored in the model p3d.

is there a chance to get this value by script? If yes, how?

Share this post


Link to post
Share on other sites

is there a chance to get this value by script? If yes, how?

Digged through the configs some time back, to no effect.

There also doesn't seem to be a script command for this (getMass requires the object to be spawned).

Getting a models mass from the config would make lots of things easier (checking if a chopper can lift an object before spawning it etc.).

 

Cheers

Share this post


Link to post
Share on other sites

Digged through the configs some time back, to no effect.

There also doesn't seem to be a script command for this (getMass requires the object to be spawned).

Getting a models mass from the config would make lots of things easier (checking if a chopper can lift an object before spawning it etc.).

 

Cheers

Thanks for ur feedback. First it gave me some hope because i thought I can spawn a bullet, get its weight and delete it but then I read this here:

Crates return their initial mass, but if you empty them or load items, magazines and weapons, the mass remains the same. In fact, none of these (non-physx) objects has a mass.

 

Sadly, the question remains, how can I use that thrust value?

Share this post


Link to post
Share on other sites

Parabolic trajectory calculations and the etc. Are 4th degree equations. They can't be simplified.

They require Calculus.

Share this post


Link to post
Share on other sites

Parabolic trajectory calculations and the etc. Are 4th degree equations. They can't be simplified.

 

Thank u but thats what I tried to say in my first post and thats the reason why I simulate the flight and not just calculate the needed time.

but thats not the point. the point is that there is no weight stored for bullets and that i dont know what the thrust value of CfgAmmo represents.

Share this post


Link to post
Share on other sites

Thank u.

I was there too but I dont get any information what exactly the thrust is. I know how to get its value but Idk how to use it and I cant find that info anywhere even not in ur posted link.

I just need the unit of the value of armas thrust. it cant be Newton because there is no weight which can be used for bullets.

Share this post


Link to post
Share on other sites

i dont know how to say it else.

i already know how to get the value but i dont know its units.

in real physics it is newton and u can use f=m*a to calculate a.

but in arma they seem to do those trajectory things without mass.

i had the same problem with air friction which unit is newton normally too.

then i found armas equation for it and it turns out that armas air friction is calculated without mass.

armas air friction formula is f=a/v².

after i got that formula i was able to calculate a from it.

now i m at the same point with thrust. i have a value but i dont know what it means because it cant be the same as thrust is in real physics.

Share this post


Link to post
Share on other sites

I am not sure your airfriction formular is right. In the real world airfriction is linear in terms if v, not inverse and squared.

I am using Fdrag = _airFriction*(vectorMagnitude _weaponVelocity) and that fits bombs and missiles well ingame (exept a small numerical factor).

Share this post


Link to post
Share on other sites

You'll probably find the mass exists, but not in the scripting space. More likely the .dll and C++ space. Same place NKEY stores the power values for TFAR.

Share this post


Link to post
Share on other sites

may be but i think they do it without mass i assume that thrust is just acceleration and i will try it with this assemption as long i have no formula. then i will see if a rocket hits a driving tank...

thanks for ur help guys but i think we r stuck at this point without any further information from a bi developer.

Share this post


Link to post
Share on other sites

A conclusion you could have drawn based on arma 3's PhysX library usage.

Google: "Thrust PhysX Projectile"

i missed that info as i read ur post the first time. maybe you edited it afterwards.

i ll definetly give it a try.

Share this post


Link to post
Share on other sites

i have my doubts that rockets truly consider physical mass... Those formulas are older then PhysX implementation and i doubt it's been added. Thrust may be some arbitrary value. If i were you i would test around what the actual impact of this value is.

You could first make a script that logs the speed and position of the missile over time, and write it down into a file. Don't ask me how - i'm not the scripting expert here. Then use it in excel to extract usefull information.

 

also - you are lacking a key value:  initspeed. Missiles/rockets do not have to start at 0 speed. Initispeed is found in the magazine class, or in the weapon class.

Share this post


Link to post
Share on other sites

i have my doubts that rockets truly consider physical mass... Those formulas are older then PhysX implementation and i doubt it's been added. Thrust may be some arbitrary value. If i were you i would test around what the actual impact of this value is.

You could first make a script that logs the speed and position of the missile over time, and write it down into a file. Don't ask me how - i'm not the scripting expert here. Then use it in excel to extract usefull information.

 

also - you are lacking a key value:  initspeed. Missiles/rockets do not have to start at 0 speed. Initispeed is found in the magazine class, or in the weapon class.

 

after all searching i also doubt that there is any physical mass for any ammo.

And I think ur absolutly right with the Point that I ve to get the Information I Need from a flying rocket.

 

last thing, I know about that initspeed. It is mostly 30 m/s for infantry based launchers as Titan. I know that the missle/rocket flies with that Speed (decelerated by air friction) until initTime is reached. After that the rocket Motors ignition starts and is acceelarating until thrustTime is expired or maxSpeed is reached.

 

I think I understand the procedure but please correct me if i m wrong.

Share this post


Link to post
Share on other sites

 

 

after all searching i also doubt that there is any physical mass for any ammo.

 

Doesn't the magazine itself have mass? (even the launchers have magazines, but with single rocket only) why not just divide that by however many bullets are present, and that would surely equal the weight of each bullet. I guess it might be an arbitrary value and means nothing to the actual bullet weight, but its worth a shot. 

Share this post


Link to post
Share on other sites

Doesn't the magazine itself have mass? (even the launchers have magazines, but with single rocket only) why not just divide that by however many bullets are present, and that would surely equal the weight of each bullet. I guess it might be an arbitrary value and means nothing to the actual bullet weight, but its worth a shot.

they have no mass in config. after the facts from post 7 and my test with spawning bullets and use getMass (failed) I doubt that magazines have a mass. I think there is no other way as to track the flight of some rockets and hack the data into excel to analyze its math...

Share this post


Link to post
Share on other sites

rpg42 rocket is simulated like bullet or mortar shell - low speed, high-parabolic trajectory. this matches the real life, in rpg's engine is working only for fractions of second to gain some speed. in case of rpg7 the powder charge is burnt inside barrel.

  • Like 1

Share this post


Link to post
Share on other sites

All the infantry weapons' magazines do have mass (CfgMagazines >> "name" >> mass) and the values are sensibly filled. For vehicle weapons' magazines, this value is usually set, but not useful (default value seems to be "8". Sadly this even coincides with some infantry magazines that actually have the mass of 8, so filtering isn't that easy either).

However, that is not necessarily a true equivalent for the projectile mass, because both the actual magazine case as well as the bullet casing are included, both not being relevant for the projectile that is expelled. And both constitute a significant part of the mass of a magazine.

Share this post


Link to post
Share on other sites

okay guys, thank u for clarifying about mags mass. i think ill try to find a solution without using mass.

I started with tracking bullets and I do that with a fired EH and this script:

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

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

params ["_bullet"];

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

_start_time = diag_tickTime;
_end_time = _start_time + 5;

while{(diag_tickTime < _end_time) and !(isNull _bullet)} do
{
 _string = _string +format["%1 %2 %3 %4 ", (diag_tickTime - _start_time), _tab, (vectorMagnitude(velocity _bullet)), 

_crlf];
};

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




here is an image of the NLAW data as a v-t-diagram
NLAWcabc.jpg
it corresponds to its data got from conf:
 

weapon      initSpeed  initTime maxSpeed thrust thrustTime
NLAW        30         0.25     275      400    0.75
RPG         30         0        140      0.1    0.1
titan AA    30         0.25     850      385    2.5
titan sh AT 30         0.25     200      130    3
titan sh AP 30         0.25     200      130    2 

I would say now it is proven:

(275 m/s - 30 m/s) / (0,85s -0,25s) = 408,33 m/s² round about 400 m/s² !!!

thrust is equal to acceleration

could someone with a wiki account please do an entry in CfgAmmo and in Config Properties Megalist?

  • Like 1
  • Thanks 1

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

×