mirror of
https://github.com/snowykami/mbcp.git
synced 2024-11-22 06:07:37 +08:00
🐛 fix ε accuracy
This commit is contained in:
parent
39d056fb47
commit
b45d85a8c7
@ -170,15 +170,15 @@ class Vector3:
|
||||
else:
|
||||
raise TypeError(f"unsupported operand type(s) for -: '{type(other)}' and 'Vector3'")
|
||||
|
||||
@overload
|
||||
def __mul__(self, other: RealNumber) -> 'Vector3':
|
||||
...
|
||||
|
||||
@overload
|
||||
def __mul__(self, other: 'Vector3') -> 'Vector3':
|
||||
...
|
||||
|
||||
def __mul__(self, other: 'RealNumber | Vector3') -> 'Vector3':
|
||||
@overload
|
||||
def __mul__(self, other: RealNumber) -> 'Vector3':
|
||||
...
|
||||
|
||||
def __mul__(self, other: 'int | float | Vector3') -> 'Vector3':
|
||||
"""
|
||||
数组运算 非点乘。点乘使用@,叉乘使用cross。
|
||||
Args:
|
||||
@ -186,15 +186,16 @@ class Vector3:
|
||||
|
||||
Returns:
|
||||
"""
|
||||
if isinstance(other, RealNumber):
|
||||
return Vector3(self.x * other, self.y * other, self.z * other)
|
||||
elif isinstance(other, Vector3):
|
||||
|
||||
if isinstance(other, Vector3):
|
||||
return Vector3(self.x * other.x, self.y * other.y, self.z * other.z)
|
||||
elif isinstance(other, (float, int)):
|
||||
return Vector3(self.x * other, self.y * other, self.z * other)
|
||||
else:
|
||||
raise TypeError(f"unsupported operand type(s) for *: 'Vector3' and '{type(other)}'")
|
||||
|
||||
def __rmul__(self, other: RealNumber) -> 'Vector3':
|
||||
return Vector3(self.x * other, self.y * other, self.z * other)
|
||||
def __rmul__(self, other: float | int) -> 'Vector3':
|
||||
return self.__mul__(other)
|
||||
|
||||
def __matmul__(self, other: 'Vector3') -> float:
|
||||
"""
|
||||
@ -226,6 +227,3 @@ y_axis = Vector3(0, 1, 0)
|
||||
"""y轴单位向量"""
|
||||
z_axis = Vector3(0, 0, 1)
|
||||
"""z轴单位向量"""
|
||||
|
||||
v1: Vector3 = Vector3(1, 2, 3) * 3.0
|
||||
v2: Vector3 = 3.0 * Vector3(1, 2, 3)
|
||||
|
Loading…
Reference in New Issue
Block a user