标签:并且 pytho 点积 span rect force tar `` 图形
设: $ a = {a_1,a_2,\cdots,a_n} \
b = {b_1,b_2,\cdots,b_n}
$ 时
几何意义 :向量$ \vec{a} $在向量 $ \vec{b} \(方向上的投影与向量\) \vec{b} $的模的乘积
运算结果: 标量(常用于物理)/数量(常用于数学)
叉积的长度|a×b|可以解释成这两个叉乘向量a,b共起点时,所构成平行四边形的面积。据此有:混合积[abc]=(a×b)·c可以得到以a,b,c为棱的平行六面体的体积。
注:向量积≠向量的积(向量的积一般指点乘)
一定要清晰地区分开向量积(矢积)与数量积(标积)。
def polar_force(
magnitude: float, # $ \rho $ 值
angle: float, # 角度 θ
radian_mode: bool = False # 是否弧度,
) -> List[float]: # (x,y)
- 向量的叉积
numpy.cross
numpy.cross(a, b, axisa=-1, axisb=-1, axisc=-1, axis=None)
返回两个(数组)向量的叉积。
- 是否静态平衡
def in_static_equilibrium(
forces: ndarray,
location: ndarray,
eps: float = 10 ** -1
) -> bool:
moments: ndarray = cross(location, forces)
sum_moments: float = sum(moments)
return abs(sum_moments) < eps
### 代码
in_static_equilibrium.py{..\src\arithmetic_analysis\in_static_equilibrium.py}
```python
"""
Prepare
1 . sys.path 中增加 TheAlgorithms\src 子模块
"""
import sys
sys.path.append(‘E:\dev\AI\TheAlgorithms\src‘)
案例一:极坐标与直角坐标的转化
Resolves force along rectangular components.
(force, angle) => (force_x, force_y)
>>> polar_force(10, 45)
[7.0710678118654755, 7.071067811865475]
>>> polar_force(10, 3.14, radian_mode=True)
[-9.999987317275394, 0.01592652916486828]
from arithmetic_analysis.in_static_equilibrium import polar_force
"""
"""
print(polar_force(10, 45)) # [7.0710678118654755, 7.071067811865475]
print(polar_force(10, 3.14, radian_mode=True)) #[-9.999987317275394, 0.01592652916486828]
[7.0710678118654755, 7.0710678118654755]
[-9.999987317275394, 0.01592652916486828]
Check if a system is in equilibrium.
It takes two numpy.array objects.
forces ==> [
[force1_x, force1_y],
[force2_x, force2_y],
....]
location ==> [
[x1, y1],
[x2, y2],
....]
from arithmetic_analysis.in_static_equilibrium import in_static_equilibrium
from numpy import array
"""
"""
force = array([[1, 1], [-1, 2]])
location = array([[1, 0], [10, 0]])
print(in_static_equilibrium(force, location)) #False
False
标签:并且 pytho 点积 span rect force tar `` 图形
原文地址:https://www.cnblogs.com/it88-laobing/p/14885483.html