def addPegOutput(bevel, endZ, outputs, radiusArealized, sides, start, topOverBottom):
 height = abs((start.z - endZ))
 bevelStartRatio = max((1.0 - (bevel / height)), 0.5)
 oneMinusBevelStartRatio = (1.0 - bevelStartRatio)
 trunkEndZ = ((bevelStartRatio * endZ) + (oneMinusBevelStartRatio * start.z))
 trunkTopOverBottom = ((bevelStartRatio * topOverBottom) + oneMinusBevelStartRatio)
 cylinder.addCylinderOutputByEndStart(trunkEndZ, radiusArealized, outputs, sides, start, trunkTopOverBottom)
 capRadius = (radiusArealized * trunkTopOverBottom)
 capStart = ((bevelStartRatio * Vector3(start.x, start.y, endZ)) + (oneMinusBevelStartRatio * start))
 radiusMaximum = max(radiusArealized.real, radiusArealized.imag)
 endRadiusMaximum = ((radiusMaximum * topOverBottom) - bevel)
 trunkRadiusMaximum = (radiusMaximum * trunkTopOverBottom)
 capTopOverBottom = (endRadiusMaximum / trunkRadiusMaximum)
 cylinder.addCylinderOutputByEndStart(endZ, capRadius, outputs, sides, capStart, capTopOverBottom)

def addPegOutput ( bevel , endZ , outputs , radiusArealized , sides , start , topOverBottom ) : height = abs ( ( start . z - endZ ) ) bevelStartRatio = max ( ( 1.0 - ( bevel / height ) ) , 0.5 ) oneMinusBevelStartRatio = ( 1.0 - bevelStartRatio ) trunkEndZ = ( ( bevelStartRatio * endZ ) + ( oneMinusBevelStartRatio * start . z ) ) trunkTopOverBottom = ( ( bevelStartRatio * topOverBottom ) + oneMinusBevelStartRatio ) cylinder . addCylinderOutputByEndStart ( trunkEndZ , radiusArealized , outputs , sides , start , trunkTopOverBottom ) capRadius = ( radiusArealized * trunkTopOverBottom ) capStart = ( ( bevelStartRatio * Vector3 ( start . x , start . y , endZ ) ) + ( oneMinusBevelStartRatio * start ) ) radiusMaximum = max ( radiusArealized . real , radiusArealized . imag ) endRadiusMaximum = ( ( radiusMaximum * topOverBottom ) - bevel ) trunkRadiusMaximum = ( radiusMaximum * trunkTopOverBottom ) capTopOverBottom = ( endRadiusMaximum / trunkRadiusMaximum ) cylinder . addCylinderOutputByEndStart ( endZ , capRadius , outputs , sides , capStart , capTopOverBottom )
add beveled cylinder to outputs given bevel .