Chappie733:
私が処理することにマンデルブロのセットを視覚化しようとしている、そしてそれは私がこのような何かを初めてです。私のアプローチは非常に単純です。私は文字通りセットの主な機能である(関数Zを有するf(z)=z^2+c
)iは、画面の各画素毎にループを行い、毎回iはZ()を使用して内の新しいZパラメータとして結果を使用するプロセスを繰り返します画面上に表示するもの何らかの理由で関数Zは、()のみの対角線である、と私はそれがある理由のない考えを持っていません。
ここでは、完全なコードは次のとおりです。
void draw() {
int max_iterations = 100, infinity_treshold = 16;
for (int y = 0; y < 360; y++) {
for (int x = 0; x < 480; x++) {
float z = 0; // the result of the function, (y)
float real = map(x,0,480,-2,2); // map "scales" the coordinate as if the pixel 0 was -2 and the pixel 480 was 2
float imaginary = map(y,0,360,-2,2); // same thing with the height
int func_iterations = 0; // how many times the process of the equation has been excecuted
while (func_iterations < max_iterations) {
z = Z(z, real+imaginary);
if (abs(z) > infinity_treshold) break;
func_iterations++;
}
if (func_iterations == max_iterations) rect(x,y,1,1);
}
}
noLoop();
}
private float Z(float z, float c) {
return pow(z,2)+c;
}
ジョニ:
あなたはそれが実数ですので、それは複雑であるべきfloatとしてのzを宣言しました。私は、処理に慣れていないよ、それも複素数データ型を持っているのですか?
もう一つの問題はであるZ(z, real+imaginary)
実部と虚その合計は実数であるので、山車、その実数の両方です。あなたは、実部と虚部から複素数を構築する必要があります。