# import math # class ThreeVec(object): "Class for 3 Vector and operations" def __init__( self, x=0., y=0., z=0.): self.x = x self.y = y self.z = z def Add( self, tv ): # add two 3 vecs newvec = ThreeVec( self.x+tv.x, self.y+tv.y, self.z+tv.z) return newvec def Length( self ): # return math.sqrt( self.x**2 + self.y**2 + self.z**2 ) def Scale( self, a ): # Skalierung mit float pass # ... def Angle( self, a ): # Winkel zwischen 2 Threevectors pass # ... def ScalProd( self, tv ): # Skalarprodukt von 2 Threevectors pass # ... def CrossProd( self, tv ): # Kreuzprodukt von 2 Threevectors pass # ... # # # use ThreeVec # tv1 = ThreeVec( 1., 2., 0.) # create ThreeVec object ( calls ThreeVec.__init__ ) tv2 = ThreeVec( 1., -1., 1.) # create ThreeVec object tv3 = ThreeVec( 3, -2, 4) # create ThreeVec object tv4 = tv3.Add( tv1 ) # Add two ThreeVecs print (tv1.Length()) # print (tv3.Length()) print (tv4.Length())