Last active
August 11, 2016 03:53
-
-
Save jaybo/49323e450d3a8932656c4176e5eb0884 to your computer and use it in GitHub Desktop.
2D boundary interpolation in numpy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from scipy.interpolate import interp1d | |
x = [0, 1, 1, 0, 0] | |
y = [0, 0, 1, 1, 0] | |
orig_len = len(x) | |
t = np.arange(len(x)) | |
ti = np.linspace(0, orig_len-1, 100 * orig_len) | |
xi = interp1d(t, x, kind='linear')(ti) | |
yi = interp1d(t, y, kind='linear')(ti) | |
print xi | |
print yi | |
fig, ax = plt.subplots() | |
ax.plot(xi, yi) | |
ax.plot(x, y) | |
ax.margins(0.05) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment