title: How to draw a curve in Cartesian coordinates in a semicircle tube in polar coordinates?
body: <pre><code>import numpy as np
  import matplotlib.pylab as plt
  
  def tube():
      theta = np.linspace(0, np.pi/2, 30)
  
      x = np.cos(theta)
      y = np.sin(theta)
      z = x*0.8
      w = y*0.8
  
      plt.plot(z,w)
      plt.plot(x,y)
      plt.axis("equal")
      plt.show()
  
  print plt.figure(1);tube()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/rX6cZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rX6cZ.png" alt="enter image description here"></a></p>
  
  <pre><code>def euler():
      A, B, a = 40, 10, 2
  
      t  = 10  # time
      dt = 1e-3 # interval
  
      nbpt = int(t/dt)
  
      n = 1
      s = 1. # sign of the derivative, initially chosen
      y = [0]*nbpt # result
  
      while n &lt; nbpt:
          yp2 = B - A*y[n-1]**a
          if yp2 &lt; 0:
              s = -s
              n -= 1 # recalculating the previous value
          else:
              y[n] = y[n-1] + dt*s*np.sqrt(yp2)
              n += 1
  
      plt.plot(np.linspace(0,t,nbpt),y)
      plt.show()
  
  print plt.figure(2);euler()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/OeuV0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OeuV0.png" alt="enter image description here"></a></p>
  
  <p>I want to draw the curve made with <code>euler()</code> in the tube made with <code>tube()</code>. I guess I must go from cartesian coordinates to polar coordinates but is there anyway to make the process easier with Python ?</p>