Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Computes the wavelength of incident light. Formulas used are:
- * Arctangent - atan(c / a) - thanks Cyparagon
- * Diffraction grid formula - nλ = d sin(ϴ)
- * Pythagorean theorem - a² + b² = c²
- * The Lightning Stalker 2013
- */
- #include <math.h>
- #include <stdio.h>
- #include <stdlib.h>
- int main (int argc, char **argv)
- {
- float a, c, d, wl;
- if (argc == 4)
- {
- a = atof(argv[1]);
- c = atof(argv[2]);
- d = atof(argv[3]);
- wl = d * sin(atan(c / a));
- printf("Wavelength is %1.1fnm\n", wl);
- }
- else
- {
- puts("gridcalc is a diffraction grid wavelength calculator.\n");
- puts("Usage: gridcalc a c d");
- puts("a = Distance from grid to target in mm");
- puts("c = Distance from center to first order spectrum line of interest in mm");
- puts("d = Distance between diffraction grid elements in nm");
- puts("Example: gridcalc 100 88 1000");
- puts("Output should be 660.6nm");
- return(1);
- }
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement