fork download
  1. <?php
  2.  
  3. $k = M_PI / 180;
  4. $h = $x = $y = 0;
  5. $d = "";
  6.  
  7. for ($i=5; $i--;){
  8. $h += $a = rand(-179,181);
  9. $x += ($l = rand(0, 501)) * cos($b = $k * $a);
  10. $y += $l * sin($b);
  11. $d .= ($d ? "," : "") . "$a:$l";
  12. }
  13.  
  14. echo "Data: $d\nHeading: $h\nDistance: " . sqrt($x*$x + $y*$y) ."\nOrientation: " . atan2($y, $x)/$k . "\n";
  15.  
  16. ?>
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Data: 138:182,80:165,-11:84,113:475,164:282
Heading: 484
Distance: 919.02834555084
Orientation: 121.54577017447