.:: Projectile Simulation ::.
Projectile Simulation
This program simulates projectiles and includes wind resistance.
SOFTWARE WRITTEN IN PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | <?PHP $dt = 0.0001; $angle = (double)$_GET['angle']; $y = (double)$_GET['height']; $inity = $y; $v = (double)$_GET['velocity']; $d = (double)$_GET['diameter']; $m = (double)$_GET['mass']; $dist = (double)$_GET['distance']; $t = 0.0; $vx = cos((3.14159/180)*$angle) * $v; $vy = sin((3.14159/180)*$angle) * $v; $xdrag = 0.0; $ydrag = 0.0; $drag = 0.0; $speed = 0.0; $max_height = 0; while(($x < $dist) && ($y > 0)) { $t += $dt; $speed = sqrt(pow($vx,2) + pow($vy,2)); $drag = (0.5 * 1.29 * pow($speed,2) * 0.295 * (3.14159 * pow($d / 2,2))) / $m; $xdrag = -($vx / $speed) * $drag; $ydrag = -($vy / $speed) * $drag; $ax = $xdrag; $ay = -9.8 + $ydrag; $vx += ($ax * $dt); $vy += ($ay * $dt); $x += ($vx * $dt); $y += ($vy * $dt); if($y > $max_height) { $max_height = $y; } } echo '<html><head><title>PROJECTILE SIMULATION</title></head><body bgcolor="#000000">'; echo '<font face="courier new" size="6" color="#FF0000">'; echo '<b>PROJECTILE SIMULATION</b><br></font>'; echo '<font face="courier new" size="4" color="#FF0000"><b>BY ROSTISLAV PERSION</b></font>'; echo '<br><br>'; echo '</font>'; echo '<font face="courier new" size="4" color="#0000FF">'; echo '<b>INITIAL HEIGHT -----------></b> ' . number_format($inity,5 , '.', ',') . ' m<br>'; echo '<b>ANGLE --------------------></b> ' . number_format($angle,5 , '.', ',') . ' degrees<br>'; echo '<b>MUZZLE VELOCITY ----------></b> ' . number_format($v,5 , '.', ',') . ' m/sec<br>'; echo '<b>PROJECTILE DIAMETER ------></b> ' . number_format($d,5 , '.', ',') . ' m<br>'; echo '<b>PROJECTILE MASS ----------></b> ' . number_format($m,5 , '.', ',') . ' kg<br>'; echo '<b>TARGET DISTANCE ----------></b> ' . number_format($dist,5 , '.', ',') . ' m<br>'; echo '</font><br>'; echo '<font face="courier new" size="4" color="#00FF00">'; echo '<b>TIME ---------------------> </b> ' . number_format($t,5 , '.', ',') . ' sec<br>'; echo '<b>MAX HEIGHT ---------------> </b> ' . number_format($max_height,5 , '.', ',') . ' m<br>'; if ($y <= 0) { echo '<b>WARNING ------------------></b> BULLET HIT THE GROUND AT ' . number_format($x,5, '.', ',') . ' m <br>'; } echo '<b>FINAL HEIGHT -------------></b> ' . number_format($y,5 , '.', ',') . ' m<br>'; echo '<b>FINAL X VELOCITY ---------></b> ' . number_format($vx,5 , '.', ',') . ' m/sec<br>'; echo '<b>FINAL Y VELOCITY ---------></b> ' . number_format($vy,5 , '.', ',') . ' m/sec<br>'; echo '<b>FINAL VELOCITY -----------></b> ' . number_format(sqrt(pow($vx,2) + pow($vy,2)),5 , '.', ',') . ' m/sec<br>'; echo '<b>FINAL X DRAG -------------></b> ' . number_format($xdrag * $m,5 , '.', ',') . ' N<br>'; echo '<b>FINAL Y DRAG -------------></b> ' . number_format($ydrag * $m,5 , '.', ',') . ' N<br>'; echo '<b>FINAL DRAG ---------------></b> ' . number_format($drag * $m,5 , '.', ',') . ' N<br>'; echo '</font>'; echo '</body></html>'; ?> |