Archived

This topic is now archived and is closed to further replies.

gurhall

Equation of a sphere

Recommended Posts

My idea is to plot the points of a sphere about the origin given it''s radius. I started with the equation for a circle: x^2 + y^2 = radius^2. I then extended it to x^2 + y^2 + z^2 = radius^2 (for three dimensions. My questions is, how can I precalculate all the x,y,z triplets given a radius and an increment? I''m stuck. Gur

Share this post


Link to post
Share on other sites
it doenst really work that way im affraid... if you want to plot a sphere, the best thing to do would be to raytrace it i suppose, but that could be quite a lot of work.. wont a filled circle fit your needs?

Share this post


Link to post
Share on other sites
Well, you could use a voxel system and iterate over x,y, and z, then check if each pixel is within a certain radius of the origin. If it is, you plot a voxel at that location. Perhaps if you explained more of what you are trying to do...

Share this post


Link to post
Share on other sites
I think I''ve found the answer: equations 10, 11 and 12 on this page http://mathworld.wolfram.com/Sphere.html

I''ve tested some code written using these equations and it''s pretty good i reckon, just have to plug it into OpenGL and see what happens.

Share this post


Link to post
Share on other sites
If you want to sample the surface of a sphere semi-randomly without seeing iso-lines, then you should check Halton sampling on a sphere:

http://www.acm.org/jgt/papers/WongLukHeng97

-cb

Share this post


Link to post
Share on other sites