title: Creating a numpy array of 3D coordinates from three 1D arrays
body: <p>Suppose I have three arbitrary 1D arrays, for example:</p>
  
  <pre><code>x_p = np.array((1.0, 2.0, 3.0, 4.0, 5.0))
  y_p = np.array((2.0, 3.0, 4.0))
  z_p = np.array((8.0, 9.0))
  </code></pre>
  
  <p>These three arrays represent sampling intervals in a 3D grid, and I want to construct a 1D array of three-dimensional vectors for all intersections, something like</p>
  
  <pre><code>points = np.array([[1.0, 2.0, 8.0],
                     [1.0, 2.0, 9.0],
                     [1.0, 3.0, 8.0],
                     ...
                     [5.0, 4.0, 9.0]])
  </code></pre>
  
  <p>Order doesn't actually matter for this. The obvious way to generate them:</p>
  
  <pre><code>npoints = len(x_p) * len(y_p) * len(z_p)
  points = np.zeros((npoints, 3))
  i = 0
  for x in x_p:
      for y in y_p:
          for z in z_p:
              points[i, :] = (x, y, z)
              i += 1
  </code></pre>
  
  <p>So the question is... is there a faster way? I have looked but not found (possibly just failed to find the right Google keywords).</p>
  
  <p>I am currently using this:</p>
  
  <pre><code>npoints = len(x_p) * len(y_p) * len(z_p)
  points = np.zeros((npoints, 3))
  i = 0
  nz = len(z_p)
  for x in x_p:
      for y in y_p:
          points[i:i+nz, 0] = x
          points[i:i+nz, 1] = y
          points[i:i+nz, 2] = z_p
          i += nz
  </code></pre>
  
  <p>but I feel like I am missing some clever fancy Numpy way?</p>