English 中文(简体)
Julia Set in Javascript
原标题:Julia Set In Javascript

我与一些曼德勒布罗人环绕的迷惑不解,因为我认为,它产生的景象相对应。 我认为,我可能会试图解决把一个人打上 j印,看我可以做些什么的问题。 我研究的是两种算法,即:

rel=“nofollow” http://library.thinkquest.org/26242/full/progs/a2.html

我将:

drawGraph: function(canvas,resolution,iterations,colors,coefficent){

                var context = canvas.getContext( 2d );

                for(var m = 0; m < resolution.x; m++){
                    for(var n = 0; n < resolution.y; n++){
                        var x = m, 
                            x2 = x*x,
                            y = n, 
                            y2 = y*y;

                        var i;
                        for(i = 1; i < iterations; i++){
                            if(x2 + y2 > 4) break;

                            var new_x = x2 - y2 + coefficent.a;
                            var new_y = 2*x*y + coefficent.b;

                            x = new_x;
                            y = new_y;
                        }

                        var color = i % colors;

                        DrawUtils.drawPoint(context,m,n,color); 
                    }
                }
            }

基本上用一个色体。

Then I tried this one:

我将:

drawGraph: function(canvas,resolution,iterations,colors,coefficent){

                var context = canvas.getContext( 2d );

                for(var m = 0; m < resolution.x; m++){
                    for(var n = 0; n < resolution.y; n++){
                        var x = 0,
                            y = 0,
                            x0 = ((m/resolution.x) * 3.5) - 2.5,
                            y0 = ((n/resolution.y) * 2) - 1;

                        var i = 0;
                        while(x*x + y*y < 4 && i < iterations){
                            var x_temp = x*x - y*y + x0;
                            y = 2*x*y + y0;
                            x  = x_temp;
                            i++;
                        }

                        var color = 0;
                        if(x*x + y*y >= 4){
                            color = i % colors;
                        }

                        DrawUtils.drawPoint(context,m,n,color);
                    }
                }
            }

产生黑箱。 算法中混为一谈的我的措辞虽然说X0 和0 按比例计算是六分之一的因素,但在算法之后却说,系数c = x0 + iy0;因此,这并不意味着我不会将预先确定的系数移入功能?

在大多数这些测试中,我使用了0.25+0i系数,但我尝试了产生相同结果的其他方法。

我在这里做了什么错误?

最佳回答

第一点:你需要清楚地了解Julia各套和Mandelbrot之间的区别。 两者都从不同角度深入了解<代码>f(z) = z^2 + c的特性。

<>>Julia <>/strong>。

关于<<>Mandelbrot的一组,我们做了一个图表,说明相同的初始<代码>z = 0为不同的<代码>c。

With that addressed...


您的第一部法典(试图为<条码>c设计的Julia, 载于<条码>、条码)的译本,您在您的第一页链接上从《经济、社会、文化权利国际公约》的译文并不正确。 如果有

‘ run through every point on the screen, setting 
‘ m and n to the coordinates
FOR m = x_minimum TO x_maximum STEP x_resolution
             FOR n = y_minimum TO y_maximum STEP y_resolution
                          ‘ the initial z value is the current pixel,  
                          ‘ so x and y have to be set to m and n
                          x = m: y = n

页: 1

        for(var m = 0; m < resolution.x; m++){
            for(var n = 0; n < resolution.y; n++){

which is close, except for the crucial point that you are not taking any steps to implement STEP x_resolution. Your m is an integer that runs from 0 to resolution.x - 1 in steps of 1; and your x is set to m.

因此,你不从<条码>-2i到<条码>2+2i(见Julia套的体面观察室),而是从<条码>0到<条码>,到<条码>,x + Resolution.y i,其中将包含在低轴左上方的几页。


第二部法典(试图起草曼德尔布罗套)does 我可以立即看到什么是错的——我会辩论并看到:<代码>m/ Resolution.x总是0,因为@user973572建议这个问题。

问题回答

在你的第一个例子中,我认为你不愿更新x2和 y2,因此,它们总是具有同样的价值。 如果金额超过4美元,在检查之前需要更新x2和 y2。 类似于

for(i = 1; i < iterations; i++){
    x2 = x*x,
    y2 = y*y
    if(x2 + y2 > 4) break;

which is probably wrong because I know nothing about javascript.





相关问题
How to add/merge several Big O s into one

If I have an algorithm which is comprised of (let s say) three sub-algorithms, all with different O() characteristics, e.g.: algorithm A: O(n) algorithm B: O(log(n)) algorithm C: O(n log(n)) How do ...

Grokking Timsort

There s a (relatively) new sort on the block called Timsort. It s been used as Python s list.sort, and is now going to be the new Array.sort in Java 7. There s some documentation and a tiny Wikipedia ...

Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Enumerating All Minimal Directed Cycles Of A Directed Graph

I have a directed graph and my problem is to enumerate all the minimal (cycles that cannot be constructed as the union of other cycles) directed cycles of this graph. This is different from what the ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...