def addEndCap(begin, end, points, radius):
 beginMinusEnd = (begin - end)
 beginMinusEndLength = abs(beginMinusEnd)
 if (beginMinusEndLength <= 0.0):
  points.append(begin)
  return
 beginMinusEnd *= (radius / beginMinusEndLength)
 perpendicular = complex((- beginMinusEnd.imag), beginMinusEnd.real)
 numberOfSides = 20
 numberOfPositiveSides = (numberOfSides / 2)
 totalAngle = 0.0
 angle = (euclidean.globalTau / float(numberOfSides))
 dotProductMultiplier = (2.0 - (1.0 / math.cos((0.5 * angle))))
 for sideIndex in xrange((numberOfPositiveSides + 1)):
  circumferentialPoint = ((math.sin(totalAngle) * beginMinusEnd) + (math.cos(totalAngle) * perpendicular))
  points.append((begin + (circumferentialPoint * dotProductMultiplier)))
  totalAngle += angle

def addEndCap ( begin , end , points , radius ) : beginMinusEnd = ( begin - end ) beginMinusEndLength = abs ( beginMinusEnd ) if ( beginMinusEndLength <= 0.0 ) : points . append ( begin ) return beginMinusEnd *= ( radius / beginMinusEndLength ) perpendicular = complex ( ( - beginMinusEnd . imag ) , beginMinusEnd . real ) numberOfSides = 20 numberOfPositiveSides = ( numberOfSides / 2 ) totalAngle = 0.0 angle = ( euclidean . globalTau / float ( numberOfSides ) ) dotProductMultiplier = ( 2.0 - ( 1.0 / math . cos ( ( 0.5 * angle ) ) ) ) for sideIndex in xrange ( ( numberOfPositiveSides + 1 ) ) : circumferentialPoint = ( ( math . sin ( totalAngle ) * beginMinusEnd ) + ( math . cos ( totalAngle ) * perpendicular ) ) points . append ( ( begin + ( circumferentialPoint * dotProductMultiplier ) ) ) totalAngle += angle
get a pair of side points .