We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So I want to plot a number of points (i.e. small spheres) on the surface of a large sphere. The formulae seems straightforward enough, though weirdly there're lot of different variations. Anyway, no matter what varient I use every time the spheres end up plotted along a 3d line, rather than forming a sphere and I can't figure out why that is. Hopefully some one can help me along. Here's the relevant section of code
for (float i = 0; i <= 100; i++) {
Theta = (TAU/100)*i;
Phi = (PI/100)*i;
XYZ.x = gear0.RX*cos(Theta)*sin(Phi);
XYZ.y = gear0.RY*sin(Theta)*sin(Phi);
XYZ.z = gear0.RZ*sin(Phi);
pushMatrix();
translate(XYZ.x, XYZ.y, XYZ.z);
sphere(10);
popMatrix();}
Answers
You are using I for both Theta and phi. You need a second loop around the current one and use that for phi.
Entire code?
I guess tau is 0 or gear?
It's all radians.
Woo thanks so much Chrisir, totally works now!! :-bd And yeah thanks for the suggestion Koog, indeed had to include a second loop.
that's one too many...
i2 < 100
the other loop is ok though, you want it to be inclusive
Interesting example! Here is an interactive version to inspect that style of point sphere at different resolutions.
Click and drag with the mouse to change the x / y sphere counts:
Thanks everybody! I adjusted the code a little bit, back to using PI for the second loop. . made more sense to me.
And added another gear, making spirograph in 3d.
That's amazing, absolutely beautiful!
Mind to share your code?
Chrisir
Thanks! As for code, it's part a larger project, basically a rudimentary animator for 2d spirograph which is already working and now I'm trying to squeeze the 3d part into existing structure and UI. . All this to say it's a bit messy at the moment. :D
this is still doing one too many loops. use T < Spheres.
at the start it'll be 0, it'll end at Spheres (i'd look at java naming conventions btw)
Theta = (TAU / Spheres) * T;
when T = 0 => Theta = 0
when T = Spheres => Theta = TAU
cos(0) is the same as cos(TAU), ditto sin().
the last spheres are the same as the first so you don't see them...
Oh right, thanks! Still getting used to 0 = 1, if that makes sense. Banged my head many a time getting 'out of bounds' errors because of that. . Anyhow, adjusted it and will look into naming conventions as well.
that looks neat as a screen saver :
Would be totally neat! And from the inside can get pretty interesting shapes as well, just add more gears to it. ;)
did you try my sketch? Looks awesome...
I just dive into this...
@vrtxt : you wrote
so without adding another gear, does this look correct to you?
!!!
Thanks!
@vrtxt: in the small 3D video though which parameters did you change there in which way....?
yes I ran your sketch @Chrisir, hence my remarks to explore the inside as well. :) In the video I changed the x,y,z dimensions respectively of gear0 which I made available in the GUI, albeit very quick n dirty.
Also, I used PI rather than TWO_PI (which is just TAU) because according to this here it only needs PI, which kinda makes sense. I'm guessing by using TWO_PI every dot is plotted twice, and also not sure why you're mapping it.
thanks!