summer_course_2024/helpers/geometry.py
2020-05-19 17:00:15 -04:00

20 lines
479 B
Python

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