-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spatial_Engine: Add query dominant vector #2539
Spatial_Engine: Add query dominant vector #2539
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a first iteration the code looks good, although I have a few objections as well some questions and general remarks - please see the code comments for details.
return dominantVector; | ||
|
||
//filter grouped vectors to find only curves that are X = 0 or 1 (horizontal or vertical lines) | ||
var orthogonalVectors = groupByNormal.Where(x => x.First().Normalise().X == 0 || x.First().Normalise().X == 1).ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use some tolerance here, otherwise you can end up with 1 != 1 due to numerical noise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found one naming issue which I believe would be good to fix, plus I gave I tried to refactor the code for sport - as mentioned in the comments, please feel free to ignore, I did it more for learning/knowledge sharing than anything else.
Co-authored-by: Pawel Baran <[email protected]>
Co-authored-by: Pawel Baran <[email protected]>
@BHoMBot check required |
@tiagogrossi to confirm, the following checks are now queued:
There are 51 requests in the queue ahead of you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now 👍
@BHoMBot check required |
@pawelbaran to confirm, the following checks are now queued:
There are 112 requests in the queue ahead of you. |
@BHoMBot check required |
@pawelbaran to confirm, the following checks are now queued:
|
Looks like there is a few compliance issues to resolve @tiagogrossi |
@BHoMBot check required |
@tiagogrossi to confirm, the following checks are now queued:
There are 71 requests in the queue ahead of you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still looks good 👍
@BHoMBot check null-handling |
@tiagogrossi to confirm, the following checks are now queued:
|
@BHoMBot check required |
@tiagogrossi to confirm, the following checks are now queued:
|
@BHoMBot check copyright-compliance |
@tiagogrossi to confirm, the following checks are now queued:
There are 11 requests in the queue ahead of you. |
@BHoMBot check dataset-compliance |
@tiagogrossi to confirm, the following checks are now queued:
There are 13 requests in the queue ahead of you. |
@BHoMBot check ready-to-merge |
@tiagogrossi to confirm, the following checks are now queued:
There are 15 requests in the queue ahead of you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...and still looks good!
@BHoMBot check ready-to-merge |
@pawelbaran to confirm, the following checks are now queued:
|
Issues addressed by this PR
Closes #2537
This new method queries
IElement1D
andIElement2D
for their dominant vector (orientation). The logic is very simple, it groups all similar vectors and sort them by summed lengths. The longest length is the dominant vector and hence it's selected. The method also allows for orthogonal vector priority, where if true it tries to return orthogonal vectors, and a angle discrepancy tolerance when grouping vectors.Test files
Test file is here. I have not included a GH proof because quite honestly I don't even know how to do it with standard nodes.
Changelog
Adds
BH.Engine.Spatial.Query.DominantVector