Wednesday, April 3, 2019

Mathematical and Physics Concepts in Computer Games

Mathematical and natural philosophy Concepts in Computer GamesIntroductionA two dissociate subsidization was distri anded and fork unrivaled was run a assumption of a wedded divergential par victimization quantitative desegregation techniques i.e. Euler and quaternary prescribe Runge-Kutta orders. Also continued as part one a submit showing the results of the simulation was to be produced and severally assess was to be to 3 decimal places. Two graphs where to be produced a) a plot of for apiece one simulation result and the admit ascendent b) a plot of geological fault set in from each one simulation and a short analysis of the results was to be produced. Part two a little more involved than part one was to implement realistic natural philosophy of a uprise straw man in earth atmosphere.Part 1To rate the diminutive theme was the simplest of equatings mostly beca victimisation up it was provided it was a matter of processing the data. In simple hurt to calculate the strike equivalence was displayed such as 1/(1+t), whereas t is snip and increments by 0.25 each theme, in that respectfore the par would panorama standardized 1/(1+0.25) = 0.8 and the next tint is 1/(1+0.50) = 0.667, furthermore is quite light-headed to calculate this equation.From the results appendix a1 there are noticeable remnants between Euler and the exact firmness, first of all of all for Eulers rule I customd y-1+-(y-12)*(h), loosely empathized into simpler monetary value y-1 is the previous y orchestrate + -previous y ordain to the ability of 2 calculate by h which in this case h was live to 0.25. After having figure out the equation for each t i.e. the x direct a significant difference was noticeable. After calculating Eulers results next was to calculate Eulers errors including the first y coordinate which was relate to 1 indeed the exact beginning for the first y coordinate was also equal to 1 so there would be an error equal t o 0 as the result. However the rest of the results varied but still remained below their equal t (x) coordinate for example t 0.250 was equal to y 0.800 in the exact solution and 0.750 in Eulers, after analysing the rest of the results prior to the enumeration it was clear each Euler y result was lower than the exact solution y coordinate and was fairly lenient to come to the error by simply exact solution y Euler solution y. Upon summing up all of Eulers results it gives a solution of 0.761 and dividing that by 41 gives a solution of 0.019. The reason out it was divided by 41 is because there are 41 y coordinates including the first y coordinate which is equal to 1, therefore revealing the comely number Euler error, suggesting Eulers method missed out on the exact solution at an estimate of 0.019, this does not seem a medium-large difference but when trying to implement real physics in a impale it makes all the difference. The graphs in appendix a3 shows the simulation for E ulers method and the exact solution where it is easy to see each y coordinate and each error coordinate whereas a4 shows the closer Eulers line and the exact line go to each other as t (time), (x coordinate) ascends, this suggests that Eulers method becomes more sinless over time and after using Eulers method for a colossal period of time eventually Eulers wouldve matched the exact solution at roughly point. Having viewed a3 and a4, a8 shows the linear line for the exact solution and the linear line for Eulers method.quaternary Order Runge-Kutta method was more complicated than Eulers mostly because as shown in a1 the solution is more entire because of the tips that must be deliberate in order to solve each y coordinate see a2 for each slope solution. First and foremost we start by solving the first slope as k1 which was calculated as -(y-12) and like Eulers method translate to minus (the previous y coordinate to the power of 2) thats how k1 was solved. K2 has bit more comput ation to process which looks like -(y-1+(0.5*k1-1*h))2) translated to simpler terms is minus(previous y irrefutable (0.5 multiply by previous k1 cipher by 0.25)) to the power of 2) this is how the second slope is discovered, solving k3 is much simpler because k1-1 is replaced with k2-1 the previous k1 solution that was just solved and k4s calculation becomes smaller -(y-1+(k3-1*h)) to the power of 2) just like k2 and k3, k4 using k3s previous solution that was solved. The fun part is finding y+1 which is the next y coordinate per t coordinate the calculation used is (y-1+((1/6)*(k1-1+2*(k2-1)+2*(k3-1)+k4-1)*h)) a significantly long calculation but reliable as it go away get close to the exact solution result, translated it is (previous y coordinate summing up(1 divided by 6) reckon by (previous k1 solution irrefutable 2 reckon by (previous k2 solution) plus 2 work out by (previous k3 solution) plus (previous k4 solution) multiplied by 0.25). The sum of RK4 errors are 0 and t he average was evenly 0 that is an incredibly accurate method but more complicated to solve as Eulers method is the simplest RK method (first order) which is why RK4 is more accurate as it is a multi-stage method. See appendix a5 for each y coordinate because RK4 method was incredibly accurate the exact solution coordinates cannot be seen but the data types are there to see and the legend is also there to show the different styles between each coordinate, appendix a6 show the breaking ball without whatsoever coordinate markers on them, again the curves cannot be distinguished from each other because of RK4s incredible the true. See appendix a7 to see the error coordinates for each consolidation technique on the same graph it is quite easy to see which method is much more accurate but again this is because Eulers method is a first order method whereas Runge-Kutta is a quaternate order method, Runge-Kuttas method has more step in solving the equations therefore providing for a more accurate solution and producing less error values, whereas Eulers method only has one step and will always provide an error value each time. See a9 for the linear line of the exact solution and RK4 inclination, it is extremely difficult to see because RK4 method is so accurate.Part 2After using RK4 in part 1 an understanding it had interpreted some time to put it into physics, however the following scenario seems to be correct.The equation for speedup is a = ( long suit Rocket + Force Drag) mint.The equation for Force quarter is force drag = -0.5 * (0.23) * (0.2) * (202) * (22) 2The time step that is used is 1 i.e. 1kg m2 because that is how much it can increment or diminution by with the user input. Time will go up to 60, the guck the roquettes force can go up to is 20kg m2 and because speedup is a derived of focal ratio k1 = (time + velocity) i.e. the x and y places. To find k2 the equation was k2 = (time + 0.5 * h, velocity + k1 * h), to find k3 is the same as k2 except the k1 in the equation is replaced with k2. K4 the last slope is calculated as k4 = (time + h, velocity + k3 * h). Lastly quickening is calculated as a1 (next acceleration value) = (a-1 (previous value) + 1/6(k1 + 2 * k2 + 2 * k3 + k4) * h). The catchy part is getting the equations correct after that it is a matter of using a loop in game to calculate the players position the players position is equal to 5 metres.Pseudo Code for in game defy Static Class quaternate Order Runge-KuttaDo hold in portion double RK (x, y) variables declared as doubles (timer and velocity)Declare a smooth variable to calculate 1/6 as fS (fraction sixth)Declare rocket position as 5Declare timerDeclare a static double rk4(double x, y, h, RK f) x, y and h are doubles, r is called from point variable)Declare half of h as halfhDeclare Double k1, k2, k3, k4Declare acceleration equals 0y = accelerationK1 = (x plus y)K2 = (x plus halfh multiplied by h) plus (y plus k1 multiplied by h)K3 = (x plus ha lfh multiplied by h) plus (y plus k1 multiplied by h)K4 = (x plus h) plus (y plus k3 multiplied by h)Return (y plus fS multiplied by (k1 plus 2 multiplied by k2 plus 2 multiplied by k3 + k3))RK acceleration equals y2 Returns accelerationDeclare Force drag kg to the power of 2 = -0.5 multiplied by (1.2 to the power of 3) multiplied by (0.2) multiplied by (20 to the power of 2) multiplied by (y to the power of 2 per second) because y is velocityAcceleration = (timer + force drag) / mass (decrement mass by 1 every second))Player position plus acceleration every secondIf detect pressed equals up growing acceleration by 1Else if key press equals downDecrement acceleration by 1Print timer, player position, acceleration and y plot timer is less than 60FlowchartCritical analysis of the use of numerical desegregation techniques to solve similar situations in game knowledgeIn the context of differential equations no numerical integration method is cognize as the method that is the best me thod to solve whatsoever and all ordinary differential equations. It all depends on the type of equation that is presented. When discussing gaming physics the solution to the differential equations plays a big part in games taking on more realism for example if a player fires an arrow in the air from a crossbow depending on velocity, gloominess and wind etc. When and where will the arrows new position be inwardly the game environment? Physics can be found roughly anywhere whether it is in Skyrim shooting an arrow that will eventually cast aside or sniping in Battlefield that also includes bullets descending over time which is incredible and makes the games more realistic and much more difficult. Before using any method some basic equations must be known first for example force = mass multiplied by acceleration and acceleration = force divided by mass, standard equations that can be learned just using a search engine. Next the derivative of velocity is acceleration and the deriv ative of acceleration is position, a derivative is something which is establish on another source 1There are several methods to distinguish from when it comes to differential equationsFirst order integrationHigher order integrationFirst order integrationEulers MethodOne of the rather simpler methods that game developer can use although as already seen above it is not the most accurate. 2 Just like the previous ordinary differential equation that was solved in part one a developer takes the initial position and velocity and calculates the next position and velocity over time, a time step is used to calculate the next position and velocity such as the previous one that was used 0.25, once the first value is calculated the method is simply repeated to calculate the next one. An equation could look like this Vn+1 = Vn + (An *dt) whereas V is velocity and A is acceleration so the position could be calculated like Pn+1 = Pn + (Vn *dt) whereas P is position. Although this is a simpler me thod to use an error value will always be return because it is not the most accurate to produce solutions. Using any method can produce error values which is why the numerical integration methods provide estimations and not exact solutions whereas as the error value calculates how far off the estimation was from the exact solution. According to Bourg 3 instability is eliminated or minimized by smaller step sizes however larger travel size seems to make the problem much more complicated than it necessarily to be. Stability plays an important part for calculating equations more calculations will be graceful if the step size is significantly small however this results in more stability. Bourg 3 mentions an reconciling step size where after a predicted numerate of error the step size is changed as calculations are being processed. To use adaptive step size method it has to be based on the errors given from the estimations by doubling the step size, Heidts 4 mentions in his abstract the adaptive step size method works considerably well with second-order split-step Fourier integration scheme and can be greatly improved when using it on base 4th order Runge-Kutta method. Unless the error values provided by Eulers estimations causes a ripe change in a games physics then there should be no problem using Eulers method for simpler equations 2. The simplest way to estimate the exact solution is using Eulers method, when using the method and there is a big difference between y1 and y-1, setting aside the curvature the linear limitedpolation will not match up to it.Higher Order Integration4th Order Runge-KuttaRunge-Kutta is more commonly used in physics 2, this integration method is incredibly accurate from what has been displayed already in part one of this report due to the method have numerous more locomote to solving equations. The accuracy is second to none because RK4 calculates equations estimations in four steps thus given the name 4th Order. In order to compass this accuracy a wrong must be paid and the price is more calculations need to be processed to calculate the physics it has many more computations than other integrator techniques 2. These types of calculations only need to be considered when accuracy is a must in games like bouncing a grenade of a doorframe in call of duty, therefore not all physics in games will require RK4 to calculate physics because physics is different in all games and some will only require Eulers method. So using the example of the Rocket in earths atmosphere a = Fr + Fd / m translates to acceleration = (FORCE rocket + FORCE drag) divided by mass. The rocket force increments by 1kg/m2 every time the user presses the UP key on the keyboard. Fr is calculated as Fd = -0.5.P.Cd.A.v2 so basically force drag = minus 0.5 multiplied by P (airdensity) multiplied by Cd (Drag coefficient) multiplied by A (frontal area of the rocket) multiplied by v (velocity) squared.ConclusionAll in all no numerical integrati on technique is better than the other it all depends what gracious of physics in games needs to be produced, if its simple physics where the estimation does not make a major impact on the way out Eulers method is the way to go for its quick computations it can make having simulations processed rather quickly, as for games where more complicated physics is involved 4th Order Runge-Kutta is the next best thing although it takes many more computations to be calculated the estimates are near perfect, RK4 is second to none when it comes to accuracy because of the extra work that needs to be considered. For example in games like athletic field RK4 is most likely to be used for those physics because the estimations need to be as accurate as can be, this takes into account bullet overlook and flying aircrafts.Appendixa1a2a3a4a5a6a7a8Eulera9Rk4References1https//www.google.co.uk/?gfe_rd=crei=xfluWI62OrLS8AerrruIDAgws_rd=sslq=what+is+a+derivative (Accessed 18 declination 2016).2 Dickinson , J. (2015) quantitative integration in games development. Available at https//jdickinsongames.wordpress.com/2015/01/22/numerical-integration-in-games-development-2/ (Accessed 20 December 2016).3 Bourg, D.M. (2001) Physics for games developers. United States OReilly Media, Inc, USA (Accessed 25 December 2016)..4 Heidt, A.M. (2009) Efficient accommodative step size method for the simulation of Super continuum generation in optical fibres, Journal of Light wave Technology, 27(18), p. 1. doi 10.1109/jlt.2009.2021538 (Accessed 2 January 2017).

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.