Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have a graphic application to develop which involve many spheres. I should determine then on run time.

Supposing that I have a sphere of radius r, how can I determine the sub set of the sphere surface points that are integer?

E.g., $r = 10$ I can have $(10,0,0), (8,6,0),$ etc.

(Obs.: I really think this is not a programming question, that's why I not posted In stack overflow. If I am wrong, please fell free to warn me that :)

Pedro

share|improve this question
1  
You could just check the integer "grid" the sphere is in by using the formula of the sphere to see which points are on the surface of the sphere. –  Listing Dec 6 '11 at 9:59
    
Ok, thats a alternative. But it results in a solution O(n³), which I am trying to avoid... –  Pedro Dusso Dec 6 '11 at 10:17
1  
Have you seen this? –  J. M. Dec 6 '11 at 10:30
1  
Obviously, there are no solutions if $r^2$ is not an integer. Are you assuming that $r$ is an integer? –  Gerry Myerson Dec 6 '11 at 11:54
7  
See projecteuler.net/problem=360 –  Will Jagy Dec 8 '11 at 19:48

1 Answer 1

You could use Euclid's formula: For $m > n, a = m^2 - n^2, b = 2mn, c = m^2 + n^2$ are solutions to $a^2 + b^2 = c^2$.

share|improve this answer
    
The question's about spheres, not circles. –  J. M. Dec 8 '11 at 18:11
    
And then there is the Gauss-Legendre theorem that an integer is the sum of three integer squares if and only if it is not of the form $4^m(8n+7)$. –  marty cohen Apr 7 '12 at 4:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.