def compareSupportFunctions(repeats, eps): P = rP.getRandomPolygon(3) Q = rP.getRandomPolygon(4) cD_P = cV.getConeVol(P) for i in range(len(P)): u = [cD_P[i - 1][0], cD_P[i - 1][1]] alpha = rP.supportFunctionCartesianCentered(Q, u) beta = rP.supportFunctionCartesianCentered2(Q, u) alternative = trySupport(Q, u) print(alternative) print(alpha) print(beta)
def supportTest(repeats): tooSmall = 0 tooSmall2 = 0 tooSmall3 = 3 tooBig = 0 easyFail = 0 n = 0 while (n < repeats): containsPoint_eps = 0 P = rP.getRandomPolygon(3) Q = rP.getRandomPolygon(4) cD_P = cV.getConeVol(P) for i in range(len(P)): print(len(P)) u = [cD_P[i - 1][0], cD_P[i - 1][1]] alpha = rP.supportFunctionCartesianCentered(Q, u) beta = rP.supportFunctionCartesianCentered2(Q, u) gamma = 1 #trySupport( Q , u , 0.0000001) if math.fabs( M.scal(u, P[i - 1]) - rP.supportFunctionCartesianCentered2(P, u)) > 1: easyFail += 1 if not (containsPoint(Q, M.scaleVek(alpha - math.exp(-15), u))): tooBig += 1 if (containsPoint(Q, M.scaleVek(alpha + 0.01, u))): #plotPoly( P , 'r' ) #plotPoly( Q , 'y') tooSmall += 1 if (containsPoint(Q, M.scaleVek(beta + 0.01, u))): #plotPoly( P , 'r' ) #plotPoly( Q , 'y') tooSmall2 += 1 if (containsPoint(Q, M.scaleVek(gamma + 0.01, u))): #plotPoly( P , 'r' ) #plotPoly( Q , 'y') tooSmall3 += 1 n += 1 print([easyFail, tooBig, tooSmall, tooSmall2, tooSmall3])
def getWorsteNormalsDirection(polygon): n = len(polygon) result = 0 cD = cV.getConeVol(polygon) for i in range(n): u = [cD[i % n][0], cD[i % n][1]] v = polygon[i - 1] w = polygon[i % n] diff = math.fabs(M.scal(v, u) - M.scal(w, u)) if diff > result: result = diff return result
def makeNormalsTest(polygon, eps_norm, eps_direction): n = len(polygon) cD = cV.getConeVol(polygon) for i in range(n): u = [cD[i % n][0], cD[i % n][1]] if math.fabs(M.norm(u) - 1) > eps_norm: return False v = polygon[i - 1] w = polygon[i % n] diff = math.fabs(M.scal(v, u) - M.scal(w, u)) if diff > eps_direction: return False return True
result = [ [ 0 , 0 ] , math.inf ] n = 2 while( result[1] > eps_orthGrad): temp = min( getGrid( n ) , cD , scalAbsGrad ) if temp[1] < result[1]: result = temp n = n + 1 return result cD_random = cV.getConeVol(rP.getRandomPolygon( 5 )) eps_orthGrad = 0.01 orthGrad_test = getOrthGrad( cD_test ) # print(cV.coneVolumeNewton( cD_test , [ orthGrad_test[0][0] , orthGrad_test[0][1] ] ) ) # newton läuft gegen [ 0 , inf ] mit orthGrad_test-startpunkt bei [5.25, 7.0]. Der presolver ist nicht geeignet. Baue lieber Quadrat im 1. Quadranten, der eine Aufsteigsrichtung enthält. Verfeinere dann dieses Quadrat, ohne es zu vergrößern def startPoint(): n=4 result=[[0,0],float("inf")] while(result[1]>min_grid): grid=getGrid(n) result=min_psi(grid) if(result[1]==0):