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

Propose adding Plane.isometric to built-in planes #647

Merged
merged 3 commits into from
Jun 24, 2024
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
39 changes: 23 additions & 16 deletions src/build123d/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1895,6 +1895,12 @@ def bottom(cls) -> Plane:
"""Bottom Plane"""
return Plane((0, 0, 0), (1, 0, 0), (0, 0, -1))

@property
def isometric(cls) -> Plane:
"""Isometric Plane"""
return Plane(
(0, 0, 0), (1 / 2**0.5, 1 / 2**0.5, 0), (1 / 3**0.5, -1 / 3**0.5, 1 / 3**0.5)
)

class Plane(metaclass=PlaneMeta):
"""Plane
Expand All @@ -1909,22 +1915,23 @@ class Plane(metaclass=PlaneMeta):

Planes can be created from faces as workplanes for feature creation on objects.

======= ====== ====== ======
Name x_dir y_dir z_dir
======= ====== ====== ======
XY +x +y +z
YZ +y +z +x
ZX +z +x +y
XZ +x +z -y
YX +y +x -z
ZY +z +y -x
front +x +z -y
back -x +z +y
left -y +z -x
right +y +z +x
top +x +y +z
bottom +x -y -z
======= ====== ====== ======
======= ====== ====== ======
Name x_dir y_dir z_dir
======= ====== ====== ======
XY +x +y +z
YZ +y +z +x
ZX +z +x +y
XZ +x +z -y
YX +y +x -z
ZY +z +y -x
front +x +z -y
back -x +z +y
left -y +z -x
right +y +z +x
top +x +y +z
bottom +x -y -z
isometric +x+y -x+y+z +x+y-z
======= ====== ====== ======

Args:
gp_pln (gp_Pln): an OCCT plane object
Expand Down
30 changes: 16 additions & 14 deletions tests/test_direct_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2267,20 +2267,21 @@ class TestPlane(DirectApiTestCase):

def test_class_properties(self):
"""Validate
Name x_dir y_dir z_dir
======= ====== ====== ======
XY +x +y +z
YZ +y +z +x
ZX +z +x +y
XZ +x +z -y
YX +y +x -z
ZY +z +y -x
front +x +z -y
back -x +z +y
left -y +z -x
right +y +z +x
top +x +y +z
bottom +x -y -z
Name x_dir y_dir z_dir
======= ====== ====== ======
XY +x +y +z
YZ +y +z +x
ZX +z +x +y
XZ +x +z -y
YX +y +x -z
ZY +z +y -x
front +x +z -y
back -x +z +y
left -y +z -x
right +y +z +x
top +x +y +z
bottom +x -y -z
isometric +x+y -x+y+z +x+y-z
"""
planes = [
(Plane.XY, (1, 0, 0), (0, 0, 1)),
Expand All @@ -2295,6 +2296,7 @@ def test_class_properties(self):
(Plane.right, (0, 1, 0), (1, 0, 0)),
(Plane.top, (1, 0, 0), (0, 0, 1)),
(Plane.bottom, (1, 0, 0), (0, 0, -1)),
(Plane.isometric, (1 / 2**0.5, 1 / 2**0.5, 0), (1 / 3**0.5, -1 / 3**0.5, 1 / 3**0.5)),
]
for plane, x_dir, z_dir in planes:
self.assertVectorAlmostEquals(plane.x_dir, x_dir, 5)
Expand Down
Loading