Skip to content

Commit 9e828e8

Browse files
committed
Support negate on Point()
1 parent 303e2a7 commit 9e828e8

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

declaracad/occ/geom.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ def __mul__(self, other):
188188
def __truediv__(self, other):
189189
return self.__class__(self.x / other, self.y / other, self.z / other)
190190

191+
def __neg__(self):
192+
return self.__class__(-self.x, -self.y, -self.z)
193+
191194
def cross(self, other) -> "Point":
192195
p = self.__coerce__(other)
193196
return self.__coerce__(self.proxy.Crossed(p.proxy))

tests/test_2_occ.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ def test_point():
5858
assert Point(1, 2, 3) * 2 == Point(2, 4, 6)
5959
assert Point(2, 4, 6) / 2 == Point(1, 2, 3)
6060

61+
assert -Point(1, 2, 3) == Point(-1, -2, -3)
62+
6163
with pytest.raises(TypeError):
6264
Point(1, 2, 3) / Point(1, 2, 3)
6365

0 commit comments

Comments
 (0)