Created
October 2, 2018 02:21
-
-
Save npyoung/5f401a04634182e1f4736a8cf81ad810 to your computer and use it in GitHub Desktop.
Rough dual lens design
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse as ap | |
if __name__ == "__main__": | |
parser = ap.ArgumentParser() | |
parser.add_argument('f', type=float, help="Overall focal length") | |
parser.add_argument('library', type=int, nargs='+', help="Focal length of available lenses") | |
args = parser.parse_args() | |
f = args.f | |
fs = args.library | |
design_tbl = [] | |
for f1 in fs: | |
for f2 in fs: | |
if f1 <= f2: | |
d = (1/f1 + 1/f2 - 1/f) * f1 * f2 | |
design_tbl.append({'d':d, 'f1':f1, 'f2':f2}) | |
design_tbl = [x for x in design_tbl if x['d'] <= 0] | |
design_tbl = sorted(design_tbl, key=lambda x: x['d']) | |
for entry in design_tbl: | |
print("{f1:d}, {f2:d} --> {d:0.3f}mm") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment