An error occurred while loading the file. Please try again.
-
Pierre-Antoine Rouby authorede5dc809a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# -*- coding: utf-8 -*-
from math import dist
from pandas import isna as pd_is_na
from Model.Geometry.Point import Point
class PointXYZ(Point):
def __init__(self, x:float = 0.0, y:float = 0.0, z:float = 0.0,
name:str = ""):
super(PointXYZ, self).__init__(name=name)
self._x = float(x)
self._y = float(y)
self._z = float(z)
def __repr__(self):
return f"({self._x}, {self._y}, {self._z}, {self._name})"
@property
def x(self):
return self._x
@x.setter
def x(self, value):
self._x = float(value)
@property
def y(self):
return self._y
@y.setter
def y(self, value):
self._y = float(value)
@property
def z(self):
return self._z
@z.setter
def z(self, value):
self._z = float(value)
@property
def is_nan(self):
"""
Returns:
True if at least one coordinate is as np.nan
"""
return pd_is_na(self.x()) or pd_is_na(self.y()) or pd_is_na(self.z())
@staticmethod
def distance(p1, p2):
"""Euclidean distance between p1 and p2.
Args:
p1: A XYZ Point
p2: A XYZ Point
Returns:
Euclidean distance between the two points
"""
return dist((p1.x(), p1.y(), p1.z()), (p2.x(), p2.y(), p2.z()))