#!/usr/bin/perl
# 
# do a simple simulation to test the notion that the phases
#    of a binary star should look different if light speed
#    changes with the speed of the emitting source.
#
# MWR 11/3/2009

$debug = 0;

$c = 1;
$r = 10;
$dist = 10000;
$v = 0.02;
$period = (2*3.14159*$r) / $v;

$absolute_t = 0;

for ($theta = 0; $theta <= 720; $theta += 45) {

  $theta_rad = $theta * (3.14159/180.0);
  $y = $r*sin($theta_rad);
  $total_dist = $y + $dist;

  $v_y = $v*cos($theta_rad);
  $light_v = $c - $v_y;
 
  if ($debug > 0) {
    printf " theta %5.1f  y %6.0f  total %6.0f v_y %6.3f light_v %6.3f \n",
         $theta, $y, $total_dist, $v_y, $light_v;
  }
  
  $time_to_earth_true = $total_dist / $c;
  $time_reaches_earth_true = $absolute_t + $time_to_earth_true - $dist;
  $time_to_earth_false = $total_dist / $light_v;
  $time_reaches_earth_false = $absolute_t + $time_to_earth_false - $dist;

  $letter = "." ;
  if ($theta % 360 == 0) {
    $letter = "A";
  }
  if ($theta % 360 == 90) {
    $letter = "B";
  }
  if ($theta % 360 == 180) {
    $letter = "C";
  }
  if ($theta % 360 == 270) {
    $letter = "D";
  }


  printf " %s theta %6.1f t %12.3f  true %12.3f  false %12.3f  \n", 
         $letter, $theta % 360.0, $absolute_t, 
         $time_reaches_earth_true, $time_reaches_earth_false;

  $absolute_t += $period / 8;
}


exit 0;

