Esempio n. 1
0
def getSegmentsFromLoopListsPoints( loopLists, pointBegin, pointEnd ):
	"Get endpoint segments from the beginning and end of a line segment."
	normalizedSegment = pointEnd - pointBegin
	normalizedSegmentLength = abs( normalizedSegment )
	if normalizedSegmentLength == 0.0:
		return []
	normalizedSegment /= normalizedSegmentLength
	segmentYMirror = complex( normalizedSegment.real, - normalizedSegment.imag )
	pointBeginRotated = segmentYMirror * pointBegin
	pointEndRotated = segmentYMirror * pointEnd
	rotatedLoopLists = []
	for loopList in loopLists:
		rotatedLoopList = []
		rotatedLoopLists.append( rotatedLoopList )
		for loop in loopList:
			rotatedLoop = euclidean.getPointsRoundZAxis( segmentYMirror, loop )
			rotatedLoopList.append( rotatedLoop )
	xIntersectionIndexList = []
	xIntersectionIndexList.append( euclidean.XIntersectionIndex( - 1, pointBeginRotated.real ) )
	xIntersectionIndexList.append( euclidean.XIntersectionIndex( - 1, pointEndRotated.real ) )
	euclidean.addXIntersectionIndexesFromLoopListsY( rotatedLoopLists, xIntersectionIndexList, pointBeginRotated.imag )
	segments = euclidean.getSegmentsFromXIntersectionIndexes( xIntersectionIndexList, pointBeginRotated.imag )
	for segment in segments:
		for endpoint in segment:
			endpoint.point *= normalizedSegment
	return segments
Esempio n. 2
0
def getSegmentsFromLoopListsPoints(loopLists, pointBegin, pointEnd):
    "Get endpoint segments from the beginning and end of a line segment."
    normalizedSegment = pointEnd - pointBegin
    normalizedSegmentLength = abs(normalizedSegment)
    if normalizedSegmentLength == 0.0:
        return []
    normalizedSegment /= normalizedSegmentLength
    segmentYMirror = complex(normalizedSegment.real, -normalizedSegment.imag)
    pointBeginRotated = segmentYMirror * pointBegin
    pointEndRotated = segmentYMirror * pointEnd
    rotatedLoopLists = []
    for loopList in loopLists:
        rotatedLoopList = []
        rotatedLoopLists.append(rotatedLoopList)
        for loop in loopList:
            rotatedLoop = euclidean.getPointsRoundZAxis(segmentYMirror, loop)
            rotatedLoopList.append(rotatedLoop)
    xIntersectionIndexList = []
    xIntersectionIndexList.append(
        euclidean.XIntersectionIndex(-1, pointBeginRotated.real))
    xIntersectionIndexList.append(
        euclidean.XIntersectionIndex(-1, pointEndRotated.real))
    euclidean.addXIntersectionIndexesFromLoopListsY(rotatedLoopLists,
                                                    xIntersectionIndexList,
                                                    pointBeginRotated.imag)
    segments = euclidean.getSegmentsFromXIntersectionIndexes(
        xIntersectionIndexList, pointBeginRotated.imag)
    for segment in segments:
        for endpoint in segment:
            endpoint.point *= normalizedSegment
    return segments
Esempio n. 3
0
def getSegmentsFromPoints( aroundLists, loopLists, pointBegin, pointEnd ):
	"Get endpoint segments from the beginning and end of a line segment."
	normalizedSegment = pointEnd - pointBegin
	normalizedSegmentLength = abs( normalizedSegment )
	if normalizedSegmentLength == 0.0:
		return
	normalizedSegment /= normalizedSegmentLength
	segmentYMirror = complex( normalizedSegment.real, - normalizedSegment.imag )
	pointBeginRotated = segmentYMirror * pointBegin
	pointEndRotated = segmentYMirror * pointEnd
	rotatedLoopLists = []
	for loopList in loopLists:
		rotatedLoopList = []
		rotatedLoopLists.append( rotatedLoopList )
		for loop in loopList:
			rotatedLoop = euclidean.getPointsRoundZAxis( segmentYMirror, loop )
			rotatedLoopList.append( rotatedLoop )
	xIntersectionIndexList = []
	xIntersectionIndexList.append( euclidean.XIntersectionIndex( - 1, pointBeginRotated.real ) )
	xIntersectionIndexList.append( euclidean.XIntersectionIndex( - 1, pointEndRotated.real ) )
	euclidean.addXIntersectionIndexesFromLoopListsY( rotatedLoopLists, xIntersectionIndexList, pointBeginRotated.imag )
	segments = euclidean.getSegmentsFromXIntersectionIndexes( xIntersectionIndexList, pointBeginRotated.imag )
	insideSegments = []
	for segment in segments:
		insideSegment = euclidean.getSegmentFromPoints( normalizedSegment * segment[ 0 ].point, normalizedSegment * segment[ 1 ].point )
		if len( aroundLists ) < 1:
			insideSegments.append( insideSegment )
		elif isSegmentInsideAround( aroundLists, insideSegment ):
			insideSegments.append( insideSegment )
	return insideSegments