Something I have been wondering for awhile is whether it would be possible to limit the closest point search area on beforehand. Say I want the closest points on the wall outlines to the midpoint of a door (so I don’t have to perform more computationally intensive intersections), the component still obtains and computes points on all curve segments. But I only need the ones closest to the dashed line (within the circle), can this be done?
In this case, testing for one point yields 19 points so the load increases quite a lot for every point closest point evaluation. Closest points evaluation.gh (10.2 KB)
One way or another you’ll probably end up with having to do the evaluation of all curves at some point.Or at the very least evaluate part of them, but then you’ll end up with more complexity in terms of knowing which to evaluate and which you shouldn’t.
E.g.
You create a radius around your point to determine what curves should be taken into account for the closest point evaluation. Downside: Still requires an evaluation of whether a curve is inside of that region or not along with a method to seperate the curves and select the one you need.
You create an iteration based python script that breaks upon finding a point that is in a range that you specify. As this was your initial request I made a quick example;
Upside: “If you’re lucky” it’s one of the first curves in the list. Downside: It could also be the last one in the list, meaning you still have the same amount of points evaluated. Remark: How would you know the search area? (This bit also makes it very prone to errors in my opinion, as you can see if you increase the search range)
Up until now I never really experienced CCP as a bottle neck in terms of time to processing time. Usually the intersections of Breps/Meshes or the Sequential processing nature of Grasshopper is the part that slows a script down.
Well, the search area is known in this case as it’s half the wall width.
I think I may be trying a different method though, thinking about this problem further.
Yes, I have also been using that. Good to know it’s faster, wasn’t sure about that, since I’m not at th point yet where I have to process the large amounts of data that I think I will.
Curve.ClosestPoint
has an overloud that allow to limit the search with maximum Distance
public bool ClosestPoint(
Point3d testPoint,
out double t,
double maximumDistance
)
Finds the parameter of the point on a curve that is closest to testPoint. If the maximumDistance parameter is > 0, then only points whose distance to the given point is <= maximumDistance will be returned. Using a positive value of maximumDistance can substantially speed up the search.
… although you would still be searching the line against all the centerlines. I guess it would be a smaller search?
It seems you are after the fastest method. Just to state the obvious, you can get the two points using Line | Curve intersection, or Curve | Curve intersection, the later of which will give you just the two intersection points of the door line and the wall outlines: