Applying cull pattern to filter by vector direction

I’m working with two sets of vectors in Grasshopper: one grid of vectors representing a force (e.g., river flow) and one set of contour vectors from a shape. I need to filter the contour vectors so that only those pointing in the same direction as the grid vectors are kept, with a tolerance of -0.2 to 0.2 . The problem is when I use vector display on the cull pattern I have created, the results are misaligned with the contour vectors.

How can I filter the contour vectors based on their direction relative to the grid vectors, with the results aligning to contour vectors?

River_Flow_Force.gh (32.8 KB)

Vectors on their own mean nothing because they don’t have a starting Point, so if you want to measure the angle between two “close” vectors in that grid in order to filter those which fall into a given angle-range, you might want to compare the points on which they are applied, and from those get which vector it’s being pulled?

I would do something like the following:

River_Flow_Force_Re.gh (36.9 KB)

note that the Angle component computes angles between two vectors, and that angle is always positive, so the filter <= 0.2 should be enough to encompass the [-0.2 to 0.2] Domain

2 Likes

Great, exactly what I was trying to get. Thanks a lot!

just a note :slight_smile: after looking at the whole thing with “fresh eyes”

as your definition is organized now, you are calculating the Grid_Vectors, then as second step we are checking which Grid_Point is the closest to each of the Contour_Points, in order to retrieve the respective vectors and measure the angle between them

the thing is, knowing that the Grid_Vectors are all defined as a Vector 2pt from each Grid Point to the very same external point, then the logical step is that instead of eventually retrieving which is the closest Grid_Point (to gets the respective Vector) to each Contour_Point, you could just calculate the exact Vector 2Pt from each Contour_Point to the external point used to create the Grid Vectors themselves :slight_smile:

what I mean is, because Grid_Vectors are built on a Grid of finite points, they are just an interpolation of the real vector that goes from each Contour Point to that very same external point… so maybe you want to use that for measuring each angle instead? :upside_down_face:

1 Like

That actually works much better! I can now adjust the values external point to get different Contour_Points better than having to adjust the number to test against in the ‘smaller than’ component. This also solves my next task of making an animation, which I can now do using number sliders of XYZ on the external point. Super cool - appreciate it! :grin:

1 Like