/* 
 * Eyepiece Projection Exposure Calculator by Eric Smestad <esmestad@hickorytech.net>
 * 11/24/2003
 * 
 * to compile:
 * gcc exposurecalculator.c -o exposurecalculator
 * 
 * Uses equations from this site: http://canopus.saao.ac.za/~wpk/exposure.html
 * 
 */

#include <stdio.h>
#include <stdlib.h>

int main (int argc, char *argv[])
{
   float lnTelescopeFL,lnEyepieceFL,lnCameraFL,lnAperture,lnK,lnISO;
   float lnTelescopeMag,lnSystemFL,lnFRatio,lnExposure;
   
   if (argc != 7)
     {
	printf ("Usage: %s TelescopeFL EyepieceFL CameraFL TelescopeAperture K FilmISO\n\n",argv[0]);
	printf ("Values for K\n");
	printf ("Crescent Moon: 20\n");
	printf ("Quarter Moon: 40\n");
	printf ("Full Moon: 200\n");
	printf ("Saturn: 13.6\n");
	printf ("Jupiter: 32.5\n");
	printf ("Mars: 32.5\n");
	printf ("Venus: 1310\n");
	exit(0);
     }
   
   lnTelescopeFL = atoi(argv[1]);
   lnEyepieceFL = atoi(argv[2]);
   lnCameraFL = atoi(argv[3]);
   lnAperture = atoi(argv[4]);
   
   lnK = atof(argv[5]);
   
   lnISO = atoi(argv[6]);
   
   lnTelescopeMag = (lnTelescopeFL / lnEyepieceFL);
   lnSystemFL = (lnTelescopeMag * lnCameraFL);
   lnFRatio = (lnSystemFL / lnAperture);
   lnExposure = (lnFRatio * lnFRatio) / (lnK * lnISO);
   
   printf("System FL: %fmm\n",lnSystemFL);
   printf("F Ratio: %f\n\n",lnFRatio);
   printf("Exposure: %f Sec\n",lnExposure);
   printf("      or: 1/%f Sec\n",(1 / lnExposure));
   
   exit(0);
}

/* Note: Snow is like hail, only it falls gently and doesn't smash windshields */

