[Bf-python] BPython bug AngleBetweenVecs

Gilbert, Joseph jgilbert at tigr.org
Wed Mar 30 19:39:11 CEST 2005


//Just now I found the problem. when AngleBetweenVecs compares 2 vectors

//that are the same, it can return  nan, nan being a float type. nothing
is //equal to nan except float('nan'). Shold be changed to return 0
instead of //nan?

I fixed this and the fix will be applied. I think in part
angleBetweenVecs was choking on a few things. First is the arc-cosine
function it was using (you may not be using the lastest cvs) and also
the float precision of the angle it was returning.

//Also discovered AngleBetweenVecs() can return NAN for very large
numbers. //Another very bad thing us that AngleBetweenVecs() modifies
the 2 vectors 
//(normalizes them I think) when it should realy be normalizing a copy
of 
//the data

VERY GOOD CATCH
The normalization should not be applied directly to the vector. FIXED
The very large number issue is resolved to a degree with full double
precision now.

//Incidentally, this is (IMHO) where we need some regression tests.  I
don't //think that a general math function like AngleBetweenVecs (with
no GUI //dependencies, etc) should be committed without a decent set of
regression //tests that run on it and test for odd cases like finding
the angle between //a vector and itself.  Functions like this should be
absolutely rock-solid, //watertight, bulletproof, leak-proof, cast iron
pieces of... well you get //the idea. :-)

If you're volunteering your services for beta testing let us know.





More information about the Bf-python mailing list