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.
Tags:
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
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
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
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.
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
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by