#N canvas 409 263 921 503 10;
#X declare -lib iemmatrix;
#X obj 223 97 mtx_rand;
#X msg 226 75 2 10;
#X obj 28 218 mtx_print;
#X text 150 226 for -n<=m<=n:;
#X text 641 241 for m>=0;
#X text 640 257 for m< 0;
#X text 146 277 The order of the harmonics in the output columns is specified by the linear index k=n^2+n+m+1.;
#X text 305 160 for an L points 2xL input matrix \, [mtx_spherical_harmonics] evaluates the (nmax+2)^2 spherical harmonics at L points and delivers an Lx(nmax+2)^2 output matrix.;
#X text 309 118 [mtx_spherical_harmonics] requires a numerical creation argument <nmax> specifyiing the maximum order 0<=n<=nmax.;
#N canvas 429 253 494 171 META 0;
#X text 12 85 OUTLET_0 matrix;
#X text 12 125 HELP_PATCH_AUTHORS IOhannes m zmölnig;
#X text 12 25 LICENSE GPL-2+;
#X text 12 65 INLET_0 matrix;
#X text 12 105 AUTHOR Franz Zotter;
#X text 12 44 DESCRIPTION calculate spherical harmonics of a matrix;
#X text 12 6 KEYWORDS control matrix math;
#X obj 13 150 declare -lib iemmatrix;
#X restore 711 56 pd META;
#X text 536 410 Franz Zotter \, 2009 \, 2023;
#X obj 76 318 mtx_spherical_harmonics 1;
#X text 102 27 [mtx_spherical_harmonics] spherical harmonics evaluated at a set of points given in azimuth and zenith coordinates.;
#X text 188 258 Y_n^m(phi \, theta) = N_n^m * sin(|m|*azi) * P_n^m(cos(zen));
#X text 188 242 Y_n^m(phi \, theta) = N_n^m * cos(|m|*azi) * P_n^m(cos(zen));
#X text 231 332 N_n^m=;
#X text 278 332 (-1)^m sqrt((2n+1)(n-|m|)!(2-delta_m))/sqrt(4pi(n+|m|)!);
#X text 618 317 (because of sin(m*azi) instead of sin(|m|*azi));
#X text 235 306 Default/LEGACY \; N3D \, but with azi=-azi reversed \, before 2023;
#X obj 52 334 mtx_spherical_harmonics 1 N3D;
#X obj 34 350 mtx_spherical_harmonics 1 N3D4PI;
#X obj 46 366 mtx_spherical_harmonics 1 SN3D;
#X text 231 349 N_n^m=;
#X text 231 365 N_n^m=;
#X text 278 365 (-1)^m sqrt( (n-|m|)!(2-delta_m))/sqrt( (n+|m|)!);
#X text 278 349 (-1)^m sqrt((2n+1)(n-|m|)!(2-delta_m))/sqrt( (n+|m|)!);
#X text 74 388 Typical 3D Ambisonic encoding choice is SN3D as ambiX does;
#X text 75 400 Typical mathematical integral orthonormalization choice: N3D;
#X msg 29 9 1;
#X obj 29 30 atan;
#X msg 29 71 matrix 2 3 0 \$1 0 \$1 \$1 0;
#X obj 28 156 mtx_* 1e+06;
#X obj 28 177 mtx_int;
#X obj 28 198 mtx_./ 1e+06;
#X obj 29 51 * 2;
#X obj 28 135 mtx_spherical_harmonics 1 SN3D;
#X connect 0 0 35 0;
#X connect 1 0 0 0;
#X connect 28 0 29 0;
#X connect 29 0 34 0;
#X connect 30 0 35 0;
#X connect 31 0 32 0;
#X connect 32 0 33 0;
#X connect 33 0 2 0;
#X connect 34 0 30 0;
#X connect 35 0 31 0;
