LoginSignup
1
0

More than 5 years have passed since last update.

The sample of diff, zeros_like, cumsum, linspace and interp in numpy

Posted at
phi = np.arange(0, 10*np.pi, 0.1)
a = 1
x = a*phi*np.cos(phi)
y = a*phi*np.sin(phi)
print(phi)
print(x)
print(y)
exit()
dr = (np.diff(x)**2 + np.diff(y)**2)**.5 # segment lengths
print(dr)
r = np.zeros_like(x)
print(r)
r[1:] = np.cumsum(dr)                # integrate path
print(r)
r_int = np.linspace(0, r.max(), 200) # regular spaced path
x_int = np.interp(r_int, r, x)       # integrate path
y_int = np.interp(r_int, r, y)
print(r_int, x_int, y_int)

Refs.

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0