저는 정말로 이것에 관한 아이디어가 고착되어 있습니다. 나는 원을 그려야하는데 괜찮습니다. 하지만 다른 해상도로 칠할 수있게 될 것입니다. 나는 아무데도 가지 않을 것입니다. 제발 도와주세요! 여기에 나와있는 코드는 differnet 해상도로 작업하려고하지는 않지만 수행 할 작업에 대한 아이디어가 없습니다.낮은 해상도의 원을 그립니다.
나는 문제가있는 수업을 올릴 것이고, 나는 나머지 프로그램을 시작할 것이다. 또한이 프로그램은 나중에 Mandlebrot 세트에 사용됩니다.
문제는 동그라미가 고해상도로 잘 작동하지만 한 번 줄이려고하면 이상한 선 패턴이 표시되는 것처럼 특정 선을 그립니다. 그런 다음 선을 그려야한다고 생각하지 않습니다. 문제가 의심되는 것은 render()
입니다. 또한 문제가 더 구체적으로 for-loops 또는 내 벡터의 인덱스라고 의심합니다. 제 설명이 명확하지 않으면 알려주세요. RESOLUTION_VERY_LOW하는
RESOLUTION_VERY_HIGH 난 당신이 그들을 필요로 의심하지만, 여기에 다른 클래스는 128
package mandelbrot;
import java.awt.Color;
import se.lth.cs.ptdc.fractal.MandelbrotGUI;
public class Generator {
public Generator() {
}
public void render(MandelbrotGUI w) {
w.disableInput();
int resolution = 1;
switch (w.getResolution()) {
case MandelbrotGUI.RESOLUTION_VERY_HIGH:
resolution = 1;
break;
case MandelbrotGUI.RESOLUTION_HIGH:
resolution = 3;
break;
case MandelbrotGUI.RESOLUTION_MEDIUM:
resolution = 5;
break;
case MandelbrotGUI.RESOLUTION_LOW:
resolution = 7;
break;
case MandelbrotGUI.RESOLUTION_VERY_LOW:
resolution = 9;
break;
}
Complex complex[][] = mesh(w.getMinimumReal(), w.getMaximumReal(), w.getMinimumImag(),
w.getMaximumImag(), w.getWidth(), w.getHeight());
Color[][] picture = new Color[w.getHeight()][w.getWidth()];
for (int i = 0; i<w.getHeight(); i+=resolution) {
for (int j = 0; j<w.getWidth(); j+=resolution) {
if ((complex[i][j]).getAbs()>1) {
picture[i][j] = Color.WHITE;
}
else {
picture[i][j] = Color.BLUE;
}
}
}
w.putData(picture, 1, 1);
w.enableInput();
}
private Complex[][] mesh(double minReal, double maxReal, double minImaginary,
double maxImaginary, int width, int height) {
Complex[][] matrice = new Complex[height][width];
for (int i = 0; i<height; i++) {
for (int j = 0; j<width; j++) {
matrice[i][j] = new Complex((minReal + ((maxReal-minReal)/width)*j),
((maxImaginary - (((maxImaginary - minImaginary)/height)*i))));
}
}
return matrice;
}
}
, 값 2048, 1024, ...이;
내 주요;
package mandelbrot;
import se.lth.cs.ptdc.fractal.MandelbrotGUI;
public class Mandelbrot {
public static void main (String[] args) {
MandelbrotGUI w = new MandelbrotGUI();
Generator generator = new Generator();
boolean zoomValue = false;
while (true) {
switch(w.getCommand()) {
case MandelbrotGUI.QUIT: System.exit(0);
break;
case MandelbrotGUI.RENDER:
generator.render(w);
break;
case MandelbrotGUI.RESET:
w.clearPlane();
w.resetPlane();
zoomValue = false;
break;
case MandelbrotGUI.ZOOM:
if (zoomValue) {
w.clearPlane();
generator.render(w);
break;
}
else {break;}
}
}
}
}
여기에 내가 작성한 복잡한 클래스가 있습니다.
package mandelbrot;
public class Complex {
double real;
double imaginary;
public Complex (double real, double imaginary) {
this.real = real;
this.imaginary = imaginary;
}
double getReal() {
return real;
}
double getImaginary() {
return imaginary;
}
double getAbs() {
return Math.hypot(real, imaginary);
}
void add(Complex c) {
real += c.getReal();
imaginary += c.getImaginary();
}
void multiply(Complex c) {
real = (real*c.getReal()) - (imaginary*c.getImaginary());
imaginary = (real*c.getImaginary()) + (imaginary*c.getReal());
}
}
여기서 찾을 수있는 GUI의 사양. http://fileadmin.cs.lth.se/cs//Education/EDA016/javadoc/cs_eda016_doc/
도움을 주셔서 감사합니다. 대단히 감사합니다. :)
GUI 클래스의 소스에 대한 링크가없는 것입니까? 꼭 필요한 것은 아니지만 디버깅이 더 쉬워진다. 정확히 말하면 무엇을 말하는지, 스펙에서 재현 할 수있는 동안은 많은 타이핑이 필요하다. :) –
서클과 만델 브로 도형에는 공통점이 있습니까? 원을 그려야 할 경우 사인 함수와 코사인 함수를 사용하여 _true_ 원을 만듭니다. – karatedog