EDIT: I found a Vector class that worked nicely enough for my purposes, paired with the kinematics values I'd already figured out, so I'm good now! Here's the class, for those interested:
Code: Select all
class Vector:
def __init__(self, x: float, y: float):
self.x = x
self.y = y
# Vector operator overloads
def __add__(self, other):
if isinstance(other, self.__class__):
return Vector(self.x + other.x, self.y + other.y)
return Vector(self.x + other, self.y + other)
def __sub__(self, other):
if isinstance(other, self.__class__):
return Vector(self.x - other.x, self.y - other.y)
return Vector(self.x - other, self.y - other)
def __mul__(self, other):
if isinstance(other, self.__class__):
return Vector(self.x * other.x, self.y * other.y)
return Vector(self.x * other, self.y * other)
def __rmul__(self, other):
return self.__mul__(other)
def __truediv__(self, other):
if isinstance(other, self.__class__):
return Vector(self.x / other.x, self.y / other.y)
return Vector(self.x / other, self.y / other)
def __eq__(self, other):
if isinstance(other, self.__class__):
return self.x == other.x and self.y == other.y
return self.x == other and self.y == other
def __neg__(self):
return Vector(-self.x, -self.y)
def make_int_tuple(self):
return int(self.x), int(self.y)
def set(self, vec):
self.x = vec.x
self.y = vec.y