# Last edited on 2021-07-31 12:02:15 by jstolfi from math import sin, cos, pi from basis_sample import basis_sample def basis_2d_hartley_sample(fr, s): # Samples at the sample points {s} the 2d Hartley basis functions whose # frequency vectors are in the list {fr}. # # Each frequency vector {fr[i]} should be a 2-tuple of signed ints. # Each sample point {s[k]} should be a 2-tuple of floats. # # Returns a list {B} of {nf} lists, each element being a list of # {ns=len(s)} floats; such that {B[i][k]} is the 2d Hartley basis # element with frequency {fr[i]} evaluated at the point {s[k]}. nb = len(fr) def basis_hartley(i, p): fxi, fyi = fr[i] ang = (p[0]*fxi + p[1]*fyi + 0.25)*pi Bp = 0.5*(1 + cos(ang)) return Bp; # ...................................................................... B = basis_sample(nb, basis_hartley, s); return B # ----------------------------------------------------------------------