An error occurred while loading the file. Please try again.
-
Pierre-Antoine Rouby authored52c4eec7
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
64
65
66
67
# -*- coding: utf-8 -*-
from math import dist
from pandas import isna
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)
def is_nan(self):
"""
Returns:
True if at least one coordinate is as np.nan
"""
return (isna(self.x) or
isna(self.y) or
isna(self.z))
def dist(self, p2):
return PointXYZ.distance(self, p2)
@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))