From cfaef4f2c2eeef843fafb0e2b5feec5d1a51b3fc Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 31 Mar 2023 04:08:18 +0200 Subject: [PATCH] add multiplication --- utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/utils.py b/utils.py index e7a3e73..d1afa7c 100644 --- a/utils.py +++ b/utils.py @@ -59,6 +59,15 @@ class Vec: return Vec(x, y, self.z - other.z) + def times(self, factor: float) -> 'Vec': + x = self.x * factor + y = self.y * factor + + if self.z == None: + return Vec(x, y) + + return Vec(x, y, self.z * factor) + def div(self, factor: float) -> 'Vec': x = self.x / factor y = self.y / factor