Jump to content
  • Advertisement

Archived

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

gurhall

Equation of a sphere

This topic is 5553 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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?

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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!