I have 2 lists of straight
I find the lines coincident with python
I find empty list
any help ??
thanks for collaboration
I have 2 lists of straight
Vector calculus! if one is looking to become proficient in any computational design tool, you’ve got to understand it (part of what I like to call the “computational designers tool kit”).
So, extract the lines normals (
Curve.NormalAtParameter), normalize them (
Vector.Normalize). Next, create a test vector (world x for example
Vector.XAxis), and calculate the dot product (
Math.abs() the result (the scalar) and test for equality to 1. Any results that return true are co-linear.
Thanks for the answer, I wanted without geometry
In my example I have two lists of line (linv1,linv2)
the python voice:
if line1 = line2:
Nope, that won’t work as it’s ambiguous. You need to evaluate explicit conditionals that resolve to a single bool.
So any results which = 1 are co-linear. In actual fact, you could simply group by scalar and organise your list of lines in one go. e.g. dot of 0.34534 would group all other lines with the same dot product (since same dot = same direction).
What you need to do next then, is find a way to group your lines based on the same dot product (same scalar). There are some list management nodes that can help you to achieve this in the Core > List library.
a line above the other line: coincident
the method does not find the lines coincident
can you tell me which carrier … calculation formula related to Vector.Dot the coincident straight lines in geometry … I found 2 conditions: cancel the vector product (parallel lines) and then pass through a point (coinciding lines)
My English is very bad … I hope realized
If I understand correctly, you are asking how to handle coincident lines, i.e. duplicates. The process of finding duplicates is relatively complex and requires more than a dot product to establish coincidence. Basically you need to evaluate:
- Startpoint and endpoint for coincidence (also establish if the test curve is reversed since this will reverse the start/end points and the normals in the next step, which obviously will generate erronous results)
- Normals at start, mid, end against same normals on the test curve (i.e. dot product test)
- Length for equality
The above describes an optimised method, meaning its likely to find around 99% of duplicates, but where ‘similar’ or seemingly identical (by human eye) curves are found, it will fail to return the correct result, but that’s a small price to pay for code and processing efficiency.
As computers are dumb (currently, they cant think or perceive like we can), you’ll need to use brute-force checking algorithm to test each curve against all others - and don’t forget to remove the test curve from the evaluation set, otherwise it will get tested against itself and all results will return true (for duplicates)! As I said, its relatively complex.
Incidentally I have good news for you, I’ve written this exact algorithm for my remove duplicate curves node. It is ready for the upcoming release of bimorphNodes v2.0 with a release date in Q1 2017. Its overloaded, so you can input Dynamo curves or Revit Model or Detail curves. There is also the additional option with Revit curves to pysically delete them from your project. I will keep you posted on this thread once its released:
RemoveDuplicateCurves is now avaialble in BimorphNodes v2.0 if you’re still running into the same issue.