def normalize(self, mag=1.0):
    d = Math.sqrt(((self.x * self.x) + (self.y * self.y)))
    if ((d == 0) or (mag == 0)):
        self.x = 0
        self.y = 0
    else:
        self.x = ((mag * self.x) / d)
        self.y = ((mag * self.y) / d)
    return self
def normalize(self, mag=1.0):
    d = Math.sqrt(((self.x * self.x) + (self.y * self.y)))
    if ((d == 0) or (mag == 0)):
        self.x = 0
        self.y = 0
    else:
        self.x = ((mag * self.x) / d)
        self.y = ((mag * self.y) / d)
    return self