Add __iadd__ and __isub__ to GyroVector.

This commit is contained in:
bʰedoh₂ swé 2024-04-06 23:45:25 +05:00
parent c745c6a82b
commit 1494f28a78

11
gyro.py
View File

@ -100,6 +100,17 @@ class GyroVector:
cAdd, cGyr = MobiusAddGyr(gA.cPos, gB.cPos) cAdd, cGyr = MobiusAddGyr(gA.cPos, gB.cPos)
return GyroVector(cAdd, gA.cRot * gB.cRot * cGyr) return GyroVector(cAdd, gA.cRot * gB.cRot * cGyr)
def __iadd__(self, gA):
cAdd, cGyr = MobiusAddGyr(self.cPos, gA.cPos)
self.cPos = cAdd
self.cRot = self.cRot * gA.cRot * cGyr
def __isub__(self, gA):
ngA = -gA
cAdd, cGyr = MobiusAddGyr(self.cPos, ngA.cPos)
self.cPos = cAdd
self.cRot = self.cRot * ngA.cRot * cGyr
def __neg__(self): def __neg__(self):
return GyroVector(-(self.cRot * self.cPos), 1/self.cRot) return GyroVector(-(self.cRot * self.cPos), 1/self.cRot)