本文整理汇总了Python中lib.GeoMath.vecNormalize方法的典型用法代码示例。如果您正苦于以下问题:Python GeoMath.vecNormalize方法的具体用法?Python GeoMath.vecNormalize怎么用?Python GeoMath.vecNormalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.GeoMath
的用法示例。
在下文中一共展示了GeoMath.vecNormalize方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: detVec
# 需要导入模块: from lib import GeoMath [as 别名]
# 或者: from lib.GeoMath import vecNormalize [as 别名]
def detVec(prim, dirVec, exception):
global epsilon
reload(GeoMath)
vec1 = GeoMath.vecNormalize(GeoMath.vecSub(list(prim.vertices()[0].point().position()), list(prim.vertices()[1].point().position())))
vec2 = GeoMath.vecNormalize(GeoMath.vecSub(list(prim.vertices()[2].point().position()), list(prim.vertices()[1].point().position())))
prim_normal = list(prim.normal())
if(list(prim_normal) != [0, 1, 0]):
# We consider that y is vertical and x horizontal
if(math.fabs(vec1[1]) > math.fabs(vec2[1])):
# If the vectors are dependent
if(math.fabs(GeoMath.vecDotProduct(vec1, vec2)) > epsilon):
vecV = GeoMath.rotateVecByVec(vec2, prim_normal, 90)
# Quads!!
if(GeoMath.vecDotProduct(vecV, vec1) < -epsilon):
vecV = GeoMath.rotateVecByVec(vec2, prim_normal, -90)
else:
vecV = vec1
vecH = vec2
else:
# If the vectors are dependent
if(math.fabs(GeoMath.vecDotProduct(vec1, vec2)) > epsilon):
vecV = GeoMath.rotateVecByVec(vec1, prim_normal, 90)
# Quads!!
if(GeoMath.vecDotProduct(vecV, vec2) < -epsilon):
vecV = GeoMath.rotateVecByVec(vec1, prim_normal, -90)
else:
vecV = vec2
vecH = vec1
else:
# We consider that x is vertical and z horizontal
if(math.fabs(vec1[0]) > math.fabs(vec2[0])):
# If the vectors are dependent
if(math.fabs(GeoMath.vecDotProduct(vec1, vec2)) > epsilon):
vecV = GeoMath.rotateVecByVec(vec2, prim_normal, 90)
# Quads!!
if(GeoMath.vecDotProduct(vecV, vec1) < -epsilon):
vecV = GeoMath.rotateVecByVec(vec2, prim_normal, -90)
else:
vecV = vec1
vecH = vec2
else:
# If the vectors are dependent
if(math.fabs(GeoMath.vecDotProduct(vec1, vec2)) > epsilon):
vecV = GeoMath.rotateVecByVec(vec1, prim_normal, 90)
#Quads!!!
if(GeoMath.vecDotProduct(vecV, vec2) < -epsilon):
vecV = GeoMath.rotateVecByVec(vec1, prim_normal, -90)
else:
vecV = vec2
vecH = vec1
if(GeoMath.vecDotProduct(dirVec, vecH) < 0):
vecH = GeoMath.vecSub([0, 0, 0], vecH)
if(GeoMath.vecDotProduct(dirVec, vecV) < 0):
vecV = GeoMath.vecSub([0, 0, 0], vecV)
vecH = GeoMath.vecNormalize(vecH)
vecV = GeoMath.vecNormalize(vecV)
return vecH, vecV
示例2: calculateDisplacement
# 需要导入模块: from lib import GeoMath [as 别名]
# 或者: from lib.GeoMath import vecNormalize [as 别名]
def calculateDisplacement(self, curEdge, nextEdge):
"""
Edges are correlatives and in wise direction
"""
curEdgeNor = GeoMath.vecSub(curEdge[1], curEdge[0])
curEdgeNor = GeoMath.vecNormalize(curEdgeNor)
nextEdgeNor = GeoMath.vecSub(nextEdge[1], nextEdge[0])
nextEdgeNor = GeoMath.vecNormalize(nextEdgeNor)
return GeoMath.vecSub(curEdgeNor, nextEdgeNor)
示例3: bresenham
# 需要导入模块: from lib import GeoMath [as 别名]
# 或者: from lib.GeoMath import vecNormalize [as 别名]
def bresenham(Ipoint, point1, fPoint, xSize, ySize, prim, exception):
reload (GeoMath)
reload (DetermineVectors)
reload (Validator)
curPoint = point1
dirVec = GeoMath.vecNormalize(GeoMath.vecSub(fPoint, Ipoint))
# Get the horizontal and vertical vectors
xVec, yVec = DetermineVectors.DetermineVectors.detVec(prim, dirVec, exception)
xSizeVec = GeoMath.vecScalarProduct(xVec, xSize)
ySizeVec = GeoMath.vecScalarProduct(yVec, ySize)
vecToFinal = GeoMath.vecSub(curPoint, fPoint)
sizeToFinalx = abs(GeoMath.vecDotProduct(vecToFinal, xVec) / GeoMath.vecModul(xVec))
sizeToFinaly = abs(GeoMath.vecDotProduct(vecToFinal, yVec) / GeoMath.vecModul(yVec))
if(sizeToFinalx > xSize or sizeToFinaly > ySize):
pointx = GeoMath.vecPlus(curPoint, xSizeVec)
pointy = GeoMath.vecPlus(curPoint, ySizeVec)
pointxy = GeoMath.vecPlus(curPoint, xSizeVec)
pointxy = GeoMath.vecPlus(pointxy, ySizeVec)
curxVec = GeoMath.vecNormalize(GeoMath.vecSub(pointx, Ipoint))
curyVec = GeoMath.vecNormalize(GeoMath.vecSub(pointy, Ipoint))
curxyVec = GeoMath.vecNormalize(GeoMath.vecSub(pointxy, Ipoint))
# We get the max dot product, the vector nearest to line
dotx = GeoMath.vecDotProduct(curxVec, dirVec)
doty = GeoMath.vecDotProduct(curyVec, dirVec)
dotxy = GeoMath.vecDotProduct(curxyVec, dirVec)
pointsTemp = {}
if(Validator.Validator.pointInsidePrim(pointx, prim)): pointsTemp[dotx] = pointx
if(Validator.Validator.pointInsidePrim(pointy, prim)): pointsTemp[doty] = pointy
if(Validator.Validator.pointInsidePrim(pointxy, prim)): pointsTemp[dotxy] = pointxy
if(not pointsTemp):
point = list(fPoint)
else:
bestPoint = list(pointsTemp[sorted(pointsTemp)[len(pointsTemp) - 1]])
point = bestPoint
else:
point = list(fPoint)
'''
if(prim.number()==54):
print "Ipoint, fpoint"
print Ipoint, fPoint
print "pointx, pointy, pointxy"
print pointx, pointy, pointxy
print "Dots"
print dotx, doty, dotxy
print "sizes"
print sizeToFinalx, sizeToFinaly
print "Point"
print point
'''
return point
示例4: applyJoker
# 需要导入模块: from lib import GeoMath [as 别名]
# 或者: from lib.GeoMath import vecNormalize [as 别名]
def applyJoker(self, point1, point2, vecH, vecV):
vec = GeoMath.vecSub(point2, point1)
dotH = GeoMath.vecDotProduct(vec, vecH) / GeoMath.vecModul(vecH)
dotV = GeoMath.vecDotProduct(vec, vecV) / GeoMath.vecModul(vecV)
if(math.fabs(dotH) < math.fabs(dotV)):
normal = GeoMath.vecNormalize(vecH)
else:
normal = GeoMath.vecNormalize(vecV)
norV = GeoMath.vecNormalize(vecV)
norH = GeoMath.vecNormalize(vecH)
sizeX = GeoMath.vecModul(GeoMath.vecScalarProduct(norH, dotH))
sizeY = GeoMath.vecModul(GeoMath.vecScalarProduct(norV, dotV))
pointI1 = GeoMath.vecPlus(point1, GeoMath.vecScalarProduct(norH, dotH / 2))
pointI2 = GeoMath.vecPlus(pointI1, GeoMath.vecScalarProduct(norV, dotV))
return WallPattern(normal, [list(point1), pointI1, pointI2, list(point2)], [sizeX, sizeY], 0)
示例5: goToPrimPattern
# 需要导入模块: from lib import GeoMath [as 别名]
# 或者: from lib.GeoMath import vecNormalize [as 别名]
def goToPrimPattern(self, curPoint, nextPoint, pat, tbn, pointWhichIsRelative):
'''
TBN aplication
'''
global epsilon
for num in range(len(pat.points)):
pat.points[num] = tbn.mulPoint3ToMatrix3(pat.points[num])
pat.points[num] = GeoMath.vecPlus(pointWhichIsRelative, pat.points[num])
# Transform normal vector also
logging.debug("Changing normal" + str(pat.getNormal()))
transformed_normal = tbn.mulPoint3ToMatrix3(pat.getNormal())
logging.debug("Transformed normal" + str(transformed_normal))
normalized_normal = GeoMath.vecNormalize(transformed_normal)
logging.debug("normalized normal" + str(normalized_normal))
pat.setNormal(normalized_normal)
logging.debug("normalized normal set?? " + str(pat.getNormal()))
trans = GeoMath.vecSub(curPoint, pat.getFirstPoint())
likelyPointF = GeoMath.vecPlus(pat.getLastPoint(), trans)
if(GeoMath.vecModul(GeoMath.vecSub(likelyPointF, nextPoint)) > epsilon):
trans = GeoMath.vecSub(curPoint, pat.getLastPoint())
for num in range(len(pat.getPoints())):
pat.points[num] = self.translatePointToPrim(pat.points[num], trans)
if(GeoMath.vecModul(GeoMath.vecSub(likelyPointF, nextPoint)) > epsilon):
pat.points.reverse()
示例6: calculatePoints
# 需要导入模块: from lib import GeoMath [as 别名]
# 或者: from lib.GeoMath import vecNormalize [as 别名]
def calculatePoints(self):
# Filter the points, first we get the undermost points, and then,
# The point which less angle from z+ vector by y+ vector has.
global epsilon
vertices = [list(p.point().position()) for p in self.prim.vertices()]
lessy = vertices[0][1]
mayPoints = []
for point in vertices:
if((point[1] - epsilon) < lessy):
mayPoints.append(point)
if(point[1] < (lessy - epsilon)):
lessy = point[1]
mayPoints = [point]
# We construct vectors from points to determine which is leftmost, so we delete 'y' component
minAngle = 2 * math.pi + epsilon
for point in mayPoints:
vec = GeoMath.vecNormalize([point[0], 0, point[2]])
angle = GeoMath.angleBetweenPointsByVec([0, 0, 1], vec, [0, 1, 0])
if(angle < minAngle):
minAngle = angle
minPoint = point
index = vertices.index(minPoint)
previousPoint = vertices[index - 1]
pointWhichIsRelative = minPoint
nextPoint = vertices[(index + 1) % len(vertices)]
self.set_previous_point(previousPoint)
self.set_point_which_is_relative(pointWhichIsRelative)
self.set_next_point(nextPoint)
示例7: checkTexture
# 需要导入模块: from lib import GeoMath [as 别名]
# 或者: from lib.GeoMath import vecNormalize [as 别名]
def checkTexture(self, texture, previousTexture, genPattern, Fpoint, nextPoint):
tex, nearestPointIntersect, minDistance = texture.findIntersectionWithNearestTexture(genPattern.getPoints())
logging.debug("Start method checkTexture, class Crack")
if(tex):
logging.debug('nearestPointIntersect: ' + str(nearestPointIntersect) + 'Distance: ' + str(minDistance) + 'Texture: ' + str(tex.get_material().get_name()))
else:
logging.debug('nearestPointIntersect: ' + str(nearestPointIntersect) + 'Distance: ' + str(minDistance) + 'No Texture')
# If we found some interect point we clip the pattern to this point
if(nearestPointIntersect):
achieved = genPattern.clipPattern(nearestPointIntersect)
if(not achieved):
logging.error("No clipping achieved")
return None, previousTexture
else:
return None, previousTexture
# Now we have to ensure that the next texture is correct, because possibly the intersection
# is correct and the next texture in pattern direction is correct, but maybe the direction
# has changed due to the clipping of the pattern and the point clipped. The direction now is
# the direction between point clipped-intersected with next texture and the final point of
# the crack in prim.
# also, in the NORMAL case, maybe the pattern intersect with his texture, because are exiting
# from it, so we have to do a point in polygon to search what texture is the next
# Check texture, for do that get the vector direction and do it little and do a point in
# polygon with the texture
nextDir = GeoMath.vecSub(Fpoint, nearestPointIntersect)
logging.debug('next dir before', str(nextDir))
if(GeoMath.vecModul(nextDir) > 0):
nextDir = GeoMath.vecNormalize(nextDir)
# make it little, not more little than the epsilon used at GeoMath pointInSegmentDistance method,
# so we use a 10x bigger than epsilon, so 0.05
nextDir = GeoMath.vecScalarProduct(nextDir, 0.05)
nextPoint = GeoMath.vecPlus(nextDir, nearestPointIntersect)
nextTex = texture.findUpperTextureContainingPoint(nextPoint)
logging.debug('Direction and texture , next point: %s, next direction', str(nextPoint), str(nextDir))
else:
nextTex = None
# We get the final point, so we not have to ensure anything
logging.debug("End method checkTexture, class Crack")
if(nearestPointIntersect):
self.intersectionPoints.append(nearestPointIntersect)
return nearestPointIntersect, nextTex
示例8: findBestPatternDynamic
# 需要导入模块: from lib import GeoMath [as 别名]
# 或者: from lib.GeoMath import vecNormalize [as 别名]
def findBestPatternDynamic(self, curPoint, nextPoint, setClass, prim, patternCrack, tbn, tbnInverse, pointWhichIsRelative, texture, texturePrim):
'''
Get the best dynamic pattern
@param curPoint:
@type curPoint:
@param nextPoint:
@type nextPoint:
@param setClass:
@type setClass:
@param prim:
@type prim:
@param patternCrack:
@type patternCrack:
@param tbn:
@type tbn:
@param tbnInverse:
@type tbnInverse:
@param pointWhichIsRelative:
@type pointWhichIsRelative:
@param texture:
@type texture:
@param texturePrim:
@type texturePrim:
'''
logging.debug('Class AutoPattern, method findBestPatternDinamically')
logging.debug('cur_point: ' + str(curPoint) + "next_point: " + str(nextPoint))
# Direction of the crack
vector = GeoMath.vecSub(nextPoint, curPoint)
vector_rotated = tbnInverse.mulPoint3ToMatrix3(vector)
logging.debug("vector_rotated: " + str(vector_rotated))
# Number of attemps to try to find a good pattern
attempts = 2
# Get a pattern generated dynamically
# TODO: wavelength now only 0, but it can be any number
wavelenght = 0
first_point = [0, 0, 0]
# Calculate normal of pattern
direction = GeoMath.vecNormalize(GeoMath.vecSub(vector_rotated, first_point))
normal_of_pattern = GeoMath.vecCrossProduct(list(prim.normal()), direction)
pattern = setClass.getRandomPattern(wavelenght, first_point, vector_rotated, normal_of_pattern)
validatedPattern = self.validateAndAdjustPatterns(curPoint, nextPoint, setClass, prim, patternCrack, tbn, pointWhichIsRelative, texture, texturePrim, pattern)
if(not validatedPattern):
# Try 10 times variing random offset(seed) in the noise function to get a valid pattern
for _ in range(attempts):
pattern = setClass.getRandomPattern(wavelenght, first_point, vector_rotated, normal_of_pattern)
validatedPattern = self.validateAndAdjustPatterns(curPoint, nextPoint, setClass, prim, patternCrack, tbn, pointWhichIsRelative, texture, texturePrim, pattern)
if(validatedPattern):
break
if(not validatedPattern):
# Try "attemps" times varying the random offset(seed) of the noise funcion and do the height little to
# increase posibilities to get a valid pattern
height = setClass.getSizey() / 2
reduction_height = 2
for _ in range(attempts):
pattern = setClass.getRandomPattern(wavelenght, first_point, vector_rotated, normal_of_pattern, height)
validatedPattern = self.validateAndAdjustPatterns(curPoint, nextPoint, setClass, prim, patternCrack, tbn, pointWhichIsRelative, texture, texturePrim, pattern)
# Make the height half, for get more possibilities to do a good pattern
height = height / reduction_height
if(validatedPattern):
break
if(not validatedPattern):
# Apply the joker pattern!
vecH, vecV = DetermineVectors.DetermineVectors.detVec(prim, GeoMath.vecSub(nextPoint, curPoint), [0, 0, 1])
validatedPattern = setClass.applyJoker(curPoint, nextPoint, vecH, vecV)
logging.debug("End method finBestPatternDynamic, class Autopattern. State: Joker applied")
else:
logging.debug("End method finBestPatternDynamic, class Autopattern. State: good")
return validatedPattern
示例9: do
# 需要导入模块: from lib import GeoMath [as 别名]
# 或者: from lib.GeoMath import vecNormalize [as 别名]
def do(self, scale=False):
# Calcule points to tbn matrix
self.calculatePoints()
# Get some arbitrary vectors conected from vertices of prim
vec1 = GeoMath.vecSub(self.get_previous_point(), self.get_point_which_is_relative())
vec2 = GeoMath.vecSub(self.get_next_point(), self.get_point_which_is_relative())
# logging.debug('Two arbitrary vec1 and vec2:' + str(vec1) + ' ' + str(vec2))
# We have to know which angle reside between the two coencted vectors, to know if suposed vectors
# in tangent space will be correct
angle = GeoMath.vecDotProduct(vec1, vec2) / (GeoMath.vecModul(vec1) * GeoMath.vecModul(vec2))
angle = math.acos(angle)
angle = math.degrees(angle)
# logging.debug('Angle between vecs:' + str(angle))
# We put relative one arbitrary point to tangent space
# logging.debug('Point relative:' + str(self.get_point_which_is_relative()))
# Determine x and y vectors, now we'll have suposed horizontal and vertical vectors acording to
# prim and direction of the crack
hasTheNormalToY = GeoMath.vecDotProduct(list(self.get_prim().normal()), [0, 1, 0])
# logging.debug('Has the normal to y?:' + str(hasTheNormalToY))
if(hasTheNormalToY < (1 - epsilon) and hasTheNormalToY > (-1 + epsilon)):
vecH, vecV = DetermineVectors.DetermineVectors.detVec(self.get_prim(), [0, 1, 0], [0, 0, 1])
# logging.debug('Yes, it has the normal to y and vecs are:' + str(vecH) + ' ' + str(vecV))
else:
vecH, vecV = DetermineVectors.DetermineVectors.detVec(self.get_prim(), [0, 0, 1], [0, 0, 1])
# logging.debug('No, it isnt has the normal to y and vecs are:' + str(vecH) + ' ' + str(vecV))
# CHAPUZA CON NUMEROS COMPLEJOS!!! Precision de python pésima, 1.000000001>1?? no! y math.acos error
cosAngle = GeoMath.vecDotProduct(vecH, vec1) / (GeoMath.vecModul(vec1) * GeoMath.vecModul(vecH))
complexAngle = cmath.acos(cosAngle)
if(complexAngle.imag == 0):
angleBetweenDetVecAndVecH = math.acos(cosAngle)
else:
if(cosAngle < 0):
angleBetweenDetVecAndVecH = math.acos(-1)
else:
angleBetweenDetVecAndVecH = math.acos(1)
# Now we have to ensure that the vec1 has the same direction that the horizontal vector, if not, we
# change and the horizontal vector will be vec2. Also we have to check if the prim is not a quad,
# in this case we have to get the vertical vector from horizontal vector, rotating the known angle
# between the two vectors conected in prim (in quad we know that the angle is 90 and we already have the
# good vectors)
if((math.fabs(angleBetweenDetVecAndVecH) < epsilon) or (math.fabs(angleBetweenDetVecAndVecH) > (math.pi - epsilon))):
if(scale):
x = GeoMath.vecScalarProduct([1, 0, 0], GeoMath.vecModul(vec1))
x = [1, 0, 0]
y = GeoMath.rotateVecByVec(x, [0, 0, 1], angle)
if(scale):
y = GeoMath.vecScalarProduct(GeoMath.vecNormalize(y), GeoMath.vecModul(vec2))
tbn = GeoMath.createTBNmatrix(self.get_previous_point(), self.get_point_which_is_relative(), self.get_next_point(), x, [0, 0], y)
else:
if(scale):
x = [1, 0, 0]
y = GeoMath.rotateVecByVec(x, [0, 0, 1], angle)
if(scale):
y = GeoMath.vecScalarProduct(GeoMath.vecNormalize(y), GeoMath.vecModul(vec1))
tbn = GeoMath.createTBNmatrix(self.get_previous_point(), self.get_point_which_is_relative(), self.get_next_point(), y, [0, 0], x)
# logging.debug('tbn: ' + str(tbn.printAttributes()))
tbnInverse = GeoMath.Matrix(3, 3)
tbnInverse.copy(tbn)
tbnInverse.matrix3Inverse()
self.set_tbn(tbn)
self.set_tbn_inverse(tbnInverse)
示例10: defCrack
# 需要导入模块: from lib import GeoMath [as 别名]
# 或者: from lib.GeoMath import vecNormalize [as 别名]
def defCrack(self, prim, Ipoint, Fpoint, texturePrim):
reload(AutoPattern)
reload(Bresenham)
reload(Data)
reload(GeoMath)
reload(HouInterface)
global epsilon
global primnumber
# TEMP: only for debug the patterns
# Size x and size y is the valor of some material with the minor wavelength(bigger pattern)
curPoint = Ipoint
self.patternCrack[prim] = []
vertices = [list(p.point().position()) for p in prim.vertices()]
print "vertices"
print vertices
# Convert prim to tangent space of patterns
# Get some arbitrary vectors conected from vertices of prim
vec1 = GeoMath.vecSub(vertices[0], vertices[1])
vec2 = GeoMath.vecSub(vertices[2], vertices[1])
# We have to know which angle reside between the two coencted vectors, to know if suposed vectors
# in tangent space will be correct
angle = GeoMath.vecDotProduct(vec1, vec2) / (GeoMath.vecModul(vec1) * GeoMath.vecModul(vec2))
angle = math.acos(angle)
angle = math.degrees(angle)
# We put relative one arbitrary point to tangent space
pointWhichIsRelative = vertices[1]
# Determine x and y vectors, now we'll have suposed horizontal and vertical vectors acording to
# prim and direction of the crack
vecH, vecV = DetermineVectors.DetermineVectors.detVec(prim, GeoMath.vecSub(Ipoint, Fpoint), [0, 0, 1])
# CHAPUZA CON NUMEROS COMPLEJOS!!! Precision de python pésima, 1.000000001>1?? no! y math.acos error
cosAngle = GeoMath.vecDotProduct(vecH, vec1) / (GeoMath.vecModul(vec1) * GeoMath.vecModul(vecH))
complexAngle = cmath.acos(cosAngle)
if(complexAngle.imag == 0):
angleBetweenDetVecAndVecH = math.acos(cosAngle)
else:
if(cosAngle < 0):
angleBetweenDetVecAndVecH = math.acos(-1)
else:
angleBetweenDetVecAndVecH = math.acos(1)
#=======================================================================
# Now we have to ensure that the vec1 has the same direction that the horizontal vector, if not, we
# change and the horizontal vector will be vec2. Also we have to check if the prim is not a quad,
# in this case we have to get the vertical vector from horizontal vector, rotating the known angle
# between the two vectors conected in prim (in quad we know that the angle is 90 and we already have the
# good vectors)
#=======================================================================
print "Create TBN"
if((math.fabs(angleBetweenDetVecAndVecH) < epsilon) or (math.fabs(angleBetweenDetVecAndVecH) > (math.pi - epsilon))):
x = GeoMath.vecScalarProduct([1, 0, 0], GeoMath.vecModul(vec1))
y = GeoMath.rotateVecByVec(x, [0, 0, 1], angle)
y = GeoMath.vecScalarProduct(GeoMath.vecNormalize(y), GeoMath.vecModul(vec2))
tbn = GeoMath.createTBNmatrix(vertices[0], vertices[1], vertices[2], x, [0, 0], y)
else:
x = GeoMath.vecScalarProduct([1, 0, 0], GeoMath.vecModul(vec2))
y = GeoMath.rotateVecByVec(x, [0, 0, 1], angle)
y = GeoMath.vecScalarProduct(GeoMath.vecNormalize(y), GeoMath.vecModul(vec1))
tbn = GeoMath.createTBNmatrix(vertices[0], vertices[1], vertices[2], y, [0, 0], x)
print "Edn create tbn"
tbnInverse = GeoMath.Matrix(3, 3)
tbnInverse.copy(tbn)
tbnInverse.matrix3Inverse()
# Get the first material:
print "texture get first layer"
texture = texturePrim.getFirstLayer(Ipoint)
nextMaterial = texture.get_material()
print "end get material"
# Create status of the process to show to the user
distance_to_complete = GeoMath.vecModul(GeoMath.vecSub(curPoint, Fpoint))
ui_process_status = UIProcessStatus.UIProcessStatus('crack for prim',
distance_to_complete)
while(GeoMath.vecModul(GeoMath.vecSub(curPoint, Fpoint)) > epsilon):
# Print status of the process
dist = GeoMath.vecModul(GeoMath.vecSub(curPoint, Fpoint))
ui_process_status.calculate_status(dist, inverse=True)
ui_process_status.print_status()
genPattern = Data.GeneralPattern()
for wavelength in nextMaterial.mat.keys():
singleMat = nextMaterial.mat[wavelength]
setOfTypeOfPattern = CDF.cdf([[singleMat.classesAndPercentage[k], k] for k in singleMat.classesAndPercentage.keys()])
if(wavelength == 0):
nextPoint = Bresenham.Bresenham.bresenham(Ipoint, curPoint, Fpoint, setOfTypeOfPattern.getSizex(), setOfTypeOfPattern.getSizey(), prim, [1, 0, 0])
pat = AutoPattern.AutoPattern(curPoint, nextPoint, setOfTypeOfPattern, prim, wavelength, self.patternCrack, tbn, tbnInverse, pointWhichIsRelative, texture, texturePrim).pattern
genPattern.applyPattern(pat, wavelength)
# Check texture
previousTexture = texture
pii, texture = self.checkTexture(texturePrim, previousTexture, genPattern, Fpoint, nextPoint)
logging.debug('Pii defcrack: ' + str(pii))
logging.debug('CurPoint defcrack: ' + str(curPoint))
logging.debug('genPattern ' + str(genPattern.getPoints()))
'''
if(not curPoint):
curPoint=genPattern.getLastPoint()
#.........这里部分代码省略.........