class Vecteur:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def __str__(self):
return f"Vecteur({self.x}, {self.y}, {self.z})"
def __eq__(self, other):
return self.x == other.x and self.y == other.y and self.z == other.z
def __mul__(self, k):
return Vecteur(k* self.x, k * self.y, k * self.z)
def __rmul__(self, k):
return Vecteur(k* self.x, k * self.y, k * self.z)
def __add__(self, other):
return Vecteur(self.x + other.x, self.y + other.y, self.z + other.z)
def __sub__(self, other):
return Vecteur(self.x - other.x, self.y - other.y, self.z - other.z)
def scalaire(self, other):
return self.x * other.x + self.y * other.y + self.z * other.z
def norme(self):
return (self.x**2 + self.y**2 +self.z**2)**0.5
def colineaire(self, other):
cdt1 = self.x * other.y == self.y * other.x
cdt2 = self.z * other.y == self.y * other.z
return cdt1 and cdt2
u = Vecteur(1, 2, -3)
v = Vecteur(0, -1, 3)
w = Vecteur(2, 4, -6)
print(u.colineaire(v))
print(u.colineaire(w))
To embed this program on your website, copy the following code and paste it into your website's HTML: