1
0

sphear_qint.m 632 B

12345678910111213141516171819202122
  1. %% -*- mode: octave -*-
  2. %%
  3. %% https://ccrma.stanford.edu/~jos/sasp/Matlab_listing_qint_m.html
  4. %%
  5. %% QINT Quadratic interpolation of 3 uniformly spaced samples
  6. %%
  7. %% [p,y,a] = qint(ym1,y0,yp1)
  8. %%
  9. %% returns extremum-location p, height y, and half-curvature a
  10. %% of a parabolic fit through three points.
  11. %% The parabola is given by y(x) = a*(x-p)^2+b,
  12. %% where y(-1)=ym1, y(0)=y0, y(1)=yp1.
  13. function [p,y,a] = sphear_qint(ym1,y0,yp1)
  14. p = (yp1 - ym1)/(2*(2*y0 - yp1 - ym1));
  15. if nargout>1
  16. y = y0 - 0.25*(ym1-yp1)*p;
  17. end;
  18. if nargout>2
  19. a = 0.5*(ym1 - 2*y0 + yp1);
  20. end;
  21. end