Is com.xith3d.spatial.bounds.Sphere broken ?

What does radius2 exactly means ? In most setters it is set to squared distance from 0,0,0 point. In compute method, local variable named radius2 is used to represent radius squared. In classify(Sphere) method it is passed in place where radius should be used, not squared distance from origin… And classify(x,y,z,rad2) method is broken - square root should be taken from d before using it for checks.

I’m not touching this class at the moment - first I need to know what you really want for radius2 to represent and if any of other code relies on current specific behaviour.

Looks like you are right - we have to make some more tests to 100% ensure and then fix!

Yuri

Please check out following patch

http://nwn-j3d.sourceforge.net/xith3d/spherebug.diff

and junit test

http://nwn-j3d.sourceforge.net/xith3d/SphereTest.java

I had no time today to finish unit test for all methods, but I hope that most things should be correct - except compute method, which is a bit over my head at the moment.

Has anyone moved this into the repository? I hate this bug and want the fix :slight_smile:

Oh… great catch and fix!

Not yet,

I will do this ASAP.

Yuri

Fix for Issue #28 committed to CVS. Thanks Artur Biesiadowski.

Yuri