Пример #1
0
	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	
Пример #2
0
    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
Пример #3
0
	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
Пример #4
0
    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