Skip to content

Commit 961fdf8

Browse files
authored
Merge pull request #1435 from mattiskoh/bugfix-plane-is-parallel
fixed unexpected behavior for opposite parallel planes.
2 parents e907f00 + 6065114 commit 961fdf8

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## Unreleased
9+
* Fixed unexpected behavior for method `Plane.is_parallel` for opposite normals.
910

1011
### Added
1112

src/compas/geometry/plane.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,13 @@ def is_parallel(self, other, tol=None):
384384
>>> plane2 = Plane([1.0, 1.0, 1.0], [0.0, 0.0, 1.0])
385385
>>> plane1.is_parallel(plane2)
386386
True
387+
>>> plane1 = Plane.worldXY()
388+
>>> plane2 = Plane([1.0, 1.0, 1.0], [0.0, 0.0, -1.0])
389+
>>> plane1.is_parallel(plane2)
390+
True
387391
388392
"""
389-
return TOL.is_close(self.normal.dot(other.normal), 1, rtol=0, atol=tol)
393+
return TOL.is_close(abs(self.normal.dot(other.normal)), 1, rtol=0, atol=tol)
390394

391395
def is_perpendicular(self, other, tol=None):
392396
"""Verify if this plane is perpendicular to another plane.

tests/compas/geometry/test_plane.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,13 @@ def test_plane_from_three_points():
7676

7777
result = Plane.from_three_points(pt1, pt2, pt3)
7878
assert result == ([0, 0, 0], [0, 0, 1])
79+
80+
81+
def test_plane_is_parallel():
82+
plane1 = Plane.worldXY()
83+
plane2 = Plane([1.0, 1.0, 1.0], [0.0, 0.0, 1.0])
84+
assert plane1.is_parallel(plane2)
85+
86+
plane1 = Plane.worldXY()
87+
plane2 = Plane([1.0, 1.0, 1.0], [0.0, 0.0, -1.0])
88+
assert plane1.is_parallel(plane2)

0 commit comments

Comments
 (0)