Example #1
0
class Calculations:

    #Constructor
    def __init__(self):
        self.delta = array([[0, 0], [0, 0]])
        self.lookupTable = LookUpTable()
        pass

    def calcAngle(self, newDelta):
        delta = newDelta

        D = 5

        mus1 = self.lookupTable.getAngLen(delta[0][0], delta[0][1])
        mus2 = self.lookupTable.getAngLen(delta[1][0], delta[1][1])

        try:
            print("both mice are mice")
            my = math.fabs(mus1.getAngle() - mus2.getAngle())

            #             thetaRad = ((
            #                          math.sqrt(
            #                                    math.pow(mus1.getLength(), 2) +
            #                                    math.pow(mus2.getLength(), 2) -
            #                                    (2* self.lookupTable.getCos(angleY) * mus1.getLength()*mus2.getLength()))
            #                      )/D) * math.fabs(delta[0][1] - delta[1][1])

            thetaRad = self.getThetaRad(
                mus1.getLength(),
                mus2.getLength(),
                delta[0][1],
                delta[1][1],
            )
            print "angle=" + str(thetaRad) + " len=" + str(
                math.fabs((mus1.getLength() + mus2.getLength()) / 2), my)

        #else:
        except:
            print("both mice are not mice")

    def calcThetaRad(self, l1, l2, y1, y2, D, my):
        thetaRad = ((math.sqrt(
            math.pow(l1, 2) + math.pow(l2, 2) -
            (2 * self.lookupTable.getCos(my) * l1 * l2))) / D) * math.fabs(y1 -
                                                                           y2)
Example #2
0
class Calculations:
    

    #Constructor
    def __init__(self):
        self.delta = array([[0,0],[0,0]])
        self.lookupTable=LookUpTable()   
        pass
    

    def calcAngle(self,newDelta):                    
        delta=newDelta
        
        D = 5
        
        mus1=self.lookupTable.getAngLen(delta[0][0], delta[0][1])
        mus2=self.lookupTable.getAngLen(delta[1][0], delta[1][1])

        try:
            print("both mice are mice") 
            my = math.fabs(mus1.getAngle() - mus2.getAngle() )
 
#             thetaRad = ((
#                          math.sqrt(
#                                    math.pow(mus1.getLength(), 2) +
#                                    math.pow(mus2.getLength(), 2) -
#                                    (2* self.lookupTable.getCos(angleY) * mus1.getLength()*mus2.getLength()))
#                      )/D) * math.fabs(delta[0][1] - delta[1][1])
            
            thetaRad=self.getThetaRad(mus1.getLength(),mus2.getLength(),delta[0][1],delta[1][1],)        
            print "angle="+str(thetaRad) +" len="+ str(math.fabs((mus1.getLength()+mus2.getLength())/2),my)
                     
        #else:
        except:
            print("both mice are not mice")
        
    def calcThetaRad(self,l1,l2,y1,y2,D,my):
        thetaRad = ((math.sqrt(math.pow(l1, 2) + math.pow(l2, 2) -(2* self.lookupTable.getCos(my) * l1*l2)))/D) * math.fabs(y1 - y2)
Example #3
0
 def __init__(self):
     self.delta = array([[0,0],[0,0]])
     self.lookupTable=LookUpTable()   
     pass
Example #4
0
 def __init__(self):
     self.delta = array([[0, 0], [0, 0]])
     self.lookupTable = LookUpTable()
     pass