Joe*_*elt 10
对于对这个问题感兴趣的人,我按照马修的建议提出了这个实现:
def hanging_line(point1, point2):
import numpy as np
a = (point2[1] - point1[1])/(np.cosh(point2[0]) - np.cosh(point1[0]))
b = point1[1] - a*np.cosh(point1[0])
x = np.linspace(point1[0], point2[0], 100)
y = a*np.cosh(x) + b
return (x,y)
Run Code Online (Sandbox Code Playgroud)
结果如下:
import matplotlib.pyplot as plt
point1 = [0,1]
point2 = [1,2]
x,y = hanging_line(point1, point2)
plt.plot(point1[0], point1[1], 'o')
plt.plot(point2[0], point2[1], 'o')
plt.plot(x,y)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7495 次 |
最近记录: |