作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要连 catch 体上的两个点,这样线(边缘)就会停留在球体的表面上并且不会穿过它。
现在我有:
绘制了边缘,但它们穿过球体。
期望的结果:
最佳答案
这是 spherical linear interpolation 的实现或在此 answer 中提出的 slerp :
import numpy as np
import matplotlib.pylab as plt
def slerp(p1, p2, t):
omega = np.arccos( p1.dot(p2) )
sin_omega = np.sin(omega)
t = t[:, np.newaxis]
return ( np.sin( (1-t)*omega )*p1 + np.sin( t*omega )*p2 )/sin_omega
p1 = np.array([1, 0, 0])
p2 = np.array([0, 1, 0])
t = np.linspace(0, 1, 30)
arc = slerp(p1, p2, t)
plt.plot( arc[:, 0], arc[:, 1] );
plt.axis('square');
给出 2D 形式:
关于python - 连 catch 体表面上的两点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52007002/
我是一名优秀的程序员,十分优秀!