From 5f52f2933771233bec364d4270e0acafb9fadf26 Mon Sep 17 00:00:00 2001 From: DaniloF14385 <121195680+DaniloF14385@users.noreply.github.com> Date: Wed, 15 Feb 2023 19:56:49 +0000 Subject: [PATCH 1/4] Started the Vector2d class --- main.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 104be10..800e7ed 100644 --- a/main.py +++ b/main.py @@ -1,2 +1,10 @@ class Vector2d: - pass \ No newline at end of file + def __init__(self,x,y): + self.x = x + self.y = y + def __repr__(self): + return f"Vector2d(x={self.x},y={self.y})" + def __str__(self): + return f"{self.x}i + {self.y}j" + def __abs__(self): + return ((self.x**2) + (self.y**2))**(1/2) \ No newline at end of file From 8c63825ffd8191fc255cc9e66d800965423d1657 Mon Sep 17 00:00:00 2001 From: DaniloF14385 <121195680+DaniloF14385@users.noreply.github.com> Date: Thu, 16 Feb 2023 20:09:13 +0000 Subject: [PATCH 2/4] Neg and Add function --- main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 800e7ed..fcd0d0d 100644 --- a/main.py +++ b/main.py @@ -7,4 +7,8 @@ def __repr__(self): def __str__(self): return f"{self.x}i + {self.y}j" def __abs__(self): - return ((self.x**2) + (self.y**2))**(1/2) \ No newline at end of file + return ((self.x**2) + (self.y**2))**(1/2) + def __neg__(self): + return Vector2d(self.x*-1,self.y*-1) + def __add__(self,other): + return Vector2d((self.x + other.x),(self.y + other.y)) \ No newline at end of file From 1f4fccc5b1dd3b27a2ec7a4e05e7456d9d14e91d Mon Sep 17 00:00:00 2001 From: DaniloF14385 <121195680+DaniloF14385@users.noreply.github.com> Date: Wed, 22 Feb 2023 19:51:23 +0000 Subject: [PATCH 3/4] eq and sub function added --- main.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index fcd0d0d..8fb53d8 100644 --- a/main.py +++ b/main.py @@ -11,4 +11,11 @@ def __abs__(self): def __neg__(self): return Vector2d(self.x*-1,self.y*-1) def __add__(self,other): - return Vector2d((self.x + other.x),(self.y + other.y)) \ No newline at end of file + return Vector2d((self.x + other.x),(self.y + other.y)) + def __eq__(self,other): + if ({self.x} == {other.x}) == True: + if ({self.y} == {other.y}) == True: + return True + return False + def __sub__(self,other): + return Vector2d((self.x - other.x),(self.y - other.y)) From 74edea17b8311d61427399522faf9884e653e0b3 Mon Sep 17 00:00:00 2001 From: DaniloF14385 <121195680+DaniloF14385@users.noreply.github.com> Date: Thu, 23 Feb 2023 17:36:02 +0000 Subject: [PATCH 4/4] angle tan added --- main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.py b/main.py index 8fb53d8..1b55fde 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,4 @@ +import math class Vector2d: def __init__(self,x,y): self.x = x @@ -19,3 +20,6 @@ def __eq__(self,other): return False def __sub__(self,other): return Vector2d((self.x - other.x),(self.y - other.y)) + def angle(self): + tan = math.atan2((self.y),(self.x)) + return math.degrees(tan) \ No newline at end of file