IDS peak ICV v1.1.0
Loading...
Searching...
No Matches
point_xyz.py
Go to the documentation of this file.
1from __future__ import annotations
2import numpy as np
3
4
5class PointXYZ:
6 """!
7 @brief
8 Represents a point in 3D space.
9
10
11 @ingroup ids_peak_icv_python_types_geometry
12 @since ids_peak_icv 1.1
13 """
14
15 def __init__(self, x: float, y: float, z: float) -> None:
16 """!
17 @brief
18 Creates a point with x, y and z float channels.
19
20 @param x: x coordinate
21 @param y: y coordinate
22 @param z: z coordinate
23
24 @since ids_peak_icv 1.1
25 """
26 self.xx = np.float32(x)
27 self.y = np.float32(y)
28 self.z = np.float32(z)
29
30 def __eq__(self, other: object) -> bool:
31 """!
32 @brief
33 Check if two points of type PointXYZ are equal.
34
35 @param other: Another PointXYZ object OR List of coordinates [x, y, z] OR Tuple of coordinates (x, y, z)
36
37 @return True if points are equal, False otherwise
38
39 @since ids_peak_icv 1.1
40 """
41 from typing import cast
42
43 if isinstance(other, PointXYZ):
44 other = cast(PointXYZ, other)
45 return bool(self.xx == other.x and self.y == other.y and self.z == other.z)
46 if isinstance(other, list) or isinstance(other, tuple):
47 if len(other) != 3:
48 return False
49 other = cast(list | tuple, other)
50
51 return bool(self.xx == other[0] and self.y == other[1] and self.z == other[2])
52
53 return False
54
55 def __ne__(self, other: object) -> bool:
56 """!
57 @brief
58 Check if two points of type PointXYZ are not equal.
59
60 @param other: Another PointXYZ
61
62 @return True if points are not equal, False otherwise
63
64 @since ids_peak_icv 1.1
65 """
66 return not self.__eq__(other)
67
68 def __gt__(self, other: object) -> bool:
69 """!
70 @brief
71 Check if a point of type PointXYZ is greater than another point of type PointXYZ.
72
73 @param other: Another peak_icv_point_xyz
74
75 @return True if point of type PointXYZ is greater than, False otherwise
76
77 @since ids_peak_icv 1.1
78 """
79
80 def gt_point(x: np.float32, y: np.float32, z: np.float32) -> bool:
81 if self.xx > x:
82 return True
83 elif self.xx < x:
84 return False
85 else:
86 if self.y > y:
87 return True
88 elif self.y < y:
89 return False
90 else:
91 return bool(self.z > z)
92
93 if isinstance(other, PointXYZ):
94 return gt_point(other.x, other.y, other.z)
95
96 if isinstance(other, list) or isinstance(other, tuple):
97 if len(other) != 3:
98 return False
99 return gt_point(other[0], other[1], other[2])
100
101 return False
102
103 def __lt__(self, other: object) -> bool:
104 return (not self.__gt__(other)) and self.__ne__(other)
105
106 def __str__(self) -> str:
107 """!
108 @brief
109 Get a string representation of the PointXYZ.
110
111 @return String representation of the PointXYZ
112
113 @since ids_peak_icv 1.1
114 """
115 return f"({self.x:.3f}, {self.y:.3f}, {self.z:.3f})"
bool __eq__(self, object other)
Check if two points of type PointXYZ are equal.
Definition point_xyz.py:30
str __str__(self)
Get a string representation of the PointXYZ.
Definition point_xyz.py:106
bool __ne__(self, object other)
Check if two points of type PointXYZ are not equal.
Definition point_xyz.py:55
bool __gt__(self, object other)
Check if a point of type PointXYZ is greater than another point of type PointXYZ.
Definition point_xyz.py:68
None __init__(self, float x, float y, float z)
Creates a point with x, y and z float channels.
Definition point_xyz.py:15