Search the Community
Showing results for tags 'ode'.
Found 2 results
-
Introduction and Acknowledgment It is the player @hitman1987 and his work on the mod @Reforger that inspire the author with the idea about equation of motion in OFP. $hitman sent the author messages introducing his purpose and achievement in January, including his result of realistic ballistics, which relates to the main content of this topic. On last Saturday, April 18th, 2020, the author happened to have a thought about how projectiles fly in OFP after having read some CONFIG files of @Reforger. The @Reforger also displays some weapons with graduations to the author. It is the first time that the author come into contact with this kinda design. The author wish to add "Artillery Support" in CTI, not in the form of "creating shells by scripts" but by directly shooting. This requiring both trajectory's calculation and graduations displaying, and the products in @Reforger delightfully meets the author's needs. The author builds correct motion equations of "shotBullet" and "shotShell" and gives precise numerical solution (alright, numerical solution is given by RK4 formula). Furthermore with the help of the precise numerical solution, the author directly calculates and draws the graduations for specific weapons and vehicles (the main part affecting the trajectory is InitSpeed of magazines, and the length and the initial angle of the gun affect a small part as well). They're planned to be introduced into TZK in next version. The author summarizes this topic for $hitman, @Reforger and other OFPers. Chapter 1 Equations and Solution There is an annotation in@Reforger of the airFriction, which is a parameter of CfgAmmo objects and isn't explicitly given by BIN\CONFIG of 1.96/1.99. The annotation says //e.g. a projectile with a muzzle velocity of 1640 m/s which slows down 94 m/s/s (i.e. by 94 m/s in the first second) has an airFriction of: -94/16402 ~= 0.0000035. The 16402 of course should be 1640² and the author was thus inspired that in OFP the friction is thus probably obeying The author once explored the relationship between trajectory and mass of bullet's model when trying to design the global tracer effect. The result is mass don't affect trajectory of those bullets whose simulation is "shotBullet" and "shotShell". Thus the should degenerate to , and the coef c might be just the airFriction. Consider the Parabolic Motion with gravity. The equation of motion should be here the means the unit vector in the direction. We divide the vector into horizontal and vertical, and take the up and right as positive direction. Note that the acceleration is the derivative of velocity to time, we gain 2 equations: This is ODEs of and , but it hasn't analytical solution. Although it is only first-order, it's nonlinear. Luckly this simple system has a unique solution for f is independent with time. Having calculated its numerical solution, the author compared it with the distance of an actual bullet shot in OFP with a same initial data as equations', and verified that the coef -c (don't miss the negative sign) is exactly the airFriction, and the gravity in OFP is 9.8 (according to subsequent exploration on the ballistic of rocket, the gravity in OFP probably be 9.8066. But simply applying 9.8 won't cause too much error). There is another implicit parameter coefGravity of CfgAmmo objects. It is just the multiple of g and its default value is 1. No more parameters and terms in the equations imitating wind or other physical quantities. It's possible for editors to define coefGravity for specific ammo or all ammo (by modifying the "Default" object of CfgAmmo) in 1.96/1.99. The airFriction, however, can't be modified in 1.96/1.99. Its default value is -0.0005. The 2.01 ArmA:R explicitly defines both of coefGravity and airFriction in its CONFIG, and editors can thus modify airFriction as well. The author tried modifying their value and check whether the distance is still equal to the calculated one. It is safe to define coefGravity from 0 to 100, but a -0.01 value airFriction can cause 10 meters' error of a 380m range ammo. Editors are recommended not to set too big value for airFriction. To be honest, since the equations don't have analytical solution, OFP must use numerical method as well. The author guess the time difference in OFP probably related to the FPS, which will be inaccurate for high airFriction. 0 coefGravity can be applied for some laser weapons, and for some ammo detecting the direction of weapon (the bullet we catch by Fired-EventHandler, with a nonzero coefGravity , has fallen and thus can't represent the direction exactly). One more to attention: the airFriction should be a negative value. Not verified, but the positive value probably will be treated as 0 (of course, the air fricton won't help accelerating your bullet). About compatibility: it's safe to add new parameter coefGravity for specific ammo in 1.99/1.96, even though it isn't explicitly defined in BIN\CONFIG. The airFriction can't be modified in 1.99/1.96 and must use -0.0005 (one can define airFriction in config but it won't work). Both of them can be modified in 2.01, but be aware that [4RTech] has explicitly defined airFriction and coefGravity in the "Default" object of CfgAmmo of their BIN\CONFIG, editor must not miss airFriction and coefGravity in the BIN\CONFIG of their own mod (this often happen when editors applying their mod direct on 2.01, without modifying their BIN\CONFIG). Otherwise 2.01 game will crash, if using a mod with undefined airFriction and coefGravity BIN\CONFIG, and shooting an ammo with defined airFriction and coefGravity . Complete contents is included in a PDF and can be read/downloaded here. A video displaying its effects of Mortar and Howitzer. In @Reforger players can experience its grenade launcher, the first vehicle that the author has ever seen of this design, and experience some other properties like realistic ballistics, sights zeroing switch, etc.
- 3 replies
-
- 3
-
- motion equation
- projectile trajectory
-
(and 2 more)
Tagged with:
-
Introduction Artillery support using rocket as well. The author thus explored the motion equation of rocket in OFP. The simulation "shotRocket" and "shotMissile" sharing same law, as "shotBullet" and "shotShell" do. The guided "shotMissile" has its own ability tracking target, with the help of maneuvrability, but this is out of the author's personal interest and current ability range, and remain to readers. Unless otherwise specified, the "rocket" in the following always includes "shotMissile" as well, but guiding won't be discussed. Totally speaking, parameters initTime, thrustTime, thrust & sideAirFriction are introduced here. Besides maneuvrability, the simulationStep & maxSpeed aren't researched either. To be honest, the author didn't find out how they affect rocket, and they maybe are for "shotMissile", too, because only the AT3, the father class of all guided missile in original CONFIG, has a 0.01 simulationStep . As for maxSpeed , no matter it is 10,000 or only 10, the author didn't observed it limited the rocket's velocity. And those parameters for bullet/shell, i.e., airFriction & coefGravity, and the model file including its shape or mass, will do nothing to rocket. The method the author analysis the air friction is measuring the equilibrium speed in different parameters. At equilibrium the acceleration of air friction is equal to thrust or gravity. Thrust has been verified by @sarogahtyp in https://forums.bohemia.net/forums/topic/189449-solved-simulate-rocket-flight-airfriction-correction-thrust-in-cfgammo-is-equal-to-acceleration/?tab=comments#comment-3001914 that is acceleration as well and in m/s². According to known thrust or gravity as acceleration and measured equilibrium velocity, the author is able to dope out the formula. More narrowly, the author discovered that the ratio acceleration/sideAirFriction gives an unique equilibrium velocity. From fundamental physical knowledge, the air friction should be the function of velocity, and since the ratio acceleration/sideAirFriction decides the equilibrium velocity, the sideAirFriction has been decoupled from the formula: it must be simply a factor in the whole formula, meaning the formula should be here c means sideAirFriction. Then basing on measured ratio a/c and velocity v, and luckily the mapping f is polynomial, the author explicitly gives the expression of f. Again, by the formula, the ODEs of motion can be given. Chapter 1 Motion Equations Previous exploration about ballistic of bullet/shell is recommended to have a look first, if you haven't read it yet. In this article some concepts mentioned there won't be explained in detail. The very first thing to be declare is that there are 2 mode for rocket's flying, depending on whether the rocket ammo (object of class CfgAmmo) has a nonzero thrustTime (yeah, the thrustTime but not the thrust, although the common sense prefer the latter). In spite of rarely being used, the case thrustTime=0 will be introduce first, for it's simpler, and can help readers building basic comprehension. thrustTime = 0 In this case, the mapping f is Here, the v means the the length of velocity vector . The trajectory of rocket in this case is similar to bullet/shell. The main part of air friction is the term 0.001× v², which is just double of shelll's formula (remember? The default airFriction for shell is -0.0005) unless the velocity too high or too low. Analogously, applying RK4 method we can have a numerical solution. (Regrefully, though, the velocity in this mode will be affected by the difference between rocket's velocity and 3D-direction. Numerical solution ignoring this will have error of tens meters. This remain to be solved.) Here list some facts of rocket. They're important and worth knowing. Gravity. As mentioned above, the ratio acceleration/sideAirFriction decides the equilibrium velocity. On the contrary, the equilibrium velocity locally decides an unique acceleration/sideAirFriction. In gravitational direction without thrust, the only acceleration are provided by gravity and air friction. Having measured many different sideAirFriction including 0 (free falling movement), we can gain a more precise gravitational acceleration than 9.8. The fitting value is 9.8066~9.8068. 3D-direction. The direction vector of bullet/shell and rocket with nonzero thrustTime is constant. But for 0 thrustTime rocket, the direction is variable. It'll incline to its current velocity vector, but mostly don't equal to the velocity. The direction here, i.e., for bullet/shell or 0 thrustTime rocket, won't affect the trajectory (for those whose direction too much different from velocity, trajectory will be slightly affect until direction close enough to the velocity vector). But direction is important to nonzero thrustTime rocket and guided missile. The thrust is always parallel to the direction vector, and for guided missile, the change of direction probably is a good (or even unique) indicator of the parameter maneuvrability. The 3D-direction of ammo is equal to the direction of weapon when being shot. In 2.01 ArmA:R the command vectorDir will return the 3D-direction, but no way in 1.99/1.96 to know z-direction. Thus 2.01 ArmA:R is recommended when exploring guided missile. Time to Live. A surprising conclusion is the life time of 0 thrustTime rocket is infinite, until it collide something. This is interesting and can be applyed for long range shoot, better than shell (whose life time is longest but still limited no more than 20 seconds, unless its timeToLive parameter is modified). Initial Velocity. Although the initSpeed is magazines' parameter, it doesn't decide the initial velocity of shot rocket. All rocket shot by weapon have a constant speed 20m/s (or say 72km/h, which is the return value of Speed command in km/h). The elevation of initial velocity is about +2.5° than weapon's (and thus ammo's). This is a special correction for rocket. However it's hard to obtain exactly value, because no way to remove the gravity for rocket like exploring bullet/shell, and thus can't gain unaffected velocity vector. Luckily this won't affect too much since the initial velocity is poor 20m/s and can be ignored when either thrust or thrustTime not too small. As for 0 thrustTime case here, the 20m/s initial velocity without any thrust certainly can't be applied in OFP, and editors must assign another velocity by setVelocity command and thus needn't to concern this unknown correction. The Gravity and 3D-direction here is useful for bullet/shell as well. The author used to thought global tracer effect must rely on 2.01 command setVectorDirAndUp, but this is unnecessary for shell's velocity is independent with the direction. As for Gravity, 9.8 or 9.8066 won't affect the trajectory too much. Even in long range shooting, the calculated distance of these 2 value have no more than 2 meters' difference. The only rocket in original OFP with 0 thrustTime is LGB (and bomb ammo of BISCamel plane's weapon). Common "rocket" don't apply this design. However its infinite life time and shell-similar air friction is good for artillery supporting. Since its initial velocity (and 3D-direction) must be assigned (unless you wish to use the useless 20m/s) and it hasn't thrust period, editor can completely know initial states of the 0 thrustTime rocket, and calculate precise enough trajectory and range via numerical method. thrustTime > 0 This is general case in OFP. It has its own law. Consider a plane spanned by the 3D-direction of the rocket and the direction of gravity. Such a plane is unique, except for when rocket is parallel to gravity, which can be ignored as trivial situation. We claim that the motion is separated into horizontal part and vertical part, and they are independent. As displayed in figure, we call the 3D-direction of rocket "H" and the vertical direction "V". The θ means the elevation of rocket. And there're some other rules: Thrust is parallel to H direction (don't forget direction is constant when thrustTime>0). Gravity should be separated into 2 directions for they're independent. The (air friction in H direction) is still but decided not by the length of any longer but only . The (air friction in V direction) is which is decided by only. And coefficient in this formula is much bigger than ()'s, thus velocity in V direction won't be too high due to large friction. It seems more complex in this case, because we have to devide the motion into 2 directions. But actually the problem is simpler, especially because of the indenpendence between 2 direction. Using rotation matrix we can easily convert between x-y and H-V coordinate. And the indenpendent air friction in 2 directions even allow us solve the ODE because the indefinite integral can be expressed by elementary functions (the integrand is a rational function). However the solution is implicit and what we need explicitly is the (the inverse function) here, which is a non-elementary function (equation is transcendental for ), and we still have to rely on numerical method. (By the way, it is because of f is polynomial that the author can simply obtain its explicit expression with exact coefficients. For more complex f it'll be hard to know what it's expression is, but actually we don't have to. As mentioned in bullet/shell case, the system has a unique solution when A is independent with time. Since we mostly have to use numerical method to calculate the solution, we can get segmental fitted numerical function of f, and apply it in numerical method like RK4. Although the formulas here for rocket in OFP have been built precisely, this view is still useful when exploring something new.) Complete contents is included in a PDF and can be read/downloaded here.
- 2 replies
-
- 2
-
- motion equation
- rocket trajectory
-
(and 2 more)
Tagged with: