本文整理汇总了Python中Vector.x方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.x方法的具体用法?Python Vector.x怎么用?Python Vector.x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector
的用法示例。
在下文中一共展示了Vector.x方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createDendrites
# 需要导入模块: import Vector [as 别名]
# 或者: from Vector import x [as 别名]
def createDendrites(self):
angle = 360.0/self.branches
startDist = 0.95 * self.somaSize
endDist = startDist + self.stepDist
halfThickness = self.dendriteThickness/2.0
a = 0.0
while a<360.0:
# Define the points that the dendrite would follow if it were a line (i.e. no thickness)
initialResources = self.maxRadius
p1, p2 = Vector(), Vector()
p1.x = m.cos(m.radians(a)) * startDist + self.center.x
p1.y = m.sin(m.radians(a)) * startDist + self.center.y
p2.x = m.cos(m.radians(a)) * endDist + self.center.x
p2.y = m.sin(m.radians(a)) * endDist + self.center.y
remainingResources = initialResources - p1.distance(p2)
# Find the first and last vertex of the quad (moving perpendicular from p1 to create thickness)
t = p1 - self.center
leftPerp = t.leftXYPerpendicular().normalize()
rightPerp = t.rightXYPerpendicular().normalize()
v1 = leftPerp * halfThickness + p1
v4 = rightPerp * halfThickness + p1
# Find the second and third vertex of the quad (moving perpendicular from p2 to create thickness)
t = p2 - p1
leftPerp = t.leftXYPerpendicular().normalize()
rightPerp = t.rightXYPerpendicular().normalize()
v2 = leftPerp * halfThickness + p2
v3 = rightPerp * halfThickness + p2
# Find the vertex index of the newly added vertices
startVertexNumber = len(self.verts)
v1Number = startVertexNumber
v2Number = startVertexNumber + 1
v3Number = startVertexNumber + 2
v4Number = startVertexNumber + 3
# Add the vertices
self.verts = self.verts + [v1.toList(), v2.toList(), v3.toList(), v4.toList()]
# Add a properly ordered face
face = self.createOrderedQuad(v1, v2, v3, v4, v1Number, v2Number, v3Number, v4Number)
self.faces.append(face)
# Store some information about the current dendrite branch
self.dendrites.append([[a,initialResources,p1,[v1,v1Number],[v4,v4Number]],
[a,remainingResources,p2,[v2,v2Number],[v3,v3Number]]])
self.lineSegments.append([p1, (p1+p2)/2.0, p2])
self.updateRadius(v1, v2, v3, v4)
a += angle
示例2: growDendrite
# 需要导入模块: import Vector [as 别名]
# 或者: from Vector import x [as 别名]
def growDendrite(self, i):
dendrite = self.dendrites[i]
step = self.stepDist
halfThickness = self.dendriteThickness/2.0
# Load this dendrite's information
heading = dendrite[-1][0]
resources = dendrite[-1][1]
p1 = dendrite[-1][2]
v1, v1Number = dendrite[-1][3]
v4, v4Number = dendrite[-1][4]
thickness = resources/self.maxRadius * (self.dendriteThickness - self.minDendriteThickness) + self.minDendriteThickness
halfThickness = thickness / 2.0
# Generate a random heading in order to create p2
heading += r.uniform(-self.headingRange, self.headingRange)
p2 = Vector()
p2.x = p1.x + m.cos(m.radians(heading)) * step
p2.y = p1.y + m.sin(m.radians(heading)) * step
resources = resources - p1.distance(p2)
# Calculate the new vertices of the quad (adding thickness)
t = p2 - p1
leftPerp = t.leftXYPerpendicular().normalize()
rightPerp = t.rightXYPerpendicular().normalize()
v2 = leftPerp * halfThickness + p2
v3 = rightPerp * halfThickness + p2
# Find the vertex index of the newly added vertices
startVertexNumber = len(self.verts)
v2Number = startVertexNumber
v3Number = startVertexNumber + 1
# Add the vertices
self.verts = self.verts + [v2.toList(), v3.toList()]
# Add a properly ordered face
face = self.createOrderedQuad(v1, v2, v3, v4, v1Number, v2Number, v3Number, v4Number)
self.faces.append(face)
# Store some information about the current dendrite branch
self.dendrites[i].append([heading, resources, p2, [v2,v2Number], [v3,v3Number]])
self.lineSegments.append([p1, (p1+p2)/2.0, p2])
self.updateRadius(v1, v2, v3, v4)