optimizations etc

This commit is contained in:
nora 2020-11-17 20:04:02 +01:00
parent 64dc682257
commit 36384cd7bc
7 changed files with 9 additions and 31 deletions

View file

@ -29,7 +29,6 @@ public class CalculationThread extends Thread {
long startTime = System.currentTimeMillis();
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
File f = null;
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
@ -109,14 +108,18 @@ public class CalculationThread extends Thread {
}
}
/**
* Checks wheter the number is in the Mandelbrot set
* @param number The Complex Number to be checked
* @param iterations The amount of iterations the program should do
* @param threshold The threshold for a number not being in the set
* @return -1 if the number is in the set, else it returns the amount of interations before it reached the threshold
*/
int checkMandelbrot(CNumber number, int iterations, double threshold) {
//returns -1 if the number is in the set, returns the number of iterations before it reached the threshold if it is not in the set
// start
CNumber n = new CNumber();
int reached = -1;
// first
n = CNumber.add(n, number);
for (int i = 0; i < iterations; i++) {
@ -131,7 +134,6 @@ public class CalculationThread extends Thread {
}
public int getColorAsInt(int a, int r, int g, int b) {
return (a << 24) | (r << 16) | (g << 8) | b;
}

View file

@ -20,7 +20,7 @@ public class MandelbrotSet {
private double pointY = 0;
private double zoom = 1;
private int width = 1920;
private int threshold = 100;
private int threshold = 1000;
private float ratio = 2 / 3f;
private int threadAmount = 10;

View file

@ -24,7 +24,7 @@ public class Controller {
}
public void startCalculation(ActionEvent actionEvent) {
MandelbrotSet m = new MandelbrotSet(2, 1, 3, 1);
MandelbrotSet m = new MandelbrotSet(2, 3, 3, 10);
m.startMandelbrot();
}
}