PDA

View Full Version : Artillery Radar, need math help

NouberNou
Aug 21 2009, 00:23
I am working on an artillery radar script suit to provide locations for counter battery fire.

It basically works using nearObjects and looking for artillery rounds within a certain distance and then it begins tracking them.

The problem is I suck at math. I am not sure how to even begin calculating trajectories using the data I am getting. I know I need the velocity and the angle, the velocity is easy enough to gauge by sampling, but I am having trouble determining the angle since I might be tracking shells that are already changing their flight angle due to their ballistic path.

Gigan
Aug 21 2009, 11:18
I think that the atan command can be used as a method of obtaining the angle of a warhead.
http://community.bistudio.com/wiki/atan2

The position of a warhead is acquired first. And it vacates during several seconds and, similarly a position is acquired.
The atan command is used and the angle of the direction to which the warhead went is obtained from the obtained length for two points.

_posx1 = _pos select 0
_posy1 = _pos select 1
_posz1 = _pos select 2
~0.1
_posx2 = _pos select 0
_posy2 = _pos select 1
_posz2 = _pos select 2
_angle = sqrt((_posx1 - _posx2)^2 + (_posy1 - _posy2 )^2) atan2 (_posz1 - _posz2 )
If this processing is repeated continuously, transition of angle change will also be able to be obtained.

The vectorUp command can also be used as another method.
http://community.bistudio.com/wiki/vectorUp
Since the magnification of the vector of each axis can be obtained with this command, that value can be used for calculation of a warhead advance angle.

sbsmac
Aug 24 2009, 10:09
Hopefully this helps. Apologies for the jpeg but the forum doesn't handle formulae very well :-)

http://homepage.ntlworld.com/n.macmullen/ArmA/counterbattery.jpg

Obviously this takes no account of air resistance or other non-ballistic effects. Clearly, it won't work for rockets or rocket-assisted shells (but then again I suspect real counter-battery radar has a problem with these).

There will also be an error introduced by the fact that the assumed firing elevation won't be correct. The easiest assumption to make is that the battery is firing from the same elevation as the radar but a more sophisticated approach would to to try and use some kind of iterative approach like this . ..

initial elevation, E = radar elevation

do until firing position stable...
{
firing pos = calculate firing position using E
//get a better estimate of elevation
E = getposasl (firingPos)
//loop back round to get a better estimate of firing position
}

*Edit* As you may have noticed, the equation gives you two solutions for T. The negative one is the time to impact which might also be useful to you. :-)

bravo1romeo
Aug 25 2009, 03:24
Neglecting air resistance will result in incredibly inaccurate results.
the velocities of objects can be obtained with the velocity command.
I'm working on a artillery - map aiming script, the maths is very complex.
I pulled apart some binaries and found the value used for Air resistance on the M119 shells is 0.00045 and they are fired at 850 meters per second.
Using projectile camera chase scripts I have found that Tank shells actually travel much further than the Howitzer shells in the game (talking KM here), and in the binaries I found tank shells to have air resistance set to 0.00004.
The force slowing the projectiles is F = V² x R
Where V = velocity, R = air resistance.
Still working on the maths.

NouberNou what exactly are you trying to track shells for, I don't quite get what your trying to achieve, there may be an easier way.

Gigan
Aug 26 2009, 08:50
This is one experiment mission.
The trench mortar shell released out of the distant place is made to collide with a non-guided bullet(M119).
Since M119 of the present condition only continues aiming at the position of a trench mortar shell, it does not hit, even if it shoots. In order to hit well or to bring bullets close, precise ballistic calculation must be performed and the muzzle of M119 must be made to be turned to the prediction course of a trench mortar shell. And it is made to succeed whenever M119 may fire.
Anyone, are there those who can realize this according to math? :D

sbsmac
Aug 26 2009, 09:23
>Neglecting air resistance will result in incredibly inaccurate results.

Yes, I believe you :-( Unfortunately solving the differential equation that results from accounting for air resistance is something I might have been able to do 20 years ago but well past me now !

There is an alternative approach that doesn't require any maths at all of course....

Just hook the 'fired' eventhandler and setVariable a record of its firing position if the object is an artillery shell. Then if it comes into range of the battery, you can just look up where it was fired from ! The equations I gave will at least give an approximation of the time-to-impact.

Apocal
Aug 26 2009, 16:31
There is an "Arty_ShellTrack.sqf" already built into the Artillery module.

scriptName format ["%1ARTY\data\scripts\ARTY_shellTrack.sqf (_this: %1)",_this];
#include "h\arty_scripts.hpp"

// ARTY_shellTrack.sqf
//
// Updates position of shell tracking markers on the player's client.

private ["_updateAlt", "_updateVel", "_updateTOF", "_shell", "_alt", "_vel", "_launchTime", "_mkr", "_mkTxt"];

_updateAlt = _this select 0; // Track altitude.
_updateVel = _this select 1; // Track velocity.
_updateTOF = _this select 2; // Track time of flight.

// Go through catalog one at a time
for [{_i=0},{_i < count BIS_ARTY_SHELLCAT},{_i = _i + 1;}] do
{
_x = BIS_ARTY_SHELLCAT select _i;

_shell = _x select 0;
_launchTime = _x select 1;
_mkr = _x select 2;

if (!isNull(_shell)) then // Update shell tracking stats.
{
// Create marker if necessary.
if (_mkr=="") then
{
// Set marker name, increment marker name counter.
_mkr = format ["BIS_ARTY_SHELLMARKER_%1", BIS_ARTY_SHELLCAT_CTR];
BIS_ARTY_SHELLCAT_CTR = BIS_ARTY_SHELLCAT_CTR + 1;

_markerobj = createMarkerLocal[_mkr, [getPos _shell select 0, getPos _shell select 1]];
_markerobj setMarkerShapeLocal "ICON";
_mkr setMarkerTypeLocal "DOT";
_mkr setMarkerColorLocal "ColorRed";
_mkr setMarkerSizeLocal [.5, .5];

// Update new shell data.
_x set [2, _mkr];
};

// Determine marker text if any.
_mkTxt = typeOf _shell;
if (_updateAlt) then {_mkTxt = _mkTxt + " " + format ["Alt: %1", getPos _shell select 2];};
if (_updateVel) then {
_vel = sqrt((velocity _shell select 0)^2 + (velocity _shell select 1)^2 + (velocity _shell select 2)^2);
_mkTxt = _mkTxt + " " + format ["Vel: %1", _vel];
};
if (_updateTOF) then {
_tof = time - _launchTime;
_mkTxt = _mkTxt + " " + format ["TOF: %1", _tof];
};

_mkr setMarkerTextLocal _mkTxt;
_mkr setMarkerPosLocal [getPos _shell select 0, getPos _shell select 1];

}
else // Remove null shell from the catalog; remove its marker.
{
if (_mkr != "") then {deleteMarkerLocal _mkr;};
BIS_ARTY_SHELLCAT = BIS_ARTY_SHELLCAT - [_x];
};
};

bravo1romeo
Sep 11 2009, 07:14
If your trying to track where the shell came from I't would be easier to just note which vehicle fired the shell, then mark it's position if the shell lands near the unit which you want to track it. PM me if you wan't me to work on some code.

On a side note I have tested my map aiming script.
It provides several advantages over the ingame module:
Kills actually count as yours when they impact. (the module seems to delete the projectile and respawn it resulting in kills not counting.)
Calculates both high and low trajectories
Takes into account, air resistance, ground topography, height of your howitzer ASL. (unlike the module where you have to reference your height vs target height)
Can be used on any projectile weapon, such as Tanks and Grenade launchers.

NouberNou
Sep 12 2009, 00:03
Wow thanks guys, yea I kinda went away from this idea. It was more for fun then anything actually realistic. Thanks for your help though, I am learning new stuff. :D

I do want to implement Artillery Radar, and will probably just fake it with the shell tracking methods available.

bravo1romeo, that is an amazing video! I would love to get my hands on that script. It is a shame that my sections kills do not count during missions (I am part of a mortar unit)!

Apocal
Sep 13 2009, 02:51
Release release release!