|
|
|
|
|
|
|
|
def resample_segments(segments, n=1000): |
|
|
def resample_segments(segments, n=1000): |
|
|
# Up-sample an (n,2) segment |
|
|
# Up-sample an (n,2) segment |
|
|
for i, s in enumerate(segments): |
|
|
for i, s in enumerate(segments): |
|
|
|
|
|
s = np.concatenate((s, s[0:1, :]), axis=0) |
|
|
x = np.linspace(0, len(s) - 1, n) |
|
|
x = np.linspace(0, len(s) - 1, n) |
|
|
xp = np.arange(len(s)) |
|
|
xp = np.arange(len(s)) |
|
|
segments[i] = np.concatenate([np.interp(x, xp, s[:, i]) for i in range(2)]).reshape(2, -1).T # segment xy |
|
|
segments[i] = np.concatenate([np.interp(x, xp, s[:, i]) for i in range(2)]).reshape(2, -1).T # segment xy |