Esempio n. 1
0
    def __init__(self,x=0,y=0,z=0):
        if hasattr(x,'__getitem__'):
            self.x=x[0]
            self.y=x[1]
            self.z=x[2]
        elif Vector.is_vector(x):
            self.x=x.x
            self.y=x.y
            self.z=x.z
        elif Number.is_number(x) and Number.is_number(y) and Number.is_number(z):
            self.x=float(x)
            self.y=float(y)
            self.z=float(z)
        else:
            print("ERROR:<__init__@Vector>:Can not init.\n")
            exit()

        self.vector=(self.x,self.y,self.z)
Esempio n. 2
0
 def __mul__(self, other):
     if Vector.is_vector(other):
         x=other.x
         y=other.y
         z=other.z
         return self.x*x+self.y*y+self.z*z
     elif Number.is_number(other):
         return Vector(self.x*other,self.y*other,self.z*other)
     else:
         exit("ERROR:<__mul__@Vector>:Can not multiply.\n")
Esempio n. 3
0
 def __floordiv__(self, other):
     if Number.is_number(other):
         return Vector(self.x//other,self.y//other,self.z//other)
     else:
         exit("ERROR:<__floordiv__@Vector>:Can not divide.\n")