hub/helpers/geometry.py

20 lines
479 B
Python
Raw Normal View History

2020-05-19 17:00:15 -04:00
import math
import numpy as np
class Geometry:
def __init__(self, delta=0.5):
self._delta = delta
def almost_equal(self, v1, v2):
delta = math.sqrt(pow((v1[0]-v2[0]), 2) + pow((v1[1]-v2[1]), 2) + pow((v1[2]-v2[2]), 2))
return delta <= self._delta
@staticmethod
def to_points_matrix(points, remove_last=False):
rows = points.size//3
points = points.reshape(rows, 3)
if remove_last:
points = np.delete(points, rows-1, 0)
return points