曲线的曲率(curvature):就是针对曲线上某个点的切线方向角对弧长的转动率,通过微分来定义,表明曲线偏离直线的程度
。数学上表明曲线在某一点的弯曲程度的数值。
曲率越大,表示曲线的弯曲程度越大。曲率的倒数就是曲率半径。
环境安装
# 在终端中输入
pip install numpy -i https://pypi.tsinghua.edu.cn/simple
pip install matplotlib -i https://pypi.tsinghua.edu.cn/simple
pip install scipy -i https://pypi.tsinghua.edu.cn/simple
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import make_interp_spline
import matplotlib
matplotlib.use('TkAgg')
x = np.linspace(0, 20, 10)
y = np.random.uniform(-10, 10, 10)
plt.figure(figsize=(10, 5), dpi=100)
# plt.plot(x, y)
plt.scatter(x, y, c="red")
plt.grid(True)
plt.show()
plt.figure(figsize=(10, 5), dpi=100)
plt.plot(x, y)
plt.scatter(x, y, c="red")
plt.grid(True)
plt.show()
x_smooth = np.linspace(x.min(), x.max(), 400)
y_smooth = make_interp_spline(x, y)(x_smooth)
plt.figure(figsize=(10, 5), dpi=100)
plt.grid(True)
plt.plot(x_smooth, y_smooth)
plt.show()
x_smooth = np.linspace(x.min(), x.max(), 400)
y_smooth = make_interp_spline(x, y)(x_smooth)
plt.figure(figsize=(10, 5), dpi=100)
plt.grid(True)
plt.plot(x_smooth, y_smooth)
plt.plot(x, y)
plt.scatter(x, y, c="red")
plt.show()
# -*- coding:utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import make_interp_spline
import matplotlib
matplotlib.use('TkAgg')
x = np.linspace(0, 20, 10)
y = np.random.uniform(-10, 10, 10)
plt.figure(figsize=(10, 5), dpi=100)
plt.scatter(x, y, c="red")
plt.grid(True)
plt.show()
plt.figure(figsize=(10, 5), dpi=100)
plt.plot(x, y)
plt.scatter(x, y, c="red")
plt.grid(True)
plt.show()
x_smooth = np.linspace(x.min(), x.max(), 400)
y_smooth = make_interp_spline(x, y)(x_smooth)
plt.figure(figsize=(10, 5), dpi=100)
plt.grid(True)
plt.plot(x_smooth, y_smooth)
plt.show()
x_smooth = np.linspace(x.min(), x.max(), 400)
y_smooth = make_interp_spline(x, y)(x_smooth)
plt.figure(figsize=(10, 5), dpi=100)
plt.grid(True)
plt.plot(x_smooth, y_smooth)
plt.plot(x, y)
plt.scatter(x, y, c="red")
plt.show()
print('over...')