# Using circles to create a sphere

I've been working on creating spheres in a 3D space recently, and have successfully created cylinders. I've just run into a little problem. For some reason, my "Spheres" end up looking like very thick star shapes. I can't seem to figure out what's wrong, and I could not really find any algorithms to reference off of. My code:

``````public static void createCircle(int xoff, int yoff, int zoff, int FOV, ArrayList<Point3D> Points, int radius) {
for(int j=0;j<Math.PI*2;j++) {
int x = (int) (radius * Math.cos(j));
int y = (int) (radius * Math.sin(j));
Points.add(new Point3D(x+xoff, y+yoff, zoff, FOV, 900, 600));
}
}
public static void createSphere(int radius, int height, int FOV, ArrayList<Point3D> Points, int posx, int posy, int posz) {
for(int z=0;z<height;z++) {
createCircle(posx, posy, posz+z, FOV, Points, (int) (radius*(Math.sin(z)*2)));
}
}
``````

Here's what it ends up looking like:

-
It would be helpful if you could post an image of what they currently look like. Additionally, there's a similar question here which may help you. And my answer there has code very similar to yours here that you can reference. – Byte56 Jan 16 '13 at 17:54

Your radius calculation is completely wrong, in `createSphere` you should do something like:
``````for(float angle=0;angle<Math.PI;angle+=0.1){