Equation of a sphere

Started by
3 comments, last by gurhall 20 years, 11 months ago
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
Advertisement
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?
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...
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.
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

This topic is closed to new replies.

Advertisement