Grasshopper

algorithmic modeling for Rhino

Hi,

I have number of vectors sharing the same starting point ang going in several directions, there can be 3 to n vectors just as sketch below. Is it possible to find adjacent vectors to one of them?

Thanks

Views: 1214

Attachments:

Replies to This Discussion

Hi Tomas,

vectors don't have starting points, they are merely directions in space. What you have there are lines. Although if they are all supposed to have the same startpoint, then I guess you can just focus on the direction only...

When you say adjacent, do you mean you want to find the one that points as much as possible in the same direction, or one that is actually pointing in the exact same direction, or the two vectors on either side? If the latter, then it's a strictly 2D problem because 'side' doesn't work in 3D as a concept.

It can also be lines. I would like to have two lines/vectors that pointing in the similar direction as red one.

First I was thinking that I could measure angles between all vectors and take two with smallest angle. But this worked only two certain extent. When I have very wide angle this type of sorting fails to find.

What would be a method in 2d either in lines or vectors?

I was also thinking use convex hull. But I want to find a more simple method of sorting.
I also saw someone using circle as a guid curve for sorting points. But is there a more simple method for retrieving specific element "neighbours"?
And it can be lines instead of vectors as I start from them.

If this serves you, you should unitize vectors, in this example I did not make for better viewing.

Does the vector subraction sorting works when taking this line as start member?
Attachments:

You have to use the vector line, heading out, replacing the [List item] (A), and replaces the [Cull item] with the other vectors (B). The [Subtract] component returns the vector from B to A and [Sort List] receives the length of the vector. That is, simply measures the distance. As the vectors are unitary, the two closest are the surrounding.

Uooops, forget this, the two closest are not necessarily neighbors, sorry! Pieter's method is the correct way.

Hi Tomas, provided the lines end points are the mutual point, here's my two cents, a kind of circular sort really:

I should have said: provided all lines start at the mutual point (like you stated in your initial question), or all lines end at the mutual point.

Dear Pieter,

Thank you very much that was what I looking for:)

I tried to use this in 3d and it also works.

Do you know if this works in 3d in all cases or it is a 2d problem? 

Hi Tomas, it's a pure 2d solution. I'd say for a reliable method in 3d you'll need to find the two smallest angles.


RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service