def addPeg(bevel, endZ, outputs, radius, start, topOverBottom, xmlElement): 'Add beveled cylinder to outputs given bevel, endZ, radius and start.' 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 sides = evaluate.getSidesMinimumThreeBasedOnPrecision(max(radius.real, radius.imag), xmlElement ) outputs.append(cylinder.getGeometryOutputByEndStart(trunkEndZ, radius, sides, start, trunkTopOverBottom, xmlElement)) capRadius = radius * trunkTopOverBottom capStart = bevelStartRatio * Vector3(start.x, start.y, endZ) + oneMinusBevelStartRatio * start radiusMaximum = max(radius.real, radius.imag) endRadiusMaximum = radiusMaximum * topOverBottom - bevel trunkRadiusMaximum = radiusMaximum * trunkTopOverBottom capTopOverBottom = endRadiusMaximum / trunkRadiusMaximum outputs.append(cylinder.getGeometryOutputByEndStart(endZ, capRadius, sides, capStart, capTopOverBottom, xmlElement))
def addNegativePeg(derivation, negatives, x, y): 'Add negative cylinder at x and y.' negativePegRadius = derivation.pegRadius + derivation.halfPegClearance inradius = complex(negativePegRadius, negativePegRadius) copyShallow = derivation.xmlElement.getCopyShallow() start = Vector3(x, y, derivation.height) cylinderOutput = cylinder.getGeometryOutputByEndStart(0.0, inradius, start, derivation.topOverBottom, copyShallow) negatives.append(cylinderOutput)
def addNegativePeg(derivation, negatives, x, y): 'Add negative cylinder at x and y.' negativePegRadius = derivation.pegRadius + derivation.halfPegClearance inradius = complex(negativePegRadius, negativePegRadius) copyShallow = derivation.xmlElement.getCopyShallow() start = Vector3(x, y, derivation.height) cylinderOutput = cylinder.getGeometryOutputByEndStart( 0.0, inradius, start, derivation.topOverBottom, copyShallow) negatives.append(cylinderOutput)
def addPeg(bevel, endZ, outputs, radius, start, topOverBottom, xmlElement): 'Add beveled cylinder to outputs given bevel, endZ, radius and start.' 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 sides = evaluate.getSidesMinimumThreeBasedOnPrecision( max(radius.real, radius.imag), xmlElement) outputs.append( cylinder.getGeometryOutputByEndStart(trunkEndZ, radius, sides, start, trunkTopOverBottom, xmlElement)) capRadius = radius * trunkTopOverBottom capStart = bevelStartRatio * Vector3( start.x, start.y, endZ) + oneMinusBevelStartRatio * start radiusMaximum = max(radius.real, radius.imag) endRadiusMaximum = radiusMaximum * topOverBottom - bevel trunkRadiusMaximum = radiusMaximum * trunkTopOverBottom capTopOverBottom = endRadiusMaximum / trunkRadiusMaximum outputs.append( cylinder.getGeometryOutputByEndStart(endZ, capRadius, sides, capStart, capTopOverBottom, xmlElement))