title: How to rotate 1D piecewise function around Y axis in Python
body: <p>I have a 1D piecewise shape which looks like a rectangular with smooth edges (quarter circles):</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt 
  
  def piecewise(x, r, d, h):
      if  -d/2 &lt;= x &lt;= - d/2 + r or d/2- r &lt;= x &lt;= d/2:
          return np.sqrt(r**2-(x-np.sign(x)*d/2+np.sign(x)*r)**2)+r+(h-2*r)
      elif -d/2 - r &lt;= x &lt;= -d/2 or d/2 &lt;= x &lt;=  d/2 + r:
          return -np.sqrt(r**2-(x- np.sign(x)*d/2-np.sign(x)*r)**2)+r
      elif - d / 2 + r &lt; x &lt; d / 2 - r:
          return 2*r+(h-2*r)
      return 0.0
  
  vpiecewise = np.vectorize(piecewise)
  
  x = np.linspace(-20, 20, 10000)
  z = vpiecewise(x, 4, 20, 10)
  
  plt.plot(x, z, '-')
  plt.show()
  </code></pre>
  
  <p>I would like to rotate it around Y-axis which is its centre to get a cyllinder with smoothed out edges. Is there a way to do it in Python? </p>