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: