From 1494f28a78238efde95877e848db200de751574a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?b=CA=B0edoh=E2=82=82=20sw=C3=A9?= Date: Sat, 6 Apr 2024 23:45:25 +0500 Subject: [PATCH] Add __iadd__ and __isub__ to GyroVector. --- gyro.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gyro.py b/gyro.py index 7396cb2..57f3b8b 100644 --- a/gyro.py +++ b/gyro.py @@ -100,6 +100,17 @@ class GyroVector: cAdd, cGyr = MobiusAddGyr(gA.cPos, gB.cPos) 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): return GyroVector(-(self.cRot * self.cPos), 1/self.cRot)