[Tutor] AttributeError: Vector instance has no attribute 'Normalize'

Garrett Hartshaw ghartshaw at gmail.com
Fri Nov 27 20:29:28 CET 2009


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'

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)

so I cannot figure out what the error is.

(o_
//\
V_/_


More information about the Tutor mailing list