[solved]How come this doesn't make a sphere? O.o

Discussion in 'Plugin Development' started by pyraetos, Oct 22, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    pyraetos

    [​IMG]Sphere generation was harder than I thought, this seems like it should have worked for me. Where 'set' is a collection of blocks which represent a cube in which the sphere should fit.
    xx, yy, and zz are the coordinates of the center of the sphere.
    Code:
    for(int counter = 0; counter <= set.size() - 1; counter++){
                int a = (set.get(counter).getX() - xx)^2;
                int b = (set.get(counter).getY() - yy)^2;
                int c = (set.get(counter).getZ() - zz)^2;
                if(a +b +c == (radius^2)) set.get(counter).setType(Material.COBBLESTONE);
            }
    What it gives looks like that at the top at radius 10.
     
  2. Offline

    nisovin

    In Java the ^ symbol is a bitwise OR, not an exponent.
     
  3. Offline

    pyraetos

    :O are you serious???
    Extreme Facepalm
    [​IMG]
     
  4. Offline

    mindless728

    this

    although at the same time, i like the structure that code did generate
     
  5. Offline

    Afforess

    It's math.pow()
     
  6. Offline

    pyraetos

    mindless728 yeah it was deep... mysterious.. symmetrical....
     
Thread Status:
Not open for further replies.

Share This Page