vector: 添加投影向量方法

This commit is contained in:
远野千束 2024-09-07 00:44:06 +08:00
parent 74daf9e2e7
commit b580a27b27

View File

@ -104,6 +104,20 @@ class Vector3:
self.y /= length self.y /= length
self.z /= length self.z /= length
def project(self, other: 'Vector3') -> 'Vector3':
r"""
返回自向量在另一个向量上的投影向量
:::tip
投影向量计算公式:
$$ \text{proj}_v(u) = \frac{u \cdot v}{|v|^2} \cdot v $$
:::
Args:
other ([`Vector3`](#class-vector3)): 另一个向量
Returns:
[`Vector3`](#class-vector3): 投影向量
"""
return (self @ other / other.length) * other.unit
@property @property
def np_array(self) -> 'np.ndarray': def np_array(self) -> 'np.ndarray':
""" """