3v4l.org

run code in 300+ PHP versions simultaneously
<?php function destinationPoint($lat, $lng, $brng, $dist) { $rad = 6371; // earths mean radius $dist = $dist/$rad; // convert dist to angular distance in radians $brng = deg2rad($brng); // conver to radians $lat1 = deg2rad($lat); $lon1 = deg2rad($lng); $lat2 = asin(sin($lat1)*cos($dist) + cos($lat1)*sin($dist)*cos($brng) ); $lon2 = $lon1 + atan2(sin($brng)*sin($dist)*cos($lat1),cos($dist)-sin($lat1)*sin($lat2)); $lon2 = fmod($lon2 + 3*M_PI, 2*M_PI) - M_PI; // normalise to -180..+180ยบ $lat2 = rad2deg($lat2); $lon2 = rad2deg($lon2); echo "lat = ".$lat2."\n"; echo "lon = ".$lon2."\n\n"; } $lat = 0; $lng = 0; $dist = 1; // km $n = 12; $bearings = range(0, 360-(360/$n) , 360/$n); // create array of all bearings needed from $lat/$lng foreach($bearings as $brng){ echo $brng ."\n"; destinationPoint($lat, $lng, $brng, $dist); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 24
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 24
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/4fI7F
function name:  (null)
number of ops:  26
compiled vars:  !0 = $lat, !1 = $lng, !2 = $dist, !3 = $n, !4 = $bearings, !5 = $brng
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   ASSIGN                                                   !0, 0
   22     1        ASSIGN                                                   !1, 0
   23     2        ASSIGN                                                   !2, 1
   24     3        ASSIGN                                                   !3, 12
   26     4        INIT_FCALL                                               'range'
          5        SEND_VAL                                                 0
          6        DIV                                              ~10     360, !3
          7        SUB                                              ~11     360, ~10
          8        SEND_VAL                                                 ~11
          9        DIV                                              ~12     360, !3
         10        SEND_VAL                                                 ~12
         11        DO_ICALL                                         $13     
         12        ASSIGN                                                   !4, $13
   28    13      > FE_RESET_R                                       $15     !4, ->24
         14    > > FE_FETCH_R                                               $15, !5, ->24
   29    15    >   CONCAT                                           ~16     !5, '%0A'
         16        ECHO                                                     ~16
   30    17        INIT_FCALL                                               'destinationpoint'
         18        SEND_VAR                                                 !0
         19        SEND_VAR                                                 !1
         20        SEND_VAR                                                 !5
         21        SEND_VAR                                                 !2
         22        DO_FCALL                                      0          
   28    23      > JMP                                                      ->14
         24    >   FE_FREE                                                  $15
   31    25      > RETURN                                                   1

Function destinationpoint:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4fI7F
function name:  destinationPoint
number of ops:  92
compiled vars:  !0 = $lat, !1 = $lng, !2 = $brng, !3 = $dist, !4 = $rad, !5 = $lat1, !6 = $lon1, !7 = $lat2, !8 = $lon2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
    4     4        ASSIGN                                                   !4, 6371
    5     5        DIV                                              ~10     !3, !4
          6        ASSIGN                                                   !3, ~10
    6     7        INIT_FCALL                                               'deg2rad'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                         $12     
         10        ASSIGN                                                   !2, $12
    7    11        INIT_FCALL                                               'deg2rad'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $14     
         14        ASSIGN                                                   !5, $14
    8    15        INIT_FCALL                                               'deg2rad'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $16     
         18        ASSIGN                                                   !6, $16
   10    19        INIT_FCALL                                               'asin'
         20        INIT_FCALL                                               'sin'
         21        SEND_VAR                                                 !5
         22        DO_ICALL                                         $18     
         23        INIT_FCALL                                               'cos'
         24        SEND_VAR                                                 !3
         25        DO_ICALL                                         $19     
         26        MUL                                              ~20     $18, $19
         27        INIT_FCALL                                               'cos'
         28        SEND_VAR                                                 !5
         29        DO_ICALL                                         $21     
         30        INIT_FCALL                                               'sin'
         31        SEND_VAR                                                 !3
         32        DO_ICALL                                         $22     
         33        MUL                                              ~23     $21, $22
         34        INIT_FCALL                                               'cos'
         35        SEND_VAR                                                 !2
         36        DO_ICALL                                         $24     
         37        MUL                                              ~25     $24, ~23
         38        ADD                                              ~26     ~20, ~25
         39        SEND_VAL                                                 ~26
         40        DO_ICALL                                         $27     
         41        ASSIGN                                                   !7, $27
   11    42        INIT_FCALL                                               'atan2'
         43        INIT_FCALL                                               'sin'
         44        SEND_VAR                                                 !2
         45        DO_ICALL                                         $29     
         46        INIT_FCALL                                               'sin'
         47        SEND_VAR                                                 !3
         48        DO_ICALL                                         $30     
         49        MUL                                              ~31     $29, $30
         50        INIT_FCALL                                               'cos'
         51        SEND_VAR                                                 !5
         52        DO_ICALL                                         $32     
         53        MUL                                              ~33     $32, ~31
         54        SEND_VAL                                                 ~33
         55        INIT_FCALL                                               'cos'
         56        SEND_VAR                                                 !3
         57        DO_ICALL                                         $34     
         58        INIT_FCALL                                               'sin'
         59        SEND_VAR                                                 !5
         60        DO_ICALL                                         $35     
         61        INIT_FCALL                                               'sin'
         62        SEND_VAR                                                 !7
         63        DO_ICALL                                         $36     
         64        MUL                                              ~37     $35, $36
         65        SUB                                              ~38     $34, ~37
         66        SEND_VAL                                                 ~38
         67        DO_ICALL                                         $39     
         68        ADD                                              ~40     !6, $39
         69        ASSIGN                                                   !8, ~40
   12    70        INIT_FCALL                                               'fmod'
         71        ADD                                              ~42     !8, 9.42478
         72        SEND_VAL                                                 ~42
         73        SEND_VAL                                                 6.28319
         74        DO_ICALL                                         $43     
         75        SUB                                              ~44     $43, 3.14159
         76        ASSIGN                                                   !8, ~44
   13    77        INIT_FCALL                                               'rad2deg'
         78        SEND_VAR                                                 !7
         79        DO_ICALL                                         $46     
         80        ASSIGN                                                   !7, $46
   14    81        INIT_FCALL                                               'rad2deg'
         82        SEND_VAR                                                 !8
         83        DO_ICALL                                         $48     
         84        ASSIGN                                                   !8, $48
   17    85        CONCAT                                           ~50     'lat+%3D+', !7
         86        CONCAT                                           ~51     ~50, '%0A'
         87        ECHO                                                     ~51
   18    88        CONCAT                                           ~52     'lon+%3D+', !8
         89        CONCAT                                           ~53     ~52, '%0A%0A'
         90        ECHO                                                     ~53
   19    91      > RETURN                                                   null

End of function destinationpoint

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.76 ms | 1411 KiB | 30 Q