From 59d69f5fc1b56b80a5ac46a239e14fc97b0582db Mon Sep 17 00:00:00 2001 From: snowy Date: Wed, 7 Aug 2024 01:05:28 +0800 Subject: [PATCH] :bug: protected property --- mbcp/mp_math/vector.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mbcp/mp_math/vector.py b/mbcp/mp_math/vector.py index a3c9ccb..5ab7995 100644 --- a/mbcp/mp_math/vector.py +++ b/mbcp/mp_math/vector.py @@ -82,7 +82,7 @@ class Vector3: def __add__(self, other): if isinstance(other, Vector3): - return Vector3(self._x + other._x, self._y + other._y, self._z + other._z) + return Vector3(self._x + other.x, self._y + other.y, self._z + other.z) elif isinstance(other, Point3): return Point3(self._x + other.x, self._y + other.y, self._z + other.z) else: @@ -107,7 +107,7 @@ class Vector3: :return: """ if isinstance(other, Vector3): - return Vector3(self._x - other._x, self._y - other._y, self._z - other._z) + return Vector3(self._x - other.x, self._y - other.y, self._z - other.z) elif isinstance(other, Point3): return Point3(self._x - other.x, self._y - other.y, self._z - other.z) else: @@ -142,7 +142,7 @@ class Vector3: if isinstance(other, (int, float)): return Vector3(self._x * other, self._y * other, self._z * other) elif isinstance(other, Vector3): - return self._x * other._x + self._y * other._y + self._z * other._z + return self._x * other.x + self._y * other.y + self._z * other.z else: raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'") @@ -160,9 +160,9 @@ class Vector3: :param other: 另一个向量 :return: 叉乘结果向量 """ - return Vector3(self._y * other._z - self._z * other._y, - self._z * other._x - self._x * other._z, - self._x * other._y - self._y * other._x) + return Vector3(self._y * other.z - self._z * other.y, + self._z * other.x - self._x * other.z, + self._x * other.y - self._y * other.x) def __truediv__(self, other: float) -> 'Vector3': return Vector3(self._x / other, self._y / other, self._z / other)