Closest points on two curves and snapping them together


#1

I have two curves, A and B. Is there a way to find the closet points on the curves: Point on A and Point on B?
I’d like to then snap the curves together at these points by either moving A to B or B to A or meet in the middle, being able to specify blending length for both.

I don’t imagine there is a function for this already, but maybe someone has already scripted something like this? If not, I am going to try to script something and would appreciate any tips.

Thanks,
Sam


(Dale Fugier) #2

Use Rhino.Geometry.Curve.ClosestPoints.


#3

OK, I see it,
As far as snapping the curves together, soft curve edit would do the job, but I don’t see anything like that in the Rhino Namespace (I am using RhinoCommon). Am I missing it? Otherwise I will just script the rhino command.

Thanks,
Sam


#4

If you want to define a deformation radius for the curves, you will at least need to rebuild the curves to have enough CP’s inside the radius to let the rest of the curve stay put.

This is what I know from Grasshopper. Since Grasshopper is closely related to RhinoCommon, all the geometry stuff should be available in RhinoCommon but I’m not 100% sure.

You can interpolate curves through points and you can blend two curves. Either, or. You will need to between two curve segments but interpolate through a third point.
I ended up building my own position/tangent blend curve based on how I think Rhino does it.

So… you can either use this GH definition or script your own.

snap curves.gh (15.4 KB)


#5

HaLo’s definitions does the job pretty nicely.
RhinoCommon’s Rhino.Geometry.Curve.CreateInterpolatedCurve method will replace the Grasshopper’s “interpolate” component.
Split.Curve will replace “shatter”.


#6

Thanks guys,

I like the soft edit approach where controls points within a radius are moved to (blended), rather than interpolate or blend two curves. Does anyone know if there is any functionality in Rhinocommon for soft moving within a radius?

On a totally different note, does anyone know why emails sometimes don’t get sent out to notify of a response to a post? I think this is the case when I’m logged into the community. But just because I’m logged in doesn’t mean I’m checking. It would be nice to always get the email. Maybe I should be posting this question in it’s own thread…

Thanks,
Sam


#7

Not actually using interpolate. Just use a set of points as CPs for a NURBS curve.
Logic is pretty straight forward:

  • to match a certain tangency at the end of a NURBS curve, you string at least as many CPs as degree-1 in a straight row along the intended tangent vector.
  • for any given degree, the center of degree numbers of CPs in a straight line, will match the line.

So I extend one CP from the ends along the tangency vectors. I move the center of the minimal connection using the tangents of the curves at the closest points to approximate the original shape.
That’s two points at the ends for tangent and three at the intersection for position. The distance of the created points to their originals determines the blend shape.


#8

In order to make soft editing feasible, you need to make sure that at least twice the curves degree are within radius. that’s the only way to leave the curve outside intact. That might either require to rebuild the whole curve or at least the part within the edit radius. At that point someone with more math background needs to take over. I have no idea how to best move arbitrary CP positions to match a given point and two endpoints.


#9

OK, got a few other things to work on first, but I’ll give it a shot!

Thanks all for your help,
Sam