Esempio n. 1
0
 def direction(self):
     """Return direction of vector (i.e. angle between vector and the horizontal plane"""
     deg = []
     if self.dimensions < 2:
         return 0 # With only 1 dimension, y is essentially zero, so angle is always 0
     if self.dimensions == 2:
         x = degrees(arctan(self.pix[1]/self.pix[0])) if self.pix[0] != 0 else 90 # Angle from x axis (y is opp, x is adj)
         y = degrees(arctan(self.pix[0]/self.pix[1])) if self.pix[1] != 0 else 90 # Angle from y axis (x is opp, y is adj)
         return (x, y)
     if self.dimensions == 3:
         x = degrees(arctan(self.pix[1]/self.pix[0])) if self.pix[0] != 0 else 90 # Angle from x axis (y is opp, x is adj)
         y = degrees(arctan(self.pix[0]/self.pix[1])) if self.pix[1] != 0 else 90 # Angle from y axis (x is opp, y is adj)
         z = degrees(arctan(self.pix[2]/hypot3d(*self.pix[:2]))) if hypot3d(*self.pix[:2]) != 0 else 90 # Angle from z axis (z is opp, hyp(x,y) is adj)
         return (x,y,z)
Esempio n. 2
0
 def magnitude(self):
     """Return magnitude of vector (i.e. length of the line from vector to (0,0) in pixels)"""
     return hypot3d(*self.pix)