hexagon logo

Find the closest node to a point

Hi everyone,
 
I am looking for a solution for finding the node of a mesh that is the closest node to a specific point.
Currently, my solution is to export the mesh and writing a specific small code in matlab for doing it but it is not very efficient.
 
Thank you in advance.
 
Best regards
Parents
  • The undocumented function has a documented version:
     
    sgm_get_close_points() you can find it in the docs; the tricky thing with this function is you need to call it twice (first time to find out how many points there are) Then you redim your array to receive the result.
     
    sys_free_array(close_pts)
    sys_free_array(pt_dist)
    sys_allocate_array(close_pts,1,1) /* needed to stop error messages from PCL function */
    sys_allocate_array(pt_dist,1,1) 
     
    sgm_get_close_points(point, tol, 1, 0, 1, nclose, close_pts, pt_dist) /* get num_only */
     
    IF (nclose == 0) THEN RETURN
    sys_reallocate_array(close_pts,1,nclose) /* now can make the proper array */
    sys_reallocate_array(pt_dist,1,nclose)
     
    sgm_get_close_points(point, tol, 0, 0, 1, nclose, close_pts, pt_dist) /* get all data */
     
     
Reply
  • The undocumented function has a documented version:
     
    sgm_get_close_points() you can find it in the docs; the tricky thing with this function is you need to call it twice (first time to find out how many points there are) Then you redim your array to receive the result.
     
    sys_free_array(close_pts)
    sys_free_array(pt_dist)
    sys_allocate_array(close_pts,1,1) /* needed to stop error messages from PCL function */
    sys_allocate_array(pt_dist,1,1) 
     
    sgm_get_close_points(point, tol, 1, 0, 1, nclose, close_pts, pt_dist) /* get num_only */
     
    IF (nclose == 0) THEN RETURN
    sys_reallocate_array(close_pts,1,nclose) /* now can make the proper array */
    sys_reallocate_array(pt_dist,1,nclose)
     
    sgm_get_close_points(point, tol, 0, 0, 1, nclose, close_pts, pt_dist) /* get all data */
     
     
Children
No Data