PDA

View Full Version : Closest CV to a point on a nurbs surface


Andimation
04-02-2009, 09:52 PM
Hey

I have the need to find the closest CV on a nurbs surface to a point on the surface. I am using the Maya API (MPxNurbsSurface) to get a point on the surface, as well as the U&V value of that point. Now I want an efficient way to find the nearest CV, without having to iterate over every CV and do a distance check.

Was wondering if anyone knows a better way?

Thanks

Andy

cbamber85
04-06-2009, 01:31 AM
How could Maya or your algorithm know which is the nearest CV without querying every one?

sirpalee
04-06-2009, 09:07 AM
The only way, if you use some space partitioning algorithm, like BIH or KDTree, but you need to build that manually.

Robert Bateman
04-06-2009, 11:26 AM
Was wondering if anyone knows a better way?

Yes, you can take the U/V coord, then query that against the knot vectors for U and V to determine the curve span in which the UV coord lies, and then determine which control points are used. That would limit you to checking (degreeU+1)*(degreeV+1) CV's. Of course, that wouldn't tell you which CV is closest since the surface can bend around on itself and there may be another CV that is closer than those used for the patch you are looking at. You might as well test every single CV - it's not going to be any slower....

CGTalk Moderation
04-06-2009, 11:26 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.