Skip to content
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

adds point in polygon to Point3. #388

Merged
merged 2 commits into from Dec 30, 2022
Merged

adds point in polygon to Point3. #388

merged 2 commits into from Dec 30, 2022

Conversation

d3ssy
Copy link
Collaborator

@d3ssy d3ssy commented Dec 28, 2022

What type of PR is this? (check all applicable)

  • ♻️ Refactor
  • ✨ Feature
  • 🐛 Bug Fix
  • 👷 Optimization
  • 📝 Documentation Update
  • 🔖 Release
  • 🚩 Other

Description

  • Adds point-in-polygon test to Point3.
  • Works with rotated polygons and points in 3d.
  • Cleaned up some doc strings.

Related Tickets & Documents

Closes #86

Added tests?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help

Added to documentation?

  • 📓 docs
  • 🙅 no documentation needed

@d3ssy d3ssy added the enhancement 📢 Issues describing an enhancement or pull requests adding an enhancement. label Dec 28, 2022
@d3ssy d3ssy requested a review from sonomirco December 28, 2022 14:59
@d3ssy d3ssy added this to In progress in Core via automation Dec 28, 2022
Copy link
Collaborator

@sonomirco sonomirco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @d3ssy :)

/// <param name="point">The point to test.</param>
/// <param name="polygon">The polygon to test against.</param>
/// <returns>Returns 0 if the point is outside the polygon or 1 if it is inside.</returns>
public int InPolygon(Polygon polygon)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it returns if it is coincident?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated method to test for coincidence edge cases.

/// <param name="point">The point to test.</param>
/// <param name="polygon">The polygon to test against.</param>
/// <returns>Returns 0 if the point is outside the polygon or 1 if it is inside.</returns>
public int InPolygon(Polygon polygon)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have this operation at the level of the Curve
It sounds natural to think we are operating on the curve instead of the point.
What about moving this method to NurbsBase?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is only applicable to Polygon as they are guaranteed to be planar curves. PointInCurve() given an arbitrary 3d curve is another can of worms.

I placed it in Point3 to match the Point3.InPlane() method.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't every curve be planar to perform this operation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try and it in rhino and see 😄.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless of planarity, we will need a more computationally intensive method for NURBS that calculates ray intersections, and does closest point for coincidence checks. The logic should be the same. We can limit it to planar curves in the case of NURBS and throw error if it ain't.

@d3ssy d3ssy merged commit 343aa18 into develop Dec 30, 2022
Core automation moved this from In progress to Done Dec 30, 2022
@d3ssy d3ssy deleted the dev/guma/point-in-polygon branch December 30, 2022 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 📢 Issues describing an enhancement or pull requests adding an enhancement.
Projects
Core
Done
Development

Successfully merging this pull request may close these issues.

Point contained inside a polygon
2 participants