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

Feat: Add check_coplanar kwarg to Line.intersect_line #320

Merged
merged 11 commits into from
Dec 29, 2022

Conversation

volkoshkursk
Copy link
Contributor

Hello! This is my fix of issue intersection line are not complanar with line in plane #319. I have added parameter tol to Plane.intersect_line, which is passed to Line.is_coplanar as keyword argument. Also I have added appropriate parameter to Triangle.orthocenter and Line.Segment.intersect_line_segment.

src/skspatial/objects/line.py Outdated Show resolved Hide resolved
@@ -560,7 +562,7 @@ def intersect_line(self, other: Line, **kwargs) -> Point:
if self.direction.is_parallel(other.direction, **kwargs):
raise ValueError("The lines must not be parallel.")

if not self.is_coplanar(other):
if not self.is_coplanar(other, tol=tol):
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
if not self.is_coplanar(other, tol=tol):
if check_coplanar and not self.is_coplanar(other):

Copy link
Owner

Choose a reason for hiding this comment

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

This still needs to be updated.

src/skspatial/objects/line_segment.py Outdated Show resolved Hide resolved
@@ -106,14 +106,17 @@ def contains_point(self, point: array_like, **kwargs) -> bool:

return math.isclose(similarity, -1, **kwargs)

def intersect_line_segment(self, other: LineSegment) -> Point:
def intersect_line_segment(self, other: LineSegment, tol: np.float64 = None) -> Point:
Copy link
Owner

Choose a reason for hiding this comment

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

This method can just pass all kwargs along to the intersect_line method.

Suggested change
def intersect_line_segment(self, other: LineSegment, tol: np.float64 = None) -> Point:
def intersect_line_segment(self, other: LineSegment, **kwargs) -> Point:

@@ -498,12 +498,18 @@ def altitude(self, vertex: str) -> Line:

raise ValueError("The vertex must be 'A', 'B', or 'C'.")

def orthocenter(self) -> Point:
def orthocenter(self, tol: np.float64 = None) -> Point:
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
def orthocenter(self, tol: np.float64 = None) -> Point:
def orthocenter(self, **kwargs) -> Point:

src/skspatial/objects/triangle.py Outdated Show resolved Hide resolved
volkoshkursk and others added 3 commits November 21, 2022 19:01
Co-authored-by: Andrew Hynes <andrewjhynes@gmail.com>
Co-authored-by: Andrew Hynes <andrewjhynes@gmail.com>
Co-authored-by: Andrew Hynes <andrewjhynes@gmail.com>
Copy link
Owner

@ajhynes7 ajhynes7 left a comment

Choose a reason for hiding this comment

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

It'd be also good if you added a unit test which calls the intersect_line method with is_coplanar=False.

@@ -485,6 +485,8 @@ def intersect_line(self, other: Line, **kwargs) -> Point:
----------
other : Line
Other line.
tol : np.float64, optional
Threshold below which values are considered zero. This value is passed to is_coplanar
Copy link
Owner

Choose a reason for hiding this comment

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

This needs to be changed to the following:

check_coplanar : bool
    Check that the lines are coplanar (default True). If False, this method may not return an actual intersection point, but an approximate one.

@@ -560,7 +562,7 @@ def intersect_line(self, other: Line, **kwargs) -> Point:
if self.direction.is_parallel(other.direction, **kwargs):
raise ValueError("The lines must not be parallel.")

if not self.is_coplanar(other):
if not self.is_coplanar(other, tol=tol):
Copy link
Owner

Choose a reason for hiding this comment

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

This still needs to be updated.

"""
Intersect the line segment with another.

Parameters
----------
other : LineSegment

tol : np.float64, optional
Threshold below which values are considered zero. This value is passed to is_coplanar as tol and to is_collinear as abs_tol.

Copy link
Owner

Choose a reason for hiding this comment

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

This needs to change to the following:

kwargs : dict, optional
    Additional keyword arguments passed to :meth:`Line.intersect_line`.

Parameters
----------
tol : np.float64, optional
Threshold below which values are considered zero. This value is passed to is_coplanar as tol and to is_collinear as abs_tol.
Copy link
Owner

Choose a reason for hiding this comment

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

This needs to change to the following:

kwargs : dict, optional
    Additional keywords passed to :meth:`Line.intersect_line`.

@ajhynes7 ajhynes7 changed the title Feat: Add parameter tol to intersect_line Feat: Add check_coplanar kwarg to Line.intersect_line Nov 23, 2022
Copy link
Owner

@ajhynes7 ajhynes7 left a comment

Choose a reason for hiding this comment

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

You still need to update the docstring of Line.intersect_line.

@@ -9,4 +9,4 @@
except ModuleNotFoundError:
import importlib_metadata # type: ignore

__version__ = importlib_metadata.version("scikit-spatial")
# __version__ = importlib_metadata.version("scikit-spatial")
Copy link
Owner

Choose a reason for hiding this comment

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

This shouldn't be commented out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forget to remove this comment. Now it is fixed.

@ajhynes7
Copy link
Owner

ajhynes7 commented Dec 3, 2022

Hi, there are some linting errors that need to be fixed.
https://github.com/ajhynes7/scikit-spatial/actions/runs/3603902670/jobs/6072652436

image

@ajhynes7
Copy link
Owner

ajhynes7 commented Dec 8, 2022

Hi, this PR is still failing.

https://github.com/ajhynes7/scikit-spatial/actions/runs/3627753010/jobs/6131842217

I suggest installing pre-commit and running this locally:

pre-commit run --all-files

Then commit the changes.

@ajhynes7 ajhynes7 force-pushed the master branch 2 times, most recently from 702e0be to 31ee17e Compare December 29, 2022 02:45
@ajhynes7
Copy link
Owner

@volkoshkursk are you still interested in merging this?

@sonarcloud
Copy link

sonarcloud bot commented Dec 29, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@codecov
Copy link

codecov bot commented Dec 29, 2022

Codecov Report

Merging #320 (937aff2) into master (b62d39e) will not change coverage.
The diff coverage is 100.00%.

❗ Current head 937aff2 differs from pull request most recent head c253738. Consider uploading reports for the commit c253738 to get more accurate results

@@           Coverage Diff           @@
##           master     #320   +/-   ##
=======================================
  Coverage   99.78%   99.78%           
=======================================
  Files          21       21           
  Lines         948      948           
=======================================
  Hits          946      946           
  Misses          2        2           
Impacted Files Coverage Δ
src/skspatial/objects/line.py 100.00% <100.00%> (ø)
src/skspatial/objects/line_segment.py 100.00% <100.00%> (ø)
src/skspatial/objects/triangle.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@ajhynes7
Copy link
Owner

I set up pre-commit.ci to make the fixes automatically.

@ajhynes7 ajhynes7 merged commit eaa889d into ajhynes7:master Dec 29, 2022
@ajhynes7 ajhynes7 linked an issue Dec 29, 2022 that may be closed by this pull request
@volkoshkursk
Copy link
Contributor Author

volkoshkursk commented Dec 30, 2022

Sorry, I had got sick and was not able to fix this. Thank you very much and Happy New Year!

@ajhynes7
Copy link
Owner

You're welcome, happy new year to you too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

intersection line are not complanar with line in plane
2 participants