Skip to content

fixed unexpected behavior for opposite parallel planes. #1435

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

Merged
merged 6 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
* Fixed unexpected behavior for method `Plane.is_parallel` for opposite normals.

### Added

Expand Down
6 changes: 5 additions & 1 deletion src/compas/geometry/plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,13 @@ def is_parallel(self, other, tol=None):
>>> plane2 = Plane([1.0, 1.0, 1.0], [0.0, 0.0, 1.0])
>>> plane1.is_parallel(plane2)
True
>>> plane1 = Plane.worldXY()
>>> plane2 = Plane([1.0, 1.0, 1.0], [0.0, 0.0, -1.0])
>>> plane1.is_parallel(plane2)
True

"""
return TOL.is_close(self.normal.dot(other.normal), 1, rtol=0, atol=tol)
return TOL.is_close(abs(self.normal.dot(other.normal)), 1, rtol=0, atol=tol)

def is_perpendicular(self, other, tol=None):
"""Verify if this plane is perpendicular to another plane.
Expand Down
3 changes: 2 additions & 1 deletion src/compas_ghpython/components_cpython/Compas_Info/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
Displays information about the active COMPAS environment.
"""

import os

import Grasshopper

import os
import compas


Expand Down
10 changes: 10 additions & 0 deletions tests/compas/geometry/test_plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,13 @@ def test_plane_from_three_points():

result = Plane.from_three_points(pt1, pt2, pt3)
assert result == ([0, 0, 0], [0, 0, 1])


def test_plane_is_parallel():
plane1 = Plane.worldXY()
plane2 = Plane([1.0, 1.0, 1.0], [0.0, 0.0, 1.0])
assert plane1.is_parallel(plane2)

plane1 = Plane.worldXY()
plane2 = Plane([1.0, 1.0, 1.0], [0.0, 0.0, -1.0])
assert plane1.is_parallel(plane2)
Loading