def calculateTangiblePositionAndRotationWithLiveIDs(self,id1,id2) : #translate from live ID to internal ID internalCursorID1 = self.externalIDtoTangibleCursorID(id1) internalCursorID2 = self.externalIDtoTangibleCursorID(id2) # create dictionary with live cursors liveCursors = {} for c in self.externalCursors: liveCursors[c.id] = c # calculate original rotation angle p1old = pointVector(self.tangibleCursors[internalCursorID1].offsetFromCenterX, self.tangibleCursors[internalCursorID1].offsetFromCenterY) p2old = pointVector(self.tangibleCursors[internalCursorID2].offsetFromCenterX, self.tangibleCursors[internalCursorID2].offsetFromCenterY) rotationAngleInCenteredTangible = calcClockWiseAngle(p1old,p2old) # calculate the current angle p1now = pointVector(liveCursors[id1].x, liveCursors[id1].y) p2now = pointVector(liveCursors[id2].x, liveCursors[id2].y) rotationAngleOfTangibleNow = calcClockWiseAngle(p1now, p2now); # calculate the difference between the two angles currentRotation = clockwiseDifferenceBetweenAngles(rotationAngleInCenteredTangible, rotationAngleOfTangibleNow); # check if the rotation filter is set to pre if settings.get('rotationFilterPosition') == 'pre': # add current rotation value to the rotation filter self.tangibleRotationFilter.addValue(currentRotation) # get rotation value from filter currentRotation = self.tangibleRotationFilter.getState() # calculate the vector form current p1 to the tangible center shiftOfId1 = rotateVector(p1old, currentRotation) # calculate position currentPosition = p1now - shiftOfId1 # check if the position filter is active if settings.get('positionFilterActive'): # add current position to filter self.tangiblePositionFilter.addXvalue(currentPosition.x) self.tangiblePositionFilter.addYvalue(currentPosition.y) # get position from filter currentPosition.x = self.tangiblePositionFilter.getXstate() currentPosition.y = self.tangiblePositionFilter.getYstate() # check if post rotation filter is active if settings.get('rotationFilterPosition') == 'post': # add current rotation value to the rotation filter self.tangibleRotationFilter.addValue(currentRotation) # get rotation value from filter currentRotation = self.tangibleRotationFilter.getState() # set position and rotation self.position = currentPosition self.rotation = currentRotation
def calculateTangiblePositionAndRotation(self, id1, id2): # calculate original rotation angle p1old = pointVector(self.tangibleCursors[id1].offsetFromCenterX, self.tangibleCursors[id1].offsetFromCenterY) p2old = pointVector(self.tangibleCursors[id2].offsetFromCenterX, self.tangibleCursors[id2].offsetFromCenterY) rotationAngleInCenteredTangible = calcClockWiseAngle(p1old, p2old) # calculate the current angle p1now = pointVector(self.tangibleCursors[id1].lastKnownPositionX, self.tangibleCursors[id1].lastKnownPositionY) p2now = pointVector(self.tangibleCursors[id2].lastKnownPositionX, self.tangibleCursors[id2].lastKnownPositionY) rotationAngleOfTangibleNow = calcClockWiseAngle(p1now, p2now) # calculate the difference between the two angles currentRotation = clockwiseDifferenceBetweenAngles( rotationAngleInCenteredTangible, rotationAngleOfTangibleNow) # check if the rotation filter is set to pre if settings.get('rotationFilterPosition') == 'pre': # add current rotation value to the rotation filter self.tangibleRotationFilter.addValue(currentRotation) # get rotation value from filter currentRotation = self.tangibleRotationFilter.getState() # calculate the vector form current p1 to the tangible center shiftOfId1 = rotateVector(p1old, currentRotation) # calculate position currentPosition = p1now - shiftOfId1 # check if the position filter is active if settings.get('positionFilterActive'): # add current position to filter self.tangiblePositionFilter.addXvalue(currentPosition.x) self.tangiblePositionFilter.addYvalue(currentPosition.y) # get position from filter currentPosition.x = self.tangiblePositionFilter.getXstate() currentPosition.y = self.tangiblePositionFilter.getYstate() # check if post rotation filter is active if settings.get('rotationFilterPosition') == 'post': # add current rotation value to the rotation filter self.tangibleRotationFilter.addValue(currentRotation) # get rotation value from filter currentRotation = self.tangibleRotationFilter.getState() # set position and rotation self.position = currentPosition self.rotation = currentRotation
def calculateTangiblePositionAndRotation(self,id1,id2) : # calculate original rotation angle p1old = pointVector(self.tangibleCursors[id1].offsetFromCenterX,self.tangibleCursors[id1].offsetFromCenterY) p2old = pointVector(self.tangibleCursors[id2].offsetFromCenterX,self.tangibleCursors[id2].offsetFromCenterY) rotationAngleInCenteredTangible = calcClockWiseAngle(p1old,p2old) # calculate the current angle p1now = pointVector(self.tangibleCursors[id1].lastKnownPositionX,self.tangibleCursors[id1].lastKnownPositionY) p2now = pointVector(self.tangibleCursors[id2].lastKnownPositionX,self.tangibleCursors[id2].lastKnownPositionY) rotationAngleOfTangibleNow = calcClockWiseAngle(p1now, p2now); # calculate the difference between the two angles currentRotation = clockwiseDifferenceBetweenAngles(rotationAngleInCenteredTangible, rotationAngleOfTangibleNow); # check if the rotation filter is set to pre if settings.get('rotationFilterPosition') == 'pre': # add current rotation value to the rotation filter self.tangibleRotationFilter.addValue(currentRotation) # get rotation value from filter currentRotation = self.tangibleRotationFilter.getState() # calculate the vector form current p1 to the tangible center shiftOfId1 = rotateVector(p1old, currentRotation) # calculate position currentPosition = p1now - shiftOfId1 # check if the position filter is active if settings.get('positionFilterActive'): # add current position to filter self.tangiblePositionFilter.addXvalue(currentPosition.x) self.tangiblePositionFilter.addYvalue(currentPosition.y) # get position from filter currentPosition.x = self.tangiblePositionFilter.getXstate() currentPosition.y = self.tangiblePositionFilter.getYstate() # check if post rotation filter is active if settings.get('rotationFilterPosition') == 'post': # add current rotation value to the rotation filter self.tangibleRotationFilter.addValue(currentRotation) # get rotation value from filter currentRotation = self.tangibleRotationFilter.getState() # set position and rotation self.position = currentPosition self.rotation = currentRotation
def registerCursors(self, *args,**kwargs): self.id = kwargs.get('id', 0) cursors = args[0] # set the center for tangible creation, if not provdided otherwise calibrationCenter = pointVector(settings.get('calibrationCenter')[0],settings.get('calibrationCenter')[1]) # add points to dictionary for c in cursors: self.tangibleCursors[c.id] = tangibleCursor(x=c.x,y=c.y) self.tangibleCursors[c.id].calcOffset(calibrationCenter) # create triangles from points self.tangibleTriangles = createTrianglesFromCursors(cursors)
def __init__(self): self.id = 0 self.position = pointVector() self.rotation = 0.0 self.outOfJailCard = 2 self.tangibleCursors = {} self.tangibleTriangles = [] self.currentlyRecognized = False self.lastSuccesfulRunIDs = [] self.externalIDtoTangibleCursorIDdict = {} self.externalIDtoTangibleCursorIDdictReverse = {} self.tangiblePositionFilter = positionFilter() self.tangibleRotationFilter = rotationFilter()
def registerCursors(self, *args, **kwargs): self.id = kwargs.get('id', 0) cursors = args[0] # set the center for tangible creation, if not provdided otherwise calibrationCenter = pointVector( settings.get('calibrationCenter')[0], settings.get('calibrationCenter')[1]) # add points to dictionary for c in cursors: self.tangibleCursors[c.id] = tangibleCursor(x=c.x, y=c.y) self.tangibleCursors[c.id].calcOffset(calibrationCenter) # create triangles from points self.tangibleTriangles = createTrianglesFromCursors(cursors)
def calculateTangiblePositionAndRotationWithLiveIDs(self, id1, id2): #translate from live ID to internal ID internalCursorID1 = self.externalIDtoTangibleCursorID(id1) internalCursorID2 = self.externalIDtoTangibleCursorID(id2) # create dictionary with live cursors liveCursors = {} for c in self.externalCursors: liveCursors[c.id] = c # calculate original rotation angle p1old = pointVector( self.tangibleCursors[internalCursorID1].offsetFromCenterX, self.tangibleCursors[internalCursorID1].offsetFromCenterY) p2old = pointVector( self.tangibleCursors[internalCursorID2].offsetFromCenterX, self.tangibleCursors[internalCursorID2].offsetFromCenterY) rotationAngleInCenteredTangible = calcClockWiseAngle(p1old, p2old) # calculate the current angle p1now = pointVector(liveCursors[id1].x, liveCursors[id1].y) p2now = pointVector(liveCursors[id2].x, liveCursors[id2].y) rotationAngleOfTangibleNow = calcClockWiseAngle(p1now, p2now) # calculate the difference between the two angles currentRotation = clockwiseDifferenceBetweenAngles( rotationAngleInCenteredTangible, rotationAngleOfTangibleNow) # check if the rotation filter is set to pre if settings.get('rotationFilterPosition') == 'pre': # add current rotation value to the rotation filter self.tangibleRotationFilter.addValue(currentRotation) # get rotation value from filter currentRotation = self.tangibleRotationFilter.getState() # calculate the vector form current p1 to the tangible center shiftOfId1 = rotateVector(p1old, currentRotation) # calculate position currentPosition = p1now - shiftOfId1 # check if the position filter is active if settings.get('positionFilterActive'): # add current position to filter self.tangiblePositionFilter.addXvalue(currentPosition.x) self.tangiblePositionFilter.addYvalue(currentPosition.y) # get position from filter currentPosition.x = self.tangiblePositionFilter.getXstate() currentPosition.y = self.tangiblePositionFilter.getYstate() # check if post rotation filter is active if settings.get('rotationFilterPosition') == 'post': # add current rotation value to the rotation filter self.tangibleRotationFilter.addValue(currentRotation) # get rotation value from filter currentRotation = self.tangibleRotationFilter.getState() # set position and rotation self.position = currentPosition self.rotation = currentRotation