From 96834ca17749729922aaf1a95c43b76868c46d91 Mon Sep 17 00:00:00 2001 From: 44013031 <121196625+44013031@users.noreply.github.com> Date: Wed, 15 Feb 2023 03:48:04 +0000 Subject: [PATCH 01/10] 2) strings forms 3) returning it but in a form with variables 4) ab returns abolute value of #, confused on how to print --- main.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 104be10..2892a99 100644 --- a/main.py +++ b/main.py @@ -1,2 +1,15 @@ class Vector2d: - pass \ No newline at end of file + def __init__(self,x,y): + self.x = x + self.y = y + + def __reper__(self): + return f"Vector 2D(x = {self.x},y-{self.y}" + + def __str__(self): + return f"Vector 2D({self.x}i + {self.y}j" + + def __abs__(self): + lenght = self.x**2 + self.y**2 + return(lenght) + From a8e669dec38afc910659dfa313f95fff5c322a4f Mon Sep 17 00:00:00 2001 From: 44013031 <121196625+44013031@users.noreply.github.com> Date: Wed, 15 Feb 2023 14:04:44 +0000 Subject: [PATCH 02/10] 1/2 instead of square root --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 2892a99..9f7dea7 100644 --- a/main.py +++ b/main.py @@ -11,5 +11,5 @@ def __str__(self): def __abs__(self): lenght = self.x**2 + self.y**2 - return(lenght) + return lenght ** (1/2) From f0366987f48264fd7f5cf2c244f4b14938375045 Mon Sep 17 00:00:00 2001 From: 44013031 <121196625+44013031@users.noreply.github.com> Date: Wed, 15 Feb 2023 19:56:10 +0000 Subject: [PATCH 03/10] abs function use (0.5) and no vectord 2d str --- main.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 9f7dea7..fc6a155 100644 --- a/main.py +++ b/main.py @@ -10,6 +10,5 @@ def __str__(self): return f"Vector 2D({self.x}i + {self.y}j" def __abs__(self): - lenght = self.x**2 + self.y**2 - return lenght ** (1/2) - + lenght = (self.x**2 + self.y**2 ) ** (1/2) + return lenght From 57bd3d12e9bee3074cc0320e82af254ba41df9b9 Mon Sep 17 00:00:00 2001 From: 44013031 <121196625+44013031@users.noreply.github.com> Date: Thu, 16 Feb 2023 19:41:51 +0000 Subject: [PATCH 04/10] FInished the previous functions --- main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index fc6a155..3514403 100644 --- a/main.py +++ b/main.py @@ -3,12 +3,12 @@ def __init__(self,x,y): self.x = x self.y = y - def __reper__(self): - return f"Vector 2D(x = {self.x},y-{self.y}" + def __repr__(self): + return f"Vector2d(x={self.x},y={self.y})" def __str__(self): - return f"Vector 2D({self.x}i + {self.y}j" + return f"{str(self.x)}i + {str(self.y)}j" def __abs__(self): - lenght = (self.x**2 + self.y**2 ) ** (1/2) + lenght = (self.x**2 + self.y**2 ) ** (1/2) return lenght From 9c50b55ddd96dd96f5127cc0cbef2b046598b6d5 Mon Sep 17 00:00:00 2001 From: 44013031 <121196625+44013031@users.noreply.github.com> Date: Thu, 16 Feb 2023 20:11:51 +0000 Subject: [PATCH 05/10] Work in progress, neg function completed --- main.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.py b/main.py index 3514403..19b0fd2 100644 --- a/main.py +++ b/main.py @@ -12,3 +12,8 @@ def __str__(self): def __abs__(self): lenght = (self.x**2 + self.y**2 ) ** (1/2) return lenght + + def __neg__(self): + return f"Vector2d(-{self.x},-{self.y})" + + From 1f00bafc242b5673822697621ab6a77cdf8d3077 Mon Sep 17 00:00:00 2001 From: 44013031 <121196625+44013031@users.noreply.github.com> Date: Fri, 17 Feb 2023 02:35:32 +0000 Subject: [PATCH 06/10] Definitely did lots of work today --- main.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 19b0fd2..3861ece 100644 --- a/main.py +++ b/main.py @@ -5,7 +5,6 @@ def __init__(self,x,y): def __repr__(self): return f"Vector2d(x={self.x},y={self.y})" - def __str__(self): return f"{str(self.x)}i + {str(self.y)}j" @@ -15,5 +14,5 @@ def __abs__(self): def __neg__(self): return f"Vector2d(-{self.x},-{self.y})" - - + def __add__(self,other): + return f"Vector2d({self.x+other.x},{self.y+other.y})" From 726d4522d1d054089e9e31ce236100c309112853 Mon Sep 17 00:00:00 2001 From: 44013031 <121196625+44013031@users.noreply.github.com> Date: Tue, 21 Feb 2023 02:38:57 +0000 Subject: [PATCH 07/10] fixed neg method --- main.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 3861ece..1a98b78 100644 --- a/main.py +++ b/main.py @@ -5,14 +5,16 @@ def __init__(self,x,y): def __repr__(self): return f"Vector2d(x={self.x},y={self.y})" + def __str__(self): return f"{str(self.x)}i + {str(self.y)}j" - def __abs__(self): + def __abs__(self): lenght = (self.x**2 + self.y**2 ) ** (1/2) return lenght def __neg__(self): - return f"Vector2d(-{self.x},-{self.y})" + return Vector2d(self.x*-1,self.y*-1) + ; def __add__(self,other): - return f"Vector2d({self.x+other.x},{self.y+other.y})" + return f"Vector2d({self.x+other.x},{self.y+other.y})" \ No newline at end of file From 406bda40f08f406ea7d48097e6abf8de5708b532 Mon Sep 17 00:00:00 2001 From: 44013031 <121196625+44013031@users.noreply.github.com> Date: Wed, 22 Feb 2023 19:58:55 +0000 Subject: [PATCH 08/10] 2/22/23 work's --- main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 1a98b78..9a951d1 100644 --- a/main.py +++ b/main.py @@ -15,6 +15,11 @@ def __abs__(self): def __neg__(self): return Vector2d(self.x*-1,self.y*-1) - ; def __add__(self,other): - return f"Vector2d({self.x+other.x},{self.y+other.y})" \ No newline at end of file + return f"Vector2d({self.x+other.x},{self.y+other.y})" + def __eq__(self,other): + if self.x == other.x and self.y == other.y: + return True + def __sub__(self,other): + return f"Vector2d({self.x - other.x},{self.y-other.y})" + From 54387d93f2a75e9e1bc314bdd1ca0b37bddbd77d Mon Sep 17 00:00:00 2001 From: 44013031 <121196625+44013031@users.noreply.github.com> Date: Thu, 23 Feb 2023 17:04:07 +0000 Subject: [PATCH 09/10] eq and sub completed functions --- main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/main.py b/main.py index 9a951d1..5bd005b 100644 --- a/main.py +++ b/main.py @@ -22,4 +22,3 @@ def __eq__(self,other): return True def __sub__(self,other): return f"Vector2d({self.x - other.x},{self.y-other.y})" - From be9952abd953e0293419b97c0ced3001a987f099 Mon Sep 17 00:00:00 2001 From: 44013031 <121196625+44013031@users.noreply.github.com> Date: Thu, 23 Feb 2023 19:58:11 +0000 Subject: [PATCH 10/10] def angle completed --- main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.py b/main.py index 5bd005b..935279d 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,4 @@ +import math class Vector2d: def __init__(self,x,y): self.x = x @@ -22,3 +23,6 @@ def __eq__(self,other): return True def __sub__(self,other): return f"Vector2d({self.x - other.x},{self.y-other.y})" + + def angle(self): + return math.degrees(math.atan2(self.x, self.y))