add multiplication
This commit is contained in:
parent
5d11939769
commit
cfaef4f2c2
1 changed files with 9 additions and 0 deletions
9
utils.py
9
utils.py
|
@ -59,6 +59,15 @@ class Vec:
|
||||||
|
|
||||||
return Vec(x, y, self.z - other.z)
|
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':
|
def div(self, factor: float) -> 'Vec':
|
||||||
x = self.x / factor
|
x = self.x / factor
|
||||||
y = self.y / factor
|
y = self.y / factor
|
||||||
|
|
Reference in a new issue