当前位置: 首页>>代码示例>>Python>>正文


Python Vector.copyVector方法代码示例

本文整理汇总了Python中Vector.copyVector方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.copyVector方法的具体用法?Python Vector.copyVector怎么用?Python Vector.copyVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vector的用法示例。


在下文中一共展示了Vector.copyVector方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import Vector [as 别名]
# 或者: from Vector import copyVector [as 别名]
class DendriteTip:
    def __init__(heading, headingRange, stepSize, resources, maxResources,
                 startThickness, endThickness, startPosition,
                 cellCenter, neuron):

        self.heading        = heading
        self.headingRange   = headingRange
        self.stepSize       = stepSize
        self.resources      = resources
        self.maxResources   = maxResources
        self.startThickness = startThickness
        self.endThickness   = endThickness
        self.cellCenter     = cellCenter
        self.neuron         = neuron

        self.p1 = startPosition
        self.p2 = None
        self.v1 = None
        self.v2 = None
        self.v3 = None
        self.v4 = None

        self.growing = True

        self.points     = []
        self.vertices   = []

    def isGrowing(self):
        return self.growing

    def grow(self, stepSize=None, heading=None, headingRange=None):
        if self.growing:
            if heading==None:       heading         = self.heading
            if headingRange==None:  headingRange    = self.headingRange
            if stepSize==None:      stepSize        = self.stepSize

            if self.p2 == None:
                initializeGrowth(stepSize, heading, headingRange)
            else:
                regularGrowth(stepSize, heading, headingRange)

    def initializeGrowth(self, stepSize, heading, headingRange):        
        self.p2     = Vector()
        self.p2.x   = m.cos(m.radians(heading)) * stepSize + self.p1.x
        self.p2.y   = m.sin(m.radians(heading)) * stepSize + self.p1.y
        
        thickness = (self.resources/self.maxResources) * (self.startThickness - self.endThickness) + self.endThickness
        halfThickness = thickness / 2.0

        t           = self.p1 - self.cellCenter
        leftPerp    = t.leftXYPerpendicular().normalize()
        rightPerp   = t.rightXYPerpendicular().normalize()
        self.v1     = leftPerp * halfThickness + self.p1
        self.v4     = rightPerp * halfThickness + self.p1

        t           = self.p2 - self.p1
        leftPerp    = t.leftXYPerpendicular().normalize()
        rightPerp   = t.rightXYPerpendicular().normalize()
        self.v2     = leftPerp * halfThickness + self.p2
        self.v3     = rightPerp * halfThickness + self.p2

        self.vertices   = self.vertices + [self.v1] + [self.v2] + [self.v3] + [self.v4]
        self.points     = self.points + [self.p1] + [self.p2]
        
        self.resources -= stepSize
        if self.resources <= 0: self.growing = False


    def regularGrowth(self, stepSize=None, heading=None, headingRange=None):
        # Start growing from the last dendrite points (deep copies)
        self.p1 = self.p2.copyVector()
        self.v1 = self.v2.copyVector()
        self.v4 = self.v3.copyVector()

        # Unlink any references that exist
        self.p2 = Vector()
        self.v2 = Vector()
        self.v3 = Vector()
        
        # Map the resources remaining into the range of thickness values to obtain the current thickness
        thickness       = remap(self.resources, 0.0, self.maxResources, self.startThickness, self.endThickness)
        halfThickness   = thickness / 2.0

        # Generate a random heading
        heading += r.uniform(-self.headingRange, self.headingRange)

        # Find p2 by moving in the heading direction
        self.p2.x = self.p1.x + m.cos(m.radians(heading)) * stepSize
        self.p2.y = self.p1.y + m.sin(m.radians(heading)) * stepSize

        # Calculate the new vertices of the quad (adding thickness relative to p2)
        t           = self.p2 - self.p1
        leftPerp    = t.leftXYPerpendicular().normalize()
        rightPerp   = t.rightXYPerpendicular().normalize()
        self.v2     = leftPerp * halfThickness + self.p2
        self.v3     = rightPerp * halfThickness + self.p2

        # Store the new vertices and the new point
        self.vertices   = self.vertices + [self.v2] + [self.v3]
        self.points     = self.points + [self.p2]
#.........这里部分代码省略.........
开发者ID:mikewesthad,项目名称:LitWithinBlender,代码行数:103,代码来源:BranchTip.py


注:本文中的Vector.copyVector方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。