# -*- coding: utf-8 -*- import numpy as np from Model.Geometry.PointXYZ import PointXYZ class Vector1d: def __init__(self, a: PointXYZ, b: PointXYZ): self.A = a self.B = b def __repr__(self): return "vecteur AB = ({}, {}, {})".format( self.B.x - self.A.x, self.B.y - self.A.y, self.B.z - self.A.z ) def vector1d(self): return np.array([ self.B.x - self.A.x, self.B.y - self.A.y, self.B.z - self.A.z ]) def direction_vector(self): return np.array([ self.B.x - self.A.x, self.B.y - self.A.y, 0 ]) def norm_vector(self): return np.linalg.norm(self.vector1d()) def norm_direction_vector(self): return np.linalg.norm(self.direction_vector()) def normalized_direction_vector(self): return self.direction_vector() / self.norm_direction_vector()