Grasshopper

algorithmic modeling for Rhino

I'm trying to find the points on two curves (crvA and crvB) that are the closest to each other. The method "Curve.GetClosestPoints" is supposed to do give me those points.

But when I call:

crvA.getClosestPoints(crvB, pointOnA, pointOnB)

I get an error message saying: 'getClosestPoints' is not a member of 'Rhino.Geometry.Curve'
Can someone tell me what I'm doing wrong here?

Thnx, Jack

Views: 382

Replies to This Discussion

Hi Jack,

this method is only available in when running Grasshopper in Rhino5. The method should have been commented out in Rhino4.

Sorry for the confusion,
David

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi David,

Thanks for the quick reply, pity the method isn't available yet. Could you point me to an alternative, other than iteratively finding an optimum?

Jack
Nope, the method is missing entirely from the Rhino4 SDK. There's quite a lot of code to it so writing one yourself isn't trivial.

If you don't care much for speed, you could try to just sample one curve at SpanCount * 10 intervals. Find the two closest points to curve B, then sample in between these two points with 10 smaller steps. Then find the two best results, and sample in between those with 10 smaller steps. And so on and so forth until your stepsize is less than the accuracy you desire.

I think this algorithm only really works well on not too funky inputs though.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks, I programmed some relaxation/cloth code that I could misuse to 'string a rubber band' between the curves. That would end up at the points of least distance. But like you said, it is going to be very slow and will get stuck in local minima if the curve is a bit funky.

I'll work around it while waiting for Rhino5....
I wrote a small VB script with my proposed method. It might help you out.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Attachments:
Thanks a lot David, that's more than I bargained for.
I tried this function in Rhino5,but also get the same error message,so?

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service