[英]How to find arc length / curve length reparameterization of b-spline curve?
我正在尝试从一组控制点和一个结向量生成二次 b 样条曲线。 如何重新参数化曲线,以便根据弧/曲线长度对其进行参数化? 例如,如果曲线参数化为 t=0 到 t=1,则输入 t=0.2 应该给出沿曲线的距离是其总长度的 20% 时出现的曲线坐标。
基本上,我如何生成根据其长度参数化的第二个 B-Spline? 我对一个合理近似的解决方案没意见。
此代码示例说明了我的问题 - 即使参数值 (u) 是等距的,但图中生成的红色星号也不是等距的。
from splipy import Curve, BSplineBasis
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
ORDER = 3 # quadratic B-spline
cp = np.array([ [0,0,0], [0, 1,0], [0,2,0], [0,3,0], [1,3,0],[2,3,0], [3,3,0]])
num_cp=cp.shape[0]
# Create Curve
knot = np.array([0. , 0. , 0. , 0.2, 0.4, 0.6, 0.8, 1. , 1. , 1. ])
basis = BSplineBasis(order=ORDER, knots=knot, periodic=-1)
curve = Curve(basis=basis, controlpoints=cp, rational=False)
# Sample along curve
t = np.linspace(0,1,100)
points_along_curve = curve(t)
# Sample 10 linear points to illustrate they are not equally spaced along curve
u = np.linspace(0,1,10)
points_10_uneven = curve(u)
# Plot results
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# Plot curve
x,y,z = points_along_curve.T
ax.plot(x,y,z,'b-')
# Plot 10 linearly-sampled points (to illustrate they are not equally spaced along curve)
x,y,z = points_10_uneven.T
ax.plot(x,y,z,'r*')
plt.show()
请注意,靠近曲线末端的红色星号比曲线弯曲处的红色星号间距更大。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.