- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Fast(er) method to get closest point on face/entit y
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-29-2012 06:51 AM
Hi
I am using the function "api_find_cls_ptto_face" to find the closest point on a FACE to a point in space (close to the face).
Unfortunately, it is not fast enough for my application.
Is there any faster way to get the closest point (even inexact)?
Thanks for any suggestions
Bryn
Re: Fast(er) method to get closest point on face/entit y
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
06-29-2012 07:54 AM
Hi Bryn
I have worked some with the model inspection APIs and I would recommend at least trying api_entity_point_distance.
It is usually easlier to optimize high level workflows then single API calls. If you are able to describe some context, that might make it easier for others to suggest a workable solution.
best regards
Eric Zenk
Re: Fast(er) method to get closest point on face/entit y
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
07-01-2012 01:45 PM
Hi Eric
Thanks for the suggestion. I am working a mesh smoothing algorithm, where the points should stay on the entity faces.
If I do the smoothing in 3d space I should move the point back to the face. Currently, it is only possible to move single points (api_entity_point_distance is slower for single points).
I tried following alternative api:
void surface::point_perp(...), i.e. for a face
face->geometry()->equation().point_perp(..)
This sometimes gives me different results, but is quite a bit faster. Can you tell me what the difference between these approaches is?
Thanks
Bryn
Re: Fast(er) method to get closest point on face/entit y
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
07-01-2012 06:39 PM
Hi Bryn
There are a couple of differences. surface::point_perp is lower level functionality. Given a point P and surface S, the local extrema of the distance function from P to S satisfy the "point perp" condition: specifically, the vector between P and a closest point on S forms a diameter of a sphere which is tangent to the surface.
There are two flavors of point_perp: each does less than api_entity_point_distance. Entity point distance finds a global minimum of the distance function and makes sure it is inside the face (not just on the surface of the face, it is inside the trimming curves).
surface::point_perp with a guess of the closest point does a relaxation (roughly like Newton's method) to find a local minimum of the distance function. point_perp without a guess checks all over the surface and finds a global minimum of the distance between the point and the surface. Neither point perp flavor knows about the trimming of the faces/edges, or anything at all about the body.
If you know something about an existing mesh, it might be possible to use that information along with one of the point perp functions. Given an arbitrary point in space, you could
- find the closest point on a triangle in your mesh
- compute the barycentric coordinates of the closest point
- use the barycentric coordinates and the uvs of the mesh points to get a reasonable guess for point perp.
If you are able to verify independantly that the foot (closest point on the surface) you find is in the face of interest, this can be much faster. e.g., if the foot is inside a triangle you can verify is in the face, you should be done.
The downside with using lower level functionality is that it offers less guarantees about the answer. Journalling isn't avialable either. But it provides another approach if the API doesn't do what you need. The lower level functionality does less but is faster than the API. I hope this helps.
Eric
Re: Fast(er) method to get closest point on face/entit y
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
07-01-2012 11:32 PM
Hi Eric
Thanks for the great answer!
Cheers
Bryn

