4
$\begingroup$

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

$\endgroup$
  • 1
    $\begingroup$ 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. $\endgroup$ – Listing Dec 6 '11 at 9:59
  • 1
    $\begingroup$ Ok, thats a alternative. But it results in a solution O(n³), which I am trying to avoid... $\endgroup$ – Pedro Dusso Dec 6 '11 at 10:17
  • 1
    $\begingroup$ Have you seen this? $\endgroup$ – J. M. is a poor mathematician Dec 6 '11 at 10:30
  • 1
    $\begingroup$ Obviously, there are no solutions if $r^2$ is not an integer. Are you assuming that $r$ is an integer? $\endgroup$ – Gerry Myerson Dec 6 '11 at 11:54
  • 8
    $\begingroup$ See projecteuler.net/problem=360 $\endgroup$ – Will Jagy Dec 8 '11 at 19:48
1
$\begingroup$

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$.

$\endgroup$
  • 1
    $\begingroup$ The question's about spheres, not circles. $\endgroup$ – J. M. is a poor mathematician Dec 8 '11 at 18:11
  • $\begingroup$ 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)$. $\endgroup$ – marty cohen Apr 7 '12 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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