-
Notifications
You must be signed in to change notification settings - Fork 74
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
Implement Intersects for ICurve and all subtypes #1008
Implement Intersects for ICurve and all subtypes #1008
Conversation
6f0063a
to
d16adb3
Compare
There is still work that needs to be done in SolveIterative
…ent classes. Bezier intersections with InfiniteLine, Circle and Ellipse still need implementation
@anthonie-kramer Added draft of implementation for ICurve.Intersects(ICurve). Does Intersects need tolerance parameter added? |
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.
This is great! Very excited to see this being worked on. I put a couple of small comment related to documentation here. As for the questions above about the overlap of methods, I'd be interested to know how big the change would be to standardize on your new interface and obsolete the old methods. I realize this would mean a bump of the release to 3.0. We could also make this a minor bump and deprecate the old intersection methods.
Reviewable status: 0 of 1 approvals obtained (waiting on @DmytroMuravskyi)
Elements/src/Geometry/TrimmedCurve.cs
line 20 at r1 (raw file):
public TBasis BasisCurve { get; protected set; } public abstract bool PointOnDomain(Vector3 point);
Can we get a comment for this new public method, and an <inheritdoc>
everywhere it is implemented?
Elements/src/Geometry/Vector3.cs
line 854 at r1 (raw file):
} public Vector3 ClosestPointOn(InfiniteLine line)
Can we get a comment here?
Elements/src/Geometry/Interfaces/ICurve.cs
line 31 at r1 (raw file):
double ParameterAtDistanceFromParameter(double distance, double parameter); bool Intersects(ICurve curve, out List<Vector3> results);
Can we a comment here? We've started to use <inheritdoc>
in other places, so a good comment on this interface can then be shared in every implementation by using <inheritdoc>
(https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/recommended-tags#inheritdoc).
Add Vector3Extensions.UniqueAverageWithinTolerance
NormalizedRadian was not helpful for domains where min is negative and max is positive. Include small noise into PointOnDomain for Arc and EllipticalArc Fix Ellipse.ParameterAt
Make UniqueAverageWithinTolerance check against every item in the group.
I will add the documentation for sure as a next step. Added implementation for Bezier. For Bezier-Line, Bezier-Circle, Bezier-Ellipse I used the iterative approach where I search where function of distance from iterated point to other object is zero. For Bezier-Bezier this approach is not working, so I used approach described in document mentioned in Bezier file - intersecting subdivided bounding boxes. Both approaches have weak points I want to minimize right now: root can be possibly missed or 2 roots can be found around an intersection point. Other issue I'm working on is resolving ambiguity between |
…just touch at one or both end points
1b7137f
to
545b051
Compare
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.
Looking good!
In the long term, I think we will want to find ways to supplement the iterative approaches, but it's fantastic to have this functionality now.
In general, we can improve readability in a couple of places. We can also improve performance by converting any foreach
loops into for
loops.
When you feel like we have enough tests, it would be awesome to see an integration test where we draw multiple beziers, lines, and other shapes in Hypar and show the intersection methods working in a Function.
Great work so far!
Reviewed 1 of 22 files at r1, 4 of 14 files at r2, 23 of 23 files at r3, all commit messages.
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @DmytroMuravskyi)
Elements/src/Geometry/Bezier.cs
line 362 at r3 (raw file):
case Circle circle: return Intersects(circle, out results); case Ellipse elliplse:
typo
Elements/src/Geometry/Bezier.cs
line 394 at r3 (raw file):
// Iteratively, find points on Bezier with 0 distance to the line. // It Bezier was limited to 4 points - more effective approach could be used. var roots = Equations.SolveIterative(Domain.Min, Domain.Max, 100,
I think if we are going to use an iterative method, we should make the steps a function of the curve length (applies to anywhere we use a step)
Elements/src/Geometry/Bezier.cs
line 525 at r3 (raw file):
} private void Intersects(Bezier other,
This method feels a little verbose / redundant
Elements/src/Geometry/InfiniteLine.cs
line 120 at r3 (raw file):
case Circle circle: return Intersects(circle, out results); case Ellipse elliplse:
typo
Elements/src/Geometry/TrimmedCurve.cs
line 42 at r3 (raw file):
case Circle circle: return Intersects(circle, out results); case Ellipse elliplse:
typo
Elements/src/Geometry/Vector3.cs
line 1 at r3 (raw file):
using ClipperLib;
What are we using ClipperLib here for? I have a secret agenda to eventually remove our dependency on ClipperLib, so if there is functionality that we need from it, I would rather solve it internally than rely on ClipperLib more.
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 think foreach
usage here is simple enough so it will not cause any performance downgrade.
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @anthonie-kramer and @ikeough)
Elements/src/Geometry/Bezier.cs
line 394 at r3 (raw file):
Previously, anthonie-kramer (Anthonie Kramer) wrote…
I think if we are going to use an iterative method, we should make the steps a function of the curve length (applies to anywhere we use a step)
Done. Added Circumference function for Ellipse and used Ellipse length for steps. For Bezier number of steps is limited to 500 as it is done in other functions.
Elements/src/Geometry/Bezier.cs
line 525 at r3 (raw file):
Previously, anthonie-kramer (Anthonie Kramer) wrote…
This method feels a little verbose / redundant
Simplified functions where it's possible. I'll be glad to do even further if you have any specific ideas in mind.
Elements/src/Geometry/TrimmedCurve.cs
line 20 at r1 (raw file):
Previously, ikeough (Ian Keough) wrote…
Can we get a comment for this new public method, and an
<inheritdoc>
everywhere it is implemented?
Done.
Elements/src/Geometry/Vector3.cs
line 854 at r1 (raw file):
Previously, ikeough (Ian Keough) wrote…
Can we get a comment here?
Done.
Elements/src/Geometry/Vector3.cs
line 1 at r3 (raw file):
Previously, anthonie-kramer (Anthonie Kramer) wrote…
What are we using ClipperLib here for? I have a secret agenda to eventually remove our dependency on ClipperLib, so if there is functionality that we need from it, I would rather solve it internally than rely on ClipperLib more.
I had auto add for using enabled, it likes to add useless usings when wrong function name is autocompleted. Disabled it for good. I agree that Clipper lib is problematic because of use of integer math.
Elements/src/Geometry/Interfaces/ICurve.cs
line 31 at r1 (raw file):
Previously, ikeough (Ian Keough) wrote…
Can we a comment here? We've started to use
<inheritdoc>
in other places, so a good comment on this interface can then be shared in every implementation by using<inheritdoc>
(https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/recommended-tags#inheritdoc).
Done.
Missing arc intersections are fixed in the latest push. Is there something else missing in this PR? |
# Conflicts: # CHANGELOG.md
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.
Reviewed 5 of 7 files at r4, 4 of 4 files at r5.
Reviewable status: complete! 1 of 1 approvals obtained (waiting on @DmytroMuravskyi and @ikeough)
Elements/src/Geometry/Bezier.cs
line 525 at r3 (raw file):
Previously, DmytroMuravskyi wrote…
Simplified functions where it's possible. I'll be glad to do even further if you have any specific ideas in mind.
BACKGROUND:
DESCRIPTION:
FUTURE WORK:
TESTING:
REQUIRED:
CHANGELOG.md
.COMMENTS:
This change is