Grasshopper

algorithmic modeling for Rhino

Hi:

Given two closed curves of different shapes, vertically displaced from each other (like contour lines on a terrain map) how would I drop lines from points on one curve to the closest points on the other?

 

The first line may be divided into some arbitrary number of points.  Obviously if we divide the second curve into the same number of points and then span with polylines the end points will not necessarily be the optimal closest points.

Views: 12999

Replies to This Discussion

Hi Al,

 

you need to use the CurveCP (Curve Closest Point) component for this. There's no way to find the smallest distance between two curves, but from a point to a curve is easy.

 

Alternatively you can use the PullPoint component which works with non-curve geometry as well.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks Dave:  I had in the last few minutes played with closest point and got it to do what it is meant to do.  As usual this is not what I really needed and the problem is a bit more complicated than I originally thought.  CP works as advertised though.  I'll try pull point and check it out.

Nope: Pretty much does the same thing as CP in this case. I think I understand how to state the solution theoretically. Now it's only figuring out how to do it.  Here goes:

1. Given the two vertically separated curves and given that the upper one lies within the shape of the lower one.  That is a perpendicular drawn from any point on the upper curve will lie within the lower one.

2. Extrude a surface from the lower line to some Z above the upper line.

3. Divide the upper curve.

4. Draw a line from each point on the upper curve perpendicular to a tangent (XY) at that point and extend it so that it intersects the extruded surface from the lower line. One could also just copy the lower curve and make the copy coplanar this the upper. (I'm not sure whether this will cause some funniness with some geometries but at this point who cares).

5. Drop a line from the intersection of the line and surface (or curve) to the lower Curve.

6. Draw a line from the originating point on the upper curve to the intersection point on the lower curve.

 

Whew.  Does this make sense to you?

Makes sense. It's not every day someone manages to come up with an algorithm this detailed. Sure makes my job easier :)

 

I attached a possible way to solve this. If both curves are planar, you can probably get away with projecting them onto a plane first, this saves an 'expensive' extrude and brep|curve intersect operation.

 

Also, it probably makes more sense to project the intersection points onto the plane of the lower curve instead of the curve itself, but so be it.

 

ps. don't worry about the warnings you get when opening the file, I made it with the internal version. It should load fine.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:

Thanks Dave:  That gets pretty darn close.  I've been playing with it and haven't come up with anything quite as straightforward.  However, try it with these lines.  I had to play with the angle of rotation and the results were a little odd.

Al

 

 

Attachments:

Graphical analysis. 

Divide 1st curve - Pull points onto 2nd curve - Plot the function Distance = f(parameter) - Find minimum - Re-inject parameter into curve one and pull.

Note : If your curves have kinks, the use the Kinky curve component instead of Interpolate

It's the same routine I use in my Phasma definition for developable surfaces. Exept in Phasma I use the curve/plane intersection to find zeros, and here I use Curve extremes. This way to solve unknown functions is very simple to set up compared to iterative scripts. This is how they did before computers...

Here's the file.

Attachments:

Thanks Fred:  This results in a single line as the result of the interpolation.  How then do I do this for all points in the original Divide?

Al

 

Sorry maybe I didn't understand. My file does the same as Rhino's Analyse curve deviation command.

Is this what you want? It can't be...

Actually I don't get at all your problem I think... Sketch?

HI Fred:  I can understand your confusion.  Here's an image of the two curves I've been playing with.  It's basically like a terrain map.  Or a minimal surface problem.

here's the actual file.  I [picked these because the straightforward analysis curve route doesn't work in this case.
Attachments:
terrain or minimal surfaces have nothing to do with closest points. Everything seems to work fine in regard to those. I don't see what is not working. Sorry, can't help.

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