예제 #1
0
 def direction(self):
     """Return direction of vector (i.e. angle between vector and the horizontal plane (WIP)"""
     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 = numpy.degrees(numpy.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 = numpy.degrees(numpy.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 = numpy.degrees(numpy.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 = numpy.degrees(numpy.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 = numpy.degrees(
             numpy.arctan(self.pix[2] / numpy.hypot3d(*self.pix[:2]))
         ) if numpy.hypot3d(
             *self.pix[:2]
         ) != 0 else 90  # Angle from z axis (z is opp, hyp(x,y) is adj)
         return (x, y, z)
예제 #2
0
    def direction(self):
        """Direction of vector (i.e. angle between vector and the horizontal
        plane).
        """
        if self.dimensions < 2:
            # with only 1 dimension, y is essentially zero, so angle is always 0
            return 0.0

        toReturn = []  # store output values

        if self.dimensions >= 2:
            if self.pix[0] != 0.0:  # Angle from x-axis (y is opp, x is adj)
                x = np.degrees(np.arctan(self.pix[1] / self.pix[0]))
            else:
                x = 90.0

            toReturn.append(x)

            if self.pix[1] != 0.0:  # Angle from y-axis (x is opp, y is adj)
                y = np.degrees(np.arctan(self.pix[0] / self.pix[1]))
            else:
                y = 90.0

            toReturn.append(y)

        if self.dimensions == 3:
            # Angle from z-axis (z is opp, hyp(x,y) is adj)
            if np.hypot3d(*self.pix[:2]) != 0.0:
                u = np.hypot3d(*self.pix[:2])
                z = np.degrees(np.arctan(self.pix[2] / u))
            else:
                z = 90.0

            toReturn.append(z)

        return toReturn
예제 #3
0
 def magnitude(self):
     """Magnitude of vector (i.e. length of the line from vector to (0, 0)
     in pixels).
     """
     return np.hypot3d(*self.pix)
예제 #4
0
 def magnitude(self):
     """Return magnitude of vector (i.e. length of the line from vector to (0,0) in pixels) (WIP)"""
     return numpy.hypot3d(*self.pix)