예제 #1
0
	def test_isLeft(self):
		res = vectorFunctions.isLeft([1,1], [10,1], [5,2]);
		self.assertTrue(res)
		
		res = vectorFunctions.isLeft([1,1], [10,1], [5,-2]);
		self.assertFalse(res)
		
		res = vectorFunctions.isLeft([1,1], [1,10], [-2,-2]);
		self.assertTrue(res)

		res = vectorFunctions.isLeft([1,1], [1,10], [-2,-2]);
		self.assertTrue(res)
예제 #2
0
def determineEnclosingSegments(skeletonTangents, u):
	for i in range(len(skeletonTangents)):
		p1 = skeletonTangents[i][0]
		p2 = skeletonTangents[i][1]
		
		if not vf.isLeft( p1, p2, u):
		
			distance_upper = vf.shortestDistanceToLine(p1,p2,u)
			if i > 0:
				distance_lower = vf.shortestDistanceToLine(skeletonTangents[i-1][0],skeletonTangents[i-1][1],u)
			else:
				distance_lower = 1e100 #todo: besser sowas wie INF verwenden?

			#print p1, p2, u
			return (i-1, distance_upper, distance_lower)
	
	distance_lower = vf.shortestDistanceToLine(skeletonTangents[-1][0],skeletonTangents[-1][1],u)
	return (len(skeletonTangents)-1, 1e100, distance_lower)