-
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
Feat: Add check_coplanar
kwarg to Line.intersect_line
#320
Conversation
src/skspatial/objects/line.py
Outdated
@@ -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): |
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.
if not self.is_coplanar(other, tol=tol): | |
if check_coplanar and not self.is_coplanar(other): |
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 still needs to be updated.
@@ -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: |
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 method can just pass all kwargs along to the intersect_line
method.
def intersect_line_segment(self, other: LineSegment, tol: np.float64 = None) -> Point: | |
def intersect_line_segment(self, other: LineSegment, **kwargs) -> Point: |
src/skspatial/objects/triangle.py
Outdated
@@ -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: |
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.
def orthocenter(self, tol: np.float64 = None) -> Point: | |
def orthocenter(self, **kwargs) -> Point: |
Co-authored-by: Andrew Hynes <andrewjhynes@gmail.com>
Co-authored-by: Andrew Hynes <andrewjhynes@gmail.com>
Co-authored-by: Andrew Hynes <andrewjhynes@gmail.com>
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.
It'd be also good if you added a unit test which calls the intersect_line
method with is_coplanar=False
.
src/skspatial/objects/line.py
Outdated
@@ -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 |
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 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.
src/skspatial/objects/line.py
Outdated
@@ -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): |
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 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. | ||
|
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 needs to change to the following:
kwargs : dict, optional
Additional keyword arguments passed to :meth:`Line.intersect_line`.
src/skspatial/objects/triangle.py
Outdated
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. |
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 needs to change to the following:
kwargs : dict, optional
Additional keywords passed to :meth:`Line.intersect_line`.
check_coplanar
kwarg to Line.intersect_line
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 still need to update the docstring of Line.intersect_line
.
src/skspatial/__init__.py
Outdated
@@ -9,4 +9,4 @@ | |||
except ModuleNotFoundError: | |||
import importlib_metadata # type: ignore | |||
|
|||
__version__ = importlib_metadata.version("scikit-spatial") | |||
# __version__ = importlib_metadata.version("scikit-spatial") |
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 shouldn't be commented out.
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 forget to remove this comment. Now it is fixed.
Hi, there are some linting errors that need to be fixed. |
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. |
702e0be
to
31ee17e
Compare
@volkoshkursk are you still interested in merging this? |
for more information, see https://pre-commit.ci
Kudos, SonarCloud Quality Gate passed! |
Codecov Report
@@ Coverage Diff @@
## master #320 +/- ##
=======================================
Coverage 99.78% 99.78%
=======================================
Files 21 21
Lines 948 948
=======================================
Hits 946 946
Misses 2 2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
I set up |
Sorry, I had got sick and was not able to fix this. Thank you very much and Happy New Year! |
You're welcome, happy new year to you too! |
Hello! This is my fix of issue
intersection line are not complanar with line in plane #319
. I have added parametertol
toPlane.intersect_line
, which is passed toLine.is_coplanar
as keyword argument. Also I have added appropriate parameter toTriangle.orthocenter
andLine.Segment.intersect_line_segment
.