[Bf-python] Incorrect checking for zero length vector
Gilbert, Joseph
jgilbert at tigr.ORG
Fri Oct 7 17:49:38 CEST 2005
Sorry cam about the headaches here with this method. Hope it's fixed
now. I was testing with this script:
import Blender
from Blender.Mathutils import *
v1 = Vector(10.0,0,0)
v2 = Vector(0,0,0)
try:
angle = AngleBetweenVecs(v1,v2)
print angle
except AttributeError, err:
if v1.length == 0:
print v1, ' has a 0 length'
elif v2.length == 0:
print v2, ' has a 0 length'
else:
print err
print v1.length, v2.length
-----Original Message-----
From: bf-python-bounces at projects.blender.org
[mailto:bf-python-bounces at projects.blender.org] On Behalf Of Gilbert,
Joseph
Sent: Friday, October 07, 2005 10:37 AM
To: Blender Foundation Python list
Subject: RE: [Bf-python] Incorrect checking for zero length vector
I tried the following script:
import Blender
from Blender.Mathutils import *
v1 = Vector(10.0,0,0)
v2 = Vector(0,1,0)
try:
angle = AngleBetweenVecs(v1,v2)
print angle
except AttributeError, err:
if v1.length is 0:
print v1, ' has a 0 length'
elif v2.length is 0:
print v2, ' has a 0 length'
else:
print err
print v1.length, v2.length
and got back that this is an error so I'll see if I can track this down.
-----Original Message-----
From: bf-python-bounces at projects.blender.org
[mailto:bf-python-bounces at projects.blender.org] On Behalf Of Gilbert,
Joseph
Sent: Friday, October 07, 2005 10:28 AM
To: cbarton at metavr.com; Blender Foundation Python list
Subject: RE: [Bf-python] Incorrect checking for zero length vector
This is the expected behavior that we talked about earlier. A
zero-length vector is not really a vector at all :) (well sort of) and
it is not possible to calculate the angle between a real vector and what
is essentially nothing - thus raising an error.
Maybe a test could be: (?)
If v1.length is not 0 and v2.length is not 0:
...angle = AngleBetweenVecs(v1,v2)
Else:
...raise AttributeError, 'Something went wrong'
Print angle
-----Original Message-----
From: bf-python-bounces at projects.blender.org
[mailto:bf-python-bounces at projects.blender.org] On Behalf Of Campbell
Barton
Sent: Thursday, October 06, 2005 7:57 PM
To: bf-python at blender.org
Subject: [Bf-python] Incorrect checking for zero length vector
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
--
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
_______________________________________________
Bf-python mailing list
Bf-python at projects.blender.org
http://projects.blender.org/mailman/listinfo/bf-python
_______________________________________________
Bf-python mailing list
Bf-python at projects.blender.org
http://projects.blender.org/mailman/listinfo/bf-python
_______________________________________________
Bf-python mailing list
Bf-python at projects.blender.org
http://projects.blender.org/mailman/listinfo/bf-python
More information about the Bf-python
mailing list