-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Vector-likes in all operations #56
Conversation
I like where we're going with this. Suggesting we put most of this under a class method |
Standard python is that conversion should be in the constructor, ie |
I only suggest a class method because the constructor is |
ppb_vector/vector2.py
Outdated
@@ -67,16 +84,18 @@ def __getitem__(self, item): | |||
raise TypeError | |||
|
|||
def __repr__(self): | |||
return "Vector2({}, {})".format(self.x, self.y) | |||
return "{}({}, {})".format(type(self).__name__, self.x, self.y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're modifying this, lets switch to F-strings.
ppb_vector/vector2.py
Outdated
@@ -115,6 +134,7 @@ def reflect(self, surface_normal: 'Vector2') -> 'Vector2': | |||
""" | |||
Calculate the reflection of the vector against a given surface normal | |||
""" | |||
surface_normal = _mkvector(surface_normal) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do this, we need to change the type hint.
On that front, we should probably build a union or type var for this.
Addressed everything. Not super happy with the name |
I would have just used |
|
Make all operations work with vector-likes.