title: Closest point projection of a 3D point to 3D triangles with numpy/scipy
body: <p>How would one calculate the closest projections of a point to N triangles using numpy/scipy?</p>
  
  <p>Right now I would make a function to calculate a projection to a single triangle, <a href="http://www.gamedev.net/topic/552906-closest-point-on-triangle/" rel="nofollow noreferrer">basically this</a>, then iterate across the entire array of triangles. But before I set off to do this I was wondering if there's already a solution built in scipy. Something like:</p>
  
  <pre><code># DREAMY PSEUDOCODE
  import numpy as np
  N_TRIANGLES = 1000
  
  point = np.random.rand(3) * 100 #random 3d point
  triangles = np.random.rand(N_TRIANGLES,3,3) * 100 #array of triangles
  
  from scipy.spatial import pointToTriangles
  projections = pointToTriangles(point,triangles)
  </code></pre>
  
  <p>Here's a picture to help you visualize:</p>
  
  <p><a href="https://i.stack.imgur.com/zvyms.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zvyms.png" alt="example of point projection"></a></p>
  
  <p>In the image above, the red dot in the middle is my query "point", the blue dots are the vertices of each triangles as define in the "triangles" np.array(). The green dots represent the result i want. They're the closest projections of "point" onto the defined triangles, and i wish to get this info back as an array of points.</p>
  
  <p>cheers!</p>