[Tutor] AttributeError: Vector instance has no attribute 'Normalize'
bob gailer
bgailer at gmail.com
Fri Nov 27 20:41:05 CET 2009
Garrett Hartshaw wrote:
> The program I am writing gives the following error message when run.
>
> Traceback (most recent call last):
> File "./space.py", line 177, in <module>
> main()
> File "./space.py", line 173, in main
> player = Ship("space/models/fighter.3ds",
> "space/models/realistic.bmp", Quaternion(), Vector(0, 0, -30), 1, 0.1)
> File "./space.py", line 131, in __init__
> Object.__init__(self, obj, tex, rot, pos)
> File "./space.py", line 124, in __init__
> self.model = Model(obj)
> File "./space.py", line 80, in __init__
> self.CalcNormals()
> File "./space.py", line 90, in CalcNormals
> vectB = (vectA - vectB).Normalize()
> AttributeError: Vector instance has no attribute 'Normalize'
>
I get a different error:
File "J:\pipelines\vector.py", line 8, in Normalize
return self / self.Length()
AttributeError: Vector instance has no attribute 'Length'
> The definition for Vector is:
>
> class Vector:
> def __init__(self, x=0, y=0, z=0):
> self.x = x
> self.y = y
> self.z = z
>
> def Normalize(self):
> return self / self.Length()
>
> def __sub__(self, right):
> return Vector(self.x - right.x, self.y - right.y, self.z - right.z)
>
>
>
--
Bob Gailer<br>
Chapel Hill NC<br>
919-636-4239
More information about the Tutor
mailing list