Skip to content

Commit

Permalink
Merge pull request #115 from cwapi3d/develop
Browse files Browse the repository at this point in the history
- add missing magic methods point_3d
  • Loading branch information
Brunner246 authored Jan 23, 2024
2 parents f384ac2 + b5efb96 commit cdc4de0
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='cwapi3d',
version='30.318.9',
version='30.319.0',
author='Cadwork',
author_email='[email protected]',
description='Python bindings for CwAPI3D',
Expand Down
81 changes: 80 additions & 1 deletion src/cadwork/point_3d.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,84 @@
class point_3d:
def __init__(self, x: float, y: float, z: float) -> None:
self.x = x
self.y = y
self.z = z

def __add__(self, p: 'point_3d'):
"""adds two points
Args:
p ( point_3d): p
Returns:
point_3d: a third point
"""

def __sub__(self, p: 'point_3d'):
"""subtracts two points
Args:
p ( point_3d): p
Returns:
point_3d: a third point
"""

def __mul__(self, p: 'point_3d'):
"""multiplies two points
Args:
p ( point_3d): p
Returns:
point_3d: a third point
"""

def __div__(self, p: 'point_3d'):
"""divides two points
Args:
p ( point_3d): p
Returns:
point_3d: a third point
"""

def __eq__(self, p: 'point_3d'):
"""checks if two points are equal
Args:
p ( point_3d): p
Returns:
bool: condition
"""

def __ne__(self, p: 'point_3d'):
"""checks if two points are not equal
Args:
p ( point_3d): p
"""

def __getitem__(self, index: int):
"""gets the value of a point at a given index
Args:
index (int): index
Returns:
float: value
"""

def __setitem__(self, index: int, value: float):
"""sets the value of a point at a given index
Args:
index (int): index
value (float): value
"""

def dot(self, p: 'point_3d') -> float:
"""dot
Args:
Expand Down Expand Up @@ -49,4 +129,3 @@ def invert(self) -> 'point_3d':
Returns:
point_3d
"""

0 comments on commit cdc4de0

Please sign in to comment.