Advertisement
TankorSmash

Untitled

Feb 11th, 2012
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1.     def angle(self, o, p1, p2):
  2.         '''the angle between two points around origin (never used origin)
  3.        
  4.        eq= len(op1)**2 + len(op2)**2 - len(p1p2)**2 over
  5.             / 2*len(op1)*len(op2) '''
  6.  
  7.         ##norm both points
  8.         #p1 = self.normalize(p1)
  9.         #p2 = self.normalize(p2)
  10.        
  11.        
  12.         #lengths of both points from origin
  13.         a = self.distance(o, p1)
  14.         b = self.distance(o, p2)
  15.         c = self.distance(p1, p2)
  16.        
  17.         print 'distance of a, b, c:', a, b, c      
  18.        
  19.        
  20.         #main equation
  21.         cosC = (a ** 2 + b ** 2 - c ** 2) / (2 * a * b)
  22.         print 'result of equation', cosC
  23.        
  24.        
  25.         ##solve cos with var cosC
  26.         #Ccos = math.cos(cosC)
  27.         #print 'used equations result and cosd it', Ccos
  28.        
  29.         C = math.acos(cosC)
  30.         print 'angle between the two points in relation to origin in rads', C
  31.        
  32.         degC = math.degrees(C)
  33.         print 'C in degrees', degC
  34.         return degC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement