title: Render image on the surface with Mayavi and Python
body: <p>I am trying to create visualization with use of Python and Mayavi.<br>
  The purpose of that visualization is to show a trajectory and camera frustums at different stages of the path. </p>
  
  <p><a href="https://i.stack.imgur.com/IPVBB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IPVBB.png" alt="Rended_screenshot"></a>
  The thing I struggle with is to texturize camera frustum polygons with an actual images.</p>
  
  <p>I am willing to put performance considerations aside for now, and want to find a way to texture a mayavi-created surface with an image provided by numpy.</p>
  
  <p>The most promising suggestions were found <a href="https://stackoverflow.com/questions/24107084/mayavi-texture-to-span-over-full-surface?rq=1">there</a>, yet I was unable to construct a surface as I implemented them.</p>
  
  <pre><code>def render_image(self, frustum, timestamp):
          surf = mayavi.mlab.surf(frustum[0, :-1],
                                  frustum[1, :-1],
                                  frustum[2, :-1],
                                  color = (1.0, 1.0, 1.0))
  </code></pre>
  
  <p>That's the code for surface creation, where rows of the numpy array frustum are x, y, z coordinates respectively and the last, fifth point is the tip of pyramid and hence not needed for mesh.</p>
  
  <pre><code>x [-8.717184671492793, -8.623419637172622, -8.363581977642212, -8.269816943322041]
  y [-4.563044562134721, -4.941612408713827, -4.37100415350352, -4.749572000082626]
  z [13.614485323873417, 13.703336344550703, 14.059553426925493, 14.148404447602779]
  </code></pre>
  
  <p>That is an example of function input - four 3D points representing vertices of a desired polygon.</p>
  
  <p>Yet, the surf function fails on that input:</p>
  
  <pre><code>File "/usr/local/lib/python2.7/dist-packages/mayavi/tools/helper_functions.py", line 679, in __call_internal__
      aspect_ratios = [(zf - zi) / (xf - xi), (zf - zi) / (yf - yi)]
  ZeroDivisionError: float division by zero
  </code></pre>
  
  <p><strong>Note:</strong> I was able to render images with mayavi.mlab.imshow, but I find it error-prone and onerous to specify image pose and size in terms of axis angles and scale vectors, so I'm reluctant to accept answers pointing to that direction.</p>
  
  <p>Your help is greatly appreciated.</p>