简体   繁体   English

如何找到b样条曲线的弧长/曲线长度重新参数化?

[英]How to find arc length / curve length reparameterization of b-spline curve?

I'm trying to generate a quadratic b-spline curve from a set of controlpoints and a knot vector.我正在尝试从一组控制点和一个结向量生成二次 b 样条曲线。 How can I reparametrize the curve so that it is parameterized according to the arc / curve length?如何重新参数化曲线,以便根据弧/曲线长度对其进行参数化? For example, if the curve is parameterized for t=0 to t=1, inputting t=0.2 should give the curve coordinate that occurs when the distance along the curve is 20% of it's total length.例如,如果曲线参数化为 t=0 到 t=1,则输入 t=0.2 应该给出沿曲线的距离是其总长度的 20% 时出现的曲线坐标。

Basically, how do I generate a second B-Spline that is parameterized according to its length?基本上,我如何生成根据其长度参数化的第二个 B-Spline? I am OK with a solution that is reasonably approximate.我对一个合理近似的解决方案没意见。

This code example illustrates my issue - the resulting red asterisks on the plot are not equally spaced, even though the parametric values (u) were.此代码示例说明了我的问题 - 即使参数值 (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()

在此处输入图片说明

Note that the red asterisks near the ends of the curve are more spaced apart than the red asterisks at the bend in the curve.请注意,靠近曲线末端的红色星号比曲线弯曲处的红色星号间距更大。

Unfortunately, what you are asking for cannot be done in general.不幸的是,您所要求的一般无法完成 A spline curve is a piecewise polynomial parametric curve and as noted for example here :样条曲线是分段多项式参数曲线, 如下所示

"..it is known (proved by R. Farouki and also well-known in geometry) that polynomial curves cannot be parameterized to have unit speed (ie, arc-length parameterization), the chord length can only be an approximation" “..众所周知(由 R. Farouki 证明并且在几何学中也是众所周知的)多项式曲线不能被参数化为具有单位速度(即弧长参数化),弦长只能是一个近似值”

See also this presentation for more references (slide 6 states the impossibility theorem).另请参阅此演示文稿以获取更多参考资料(幻灯片 6 说明了不可能定理)。

There is, however, literature on approximating an arc-length parameterization using spline (or rational spline) curves and the links above are a good place to start.然而,有关于使用样条(或有理样条)曲线近似弧长参数化的文献,上面的链接是一个很好的起点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM