Exemplo n.º 1
0
	def test_tangetialAngle(self):
		alpha = vectorFunctions.getTangentialAngle([0,0],[0,1],[0,2])
		self.assertAlmostEqual( alpha, 0 )
		
		alpha = vectorFunctions.getTangentialAngle([1,1],[2,2],[3,3])
		self.assertAlmostEqual( alpha, -math.pi/4.0 )

		alpha = vectorFunctions.getTangentialAngle([-1,1],[-2,2],[-3,3])
		self.assertAlmostEqual( alpha, math.pi/4.0 )

		alpha = vectorFunctions.getTangentialAngle([0,0],[0,2],[2,2])
		self.assertAlmostEqual( alpha, -math.pi/4.0 )

		alpha = vectorFunctions.getTangentialAngle([0,0],[0,2],[-2,2])
		self.assertAlmostEqual( alpha, math.pi/4.0 )
Exemplo n.º 2
0
def computeSkeletonTangents(skeletonPoints):

	length = 10;
	skeletonTangents = [  [(int(skeletonPoints[0][0] + length), int(skeletonPoints[0][1])), (int(skeletonPoints[0][0] - length), int(skeletonPoints[0][1])) ]];

	for i in range(len(skeletonPoints)-2):
		p1 = skeletonPoints[i]
		p2 = skeletonPoints[i+1]
		p3 = skeletonPoints[i+2]
		
		theta = vf.getTangentialAngle(p1,p2,p3);
		
		l1 = ( int(p2[0] + length*math.cos(theta)), int(p2[1] + length*math.sin(theta)));
		l2 = ( int(p2[0] - length*math.cos(theta)), int(p2[1] - length*math.sin(theta)));
		
		skeletonTangents.append([l1,l2])
		
	pDiff = vf.pDiff(skeletonPoints[-1], skeletonPoints[-2])
	
	l1 = ( int(skeletonTangents[-1][0][0] + pDiff[0]), int(skeletonTangents[-1][0][1] + pDiff[1]) )
	l2 = ( int(skeletonTangents[-1][1][0] + pDiff[0]), int(skeletonTangents[-1][1][1] + pDiff[1]) )
	skeletonTangents.append( [l1,l2] )
	
	
	return skeletonTangents