I want to calculate a sphere (and render it with my JavaScript programme. (The render works successfully))
I found this question: Plotting a point on the edge of a sphere and afterwards I has developed this code:
for(var s = 0; s < 6; s++){
for(var t = 0; t <= 3; t++){
var x = d * Math.cos(s) * Math.sin(t);
var y = d * Math.sin(s) * Math.sin(t);
var z = d * Math.cos(t);
console.log("("+x+","+y+","+z+")");
}
}
It looks like:
It is doesn't look like a sphere!
So I changed the s++ to s+=0.1 and the t++ to t+=0.1.
Now it looks like:
Now it looks better, BUT my BIG PROBLEM: in the middle the lines should intersect on the Z axis. I think you can see the problem better on the first image.
Thanks for your answers!
EDIT: SOLUTION: unedited answer from @MBo:
for(var ss = 0; ss < 24; ss++){
for(var tt = 0; tt <= 12; tt++){
s = Math.Pi * ss / 12;
t = Math.Pi * tt / 12;
...x y z stuff