#!/usr/bin/perl
#
# Calculate the apparent transverse speed of a blob of material
#   in a jet moving at high speed nearly towards the observer.
#   MWR 12/15/2004
#
# Modified to print out the table students are asked to fill in.
#   MWR 10/24/2017
use POSIX;

# multiply by this to convert degrees to radians
$DEGTORAD = (3.14159/180.0);

$debug = 1;


# speed of blob, as fraction of speed of light
@v_array = (0.10, 0.50, 0.90);
# angles of motion relative to observer's line of sight (degrees)
@theta_array = (5, 10, 15, 20);

printf "#%10s %10s %10s %10s %10s %10s %10s \n", 
    "v", "theta", "theta_rad", "vsin", "1-vcos", "speed", "gamma";

foreach $v (@v_array) {

  foreach $theta (@theta_array) {

     $theta_rad = $theta*$DEGTORAD;

		  # gamma factor
		  $gamma = 1.0/sqrt(1.0 - $v*$v);




			 $x = $v*sin($theta_rad);
			 $dt = (1.0 - $v*cos($theta_rad));
			 $speed = $x/$dt;
    			printf "%10.3f %10.1f %10.3f  %10.3f %10.3f %10.3f  %10.3f\n",
							$v, $theta, $theta_rad, $x, $dt, $speed, $gamma;

#			 printf " %7.3f  %7.1f  %8.4f  %7.3f\n", $v, $theta, $speed, $gamma;
		  }

}


exit 0;
