简体   繁体   中英

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. 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.

Basically, how do I generate a second B-Spline that is parameterized according to its length? 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.

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"

See also this presentation for more references (slide 6 states the impossibility theorem).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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