mirror of
https://github.com/snowykami/mbcp.git
synced 2024-11-22 06:07:37 +08:00
✨ vector: 添加投影向量方法
This commit is contained in:
parent
74daf9e2e7
commit
b580a27b27
@ -104,6 +104,20 @@ class Vector3:
|
||||
self.y /= 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
|
||||
def np_array(self) -> 'np.ndarray':
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user