View Full Version : Closest point on surface
09-29-2004, 09:55 AM
Does anyone know if there is a meshOps command or similar for finding the closest point on a surface based on a point in space?
I could write it myself in maxscript but it would be very slow so it would be great if there was a script command that could handle it.
09-29-2004, 03:30 PM
I Don't think that exists.
But it's simple to do
Take a look at meshop.getElementsUsingFace
Then for in loop inside the vertex list and to calculate the distance.
Keep the min distance.
09-29-2004, 06:03 PM
this should work, no evaluation in notepad!
fn findTheClosestPoint pointX obj =
local posArr = #()
for i = 1 to (polyOp.getNumFaces obj) do
local vPos = polyOp.getVert obj
append posArr vPos
local sPosArr = #()
for i in posArr do
local distX = distance pointX i
append sPosArr distX
local minDistance = amin sPosArr
local minVert = findItem sPosArr (minDistance)
09-30-2004, 01:52 PM
If I understand you correctly, you want the distance to the closest point on the surface, not just the closest vertex. Unfortunately, Maxscript offers no built-in function to accomplish this. If you're going to go about the task of calculating it "the hard way," I would suggest looking into rayMeshGridIntersect or John Burnett's fooLib for functions that might help optimize the search for the closest point (i.e. limiting the search to include only the closest faces).
01-19-2006, 09:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.