Comparing lines from models and displaying similarities and differences

I’ve got 2 line models where there should be similarities and may or may not have differences. I’d like to compare the lines and visually identify the similarities and differences. The problem is 1 of the model tend to have lines broken into segments which makes the comparison a little harder. Does anyone have any advice on how I should approach this?

Check if the midpoints of the lines in one model lie on the lines of the other.

I’ve already done that as a first step but due to Model 2 having segmented lines it’s proving difficult to do the comparison.

Midpoints not lying on other lines show the difference.
Midpoints not lying on other midpoints show the segments.

What component would I use to capture points lying on lines?

Curve Closest Point

Find the difference - dissimilar line_vr1.gh (18.8 KB)

1 Like

Pull Point for points on points.

Find the difference_vr2.gh (15.2 KB)

1 Like

Thanks! I’ll have a look.

I’m working on this project where there are 2 models that are mostly identical. I’m building a script that can check whether the vectors of lines in each model point in the same direction and if not have it show visually. In a previous post, I mentioned that the model lines don’t map exactly as 1 model may have multiple segments of lines to match 1 line in the other model. I’ve kind of overcome this situation temporarily by chopping up the other model so the segments of lines somewhat map to one another.

For the vector compare, I’ve tried using the method where you find the distance of the two lists and obtain data where distances = 0. Two problems with this methodology using my data is that the vector ‘points’ aren’t perfectly matching (some tolerances involved) and secondly the vector lists have repeats despite when displayed the anchors are located at different points.

If anyone have any thoughts or even inspirations on how I may tackle this it would be greatly appreciated!

Do you know what the dot product does?

Why don’t you continue the other topic where there are replies already?

1 Like

Yes, I was considering using it but have yet to try implement.

My thoughts were to unitise the vectors and then use the dot products to get information on whether the vectors matched, or not. But for the second problem where my vectors having repeats despite technically having different anchor points, I’m not too sure how I’d tackle.

I’ve tried searching via. google but only came across a couple from another site. I might not be searching with the right keywords. Do you have links to similar posts?

I assume the geometry would be the same like in your other topic?

Ok so the dot product lets you compare two vectors. If the dot product is 1, the vectors are parallel. Dot product of 0 tells you the vectors are in a 90° angle. If you do not understand this, please take a look at the ‘Essential Mathematics…’ guide

Rhino - Essential Mathematics for Computational Design

There’s also the modelab primer with some useful information:

Foundations | The Grasshopper Primer Third Edition

Was my solution not useful?

1 Like

It was useful! This is for another topic that I posted about. Martin is asking if we can combine the post into one

If the topics are different, then please ignore my input and continue the other one. You’d also mark one post as solution so other see the topic is solved.

Please provide a Grasshopper definition with some geometry

I think I see the problem? What if two lines share the same midpoint but have different directions?

You could first sort for lines of the same direction using the vector solution Martin suggested, then reduce the result for lines of the same midpoint. Or you could just solve the whole thing by comparing the start and endpoints of the lines. The only problem comparing endpoints is curve direction, which would still require vector comparison.

I am so confused.

You can use Similarity to get vectors that are equal within tolerance. As for the list of vectors that share the same direction, they will have repeats because vectors do not have anchors. They are a single point value that when measured from the origin represent direction and magnitude.