Add cross product impleimentation

This commit is contained in:
Corran Webster
2025-10-24 16:21:50 +01:00
parent 64f06ce7c1
commit 437be17f51

View File

@@ -36,6 +36,14 @@ class Vector(object):
z = self.z + other.z
return self.__class__(x, y, z)
def __mul__(self, other):
if not isinstance(other, Vector):
return NotImplemented
x = self.y * other.z - self.z * other.y
y = self.z * other.x - self.x * other.z
z = self.x * other.y - self.y * other.x
return self.__class__(x, y, z)
if __name__ == "__main__":
v1 = Vector(3, 4, 0)