[Bf-python] last angleBetweenVectors bug?

Campbell Barton cbarton at metavr.com
Sun Oct 9 07:41:21 CEST 2005


Heres a workaround I use when comparing face normals.
Seems it can return NAN when the normals are either the Same of 
completely opposite.
Contrived comparisons between vectors dont work. Only that Im getting 
the normals from a mesh.
- Cam

            # Now we can compare a selected face to an unselected face.
           
            if selFace.normal == unselFace.normal:
                ang = 0
            else:
                ang = AngleBetweenVecs(selFace.normal, unselFace.normal)
           
            if ang != ang:
                #print selFace.normal, unselFace.normal
                #raise ' ERROR'
                if (selFace.normal - unselFace.normal).length < 0.5: # 
Are we the same or complete opposite.
                    ang = 0
                else:
                    ang = 180



Campbell Barton wrote:
> Theres still a bug that makes AngleBetweenVecs return NAN when both 
> vectors are the same.
> Checking weather V1 == V2, almost always works, but in some situations 
> a slight difference will make the 2 vectors not equel but still return 
> NAN- if you need a testcase I can provide one. but I assume that 
> looking at the code will show how 2 vectors that are the same could 
> return NAN.
>
> - Cam
>
> Frank Schafer wrote:
>> Hi,
>> IMHO you should simply catch this exception, because (again IMHO) it
>> MAKES sense that Mathutils complains to calculate angles between vectors
>> of zero length.
>>
>> Regards
>> Frank
>>
>>
>> On Fri, 2005-10-07 at 09:57 +1000, Campbell Barton wrote:
>>  
>>> Found that AngleBetweenVecs raises an error when checking for a zero 
>>> length Vector
>>>
>>> # Heres my test from the interactive console.
>>> print Mathutils.AngleBetweenVecs(Mathutils.Vector(10.0, 0 , 0), 
>>> Mathutils.Vector(0,1,0))
>>> exceptions.AttributeError:  Mathutils.AngleBetweenVecs(): 
>>> zero-length vectors not acceptable
>>>
>>> - Cam
>>>
>>>     
>> _______________________________________________
>> Bf-python mailing list
>> Bf-python at projects.blender.org
>> http://projects.blender.org/mailman/listinfo/bf-python
>>
>>   
>
>


-- 
Campbell J Barton

133 Hope Street
Geelong West, Victoria 3218 Australia

URL:    http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241



More information about the Bf-python mailing list