Created
May 23, 2015 21:12
-
-
Save agnes1/fe8ea7d184f848621865 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package com.clarke.agnes.experiments; | |
import java.util.ArrayList; | |
import java.util.List; | |
/** | |
* Calculates the vignetting caused by the size of the Newt secondary and the f ratio. | |
* Units are mm. | |
* Created by Ags on 5/12/2015. | |
*/ | |
public class NewtonianVignetting { | |
public static void main(String[] args) { | |
double aperture = 250.0; | |
double fRatio = 5.2; | |
double[] secondaries = {46.0, 50.0, 63.0, 70.0}; | |
double focusser = 45.0; | |
double tubeGap = 30.0; | |
List<List<String>> columns = new ArrayList<>(); | |
ArrayList<String> fieldStop = new ArrayList<>(); | |
columns.add(fieldStop); | |
fieldStop.add("Field Stop"); | |
for (int i = 0; i < 100; i++) { | |
fieldStop.add(""+i); | |
} | |
for (double secondary : secondaries) { | |
ArrayList<String> col = new ArrayList<>(); | |
col.add(""+secondary); | |
columns.add(col); | |
double mirrorRadius = aperture / 2.0; | |
double secondaryRadius = secondary / 2.0; | |
double d = mirrorRadius + tubeGap + focusser; | |
double focalLength = aperture * fRatio; | |
double coneWidth = d / fRatio; | |
double fiftyMmField = 50.0 * (focalLength - d) / focalLength; | |
double secondaryDist2 = secondaryRadius * secondaryRadius; | |
double coneDist2 = coneWidth * coneWidth / 4.0; | |
System.out.println("d = " + d); | |
System.out.println("aperture = " + aperture); | |
System.out.println("secondary = " + secondary); | |
System.out.println("coneWidth = " + coneWidth); | |
System.out.println("fRatio = " + fRatio); | |
System.out.println("focalLength = " + focalLength); | |
System.out.println("fiftyMmField = " + fiftyMmField); | |
boolean first = true; | |
double centerVal = 0.0; | |
for (double ii = 0.0; ii <= 50.0; ii += 0.5) { | |
double i = ii / 50.0 * fiftyMmField; | |
double count = 0.0; | |
for (double x = -mirrorRadius; x < mirrorRadius; x += 0.1) { | |
for (double y = -mirrorRadius; y < mirrorRadius; y += 0.1) { | |
double distFromSecondaryCenter = (x * x) + (y * y); | |
double distFromConeCenter = ((x + i) * (x + i)) + (y * y); | |
boolean onSecondary = (distFromSecondaryCenter <= secondaryDist2); | |
boolean inCone = (distFromConeCenter <= coneDist2); | |
if (onSecondary && inCone) { | |
count++; | |
} | |
} | |
} | |
if (first) { | |
first = false; | |
centerVal = count; | |
} | |
double v = count / centerVal; | |
System.out.printf("%.2f: %.2f: %.2f\r\n", ii, i, v); | |
col.add(""+v); | |
} | |
} | |
System.out.println(); | |
System.out.println("---------------------------------------"); | |
System.out.println(); | |
for (int i = 0; i < 100; i++) { | |
for (List<String> column : columns) { | |
System.out.print(column.get(i) + ','); | |
} | |
System.out.println(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment