本文整理汇总了Python中lib.GeoMath.createTBNmatrix方法的典型用法代码示例。如果您正苦于以下问题:Python GeoMath.createTBNmatrix方法的具体用法?Python GeoMath.createTBNmatrix怎么用?Python GeoMath.createTBNmatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.GeoMath
的用法示例。
在下文中一共展示了GeoMath.createTBNmatrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do
# 需要导入模块: from lib import GeoMath [as 别名]
# 或者: from lib.GeoMath import createTBNmatrix [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)
示例2: defCrack
# 需要导入模块: from lib import GeoMath [as 别名]
# 或者: from lib.GeoMath import createTBNmatrix [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()
#.........这里部分代码省略.........