From 243b48abf7922957fc3e0876bf9f12f893a8327f Mon Sep 17 00:00:00 2001 From: Franz Zotter Date: Wed, 17 Jun 2009 08:39:06 +0000 Subject: modified the chebyshev12 routine to put out readily normalized circular harmonics and added [mtx_circular_harmonics] to the file mtx_spherical_harmonics, as well as a corresponding helpfile. why: useful for circular (1D) ambisonics, e.g. ... svn path=/trunk/externals/iem/iemmatrix/; revision=11792 --- src/mtx_spherical_harmonics/chebyshev12.c | 10 ++++++---- src/mtx_spherical_harmonics/sharmonics.c | 2 +- src/mtx_spherical_harmonics/sharmonics_normalization.c | 9 +++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src/mtx_spherical_harmonics') diff --git a/src/mtx_spherical_harmonics/chebyshev12.c b/src/mtx_spherical_harmonics/chebyshev12.c index 462341b..64af232 100644 --- a/src/mtx_spherical_harmonics/chebyshev12.c +++ b/src/mtx_spherical_harmonics/chebyshev12.c @@ -1,5 +1,5 @@ /* - Evaluates all circular harmonics + Evaluates all fully normalized circular harmonics at the angles phi up to the order nmax. using the recurrence for the Chebyshev polynomials of the first and second kind @@ -42,6 +42,8 @@ void chebyshev12(double *phi, Cheby12WorkSpace *wc) { const int incr=2*wc->nmax+1; double *cosphi; double *sinphi; + const double oneoversqrt2pi=1.0/sqrt(2.0*M_PI); + const double oneoversqrtpi=1.0/sqrt(M_PI); // memory allocation if ((wc!=0)&&(phi!=0)) { if ((cosphi=(double*)calloc(wc->l,sizeof(double)))==0) { @@ -56,9 +58,9 @@ void chebyshev12(double *phi, Cheby12WorkSpace *wc) { cosphi[l]=cos(phi[l]); sinphi[l]=sin(phi[l]); // initial value T_0=1 - wc->t[l0]=1; - wc->t[l0+1]=cosphi[l]; - wc->t[l0-1]=sinphi[l]; + wc->t[l0]=oneoversqrt2pi; + wc->t[l0+1]=cosphi[l]*oneoversqrtpi; + wc->t[l0-1]=sinphi[l]*oneoversqrtpi; } // recurrence for n>1 for (n=2; n<=wc->nmax; n++) { diff --git a/src/mtx_spherical_harmonics/sharmonics.c b/src/mtx_spherical_harmonics/sharmonics.c index 5d6f853..dbfcb18 100644 --- a/src/mtx_spherical_harmonics/sharmonics.c +++ b/src/mtx_spherical_harmonics/sharmonics.c @@ -43,7 +43,7 @@ static void sharmonics_initlegendrenormlzd(SHWorkSpace *ws) { } } -// multiplying Chebyshev sin/cos to the preliminary result +// multiplying normalized Chebyshev sin/cos to the preliminary result // Y_n^m(phi,theta) = Y_n^m(theta) * T_m(phi) // ny0 and nt0 denote where the position (n,m)=(n,0) or m=0 is in the arrays // ly0 and lt0 denote the starting position for one vertex in the arrays diff --git a/src/mtx_spherical_harmonics/sharmonics_normalization.c b/src/mtx_spherical_harmonics/sharmonics_normalization.c index ca97292..d7fe00a 100644 --- a/src/mtx_spherical_harmonics/sharmonics_normalization.c +++ b/src/mtx_spherical_harmonics/sharmonics_normalization.c @@ -27,8 +27,14 @@ SHNorml *sharmonics_normalization_new (const size_t nmax) { wn=0; } else { + /* + deprecated: // computing N_n^m for m=0, wrongly normalized wn->n[0]=sqrt(1/(2*M_PI)); + */ + + // computing N_n^m for m=0, + wn->n[0]=oneoversqrt2; for (n=1,n0=1; n<=nmax; n++) { wn->n[n0]=wn->n[0] * sqrt(2*n+1); n0+=n+1; @@ -40,11 +46,14 @@ SHNorml *sharmonics_normalization_new (const size_t nmax) { } n0+=n+1; } + /* + deprecated: // correcting normalization of N_n^0 for (n=0,n0=0; n<=nmax; n++) { wn->n[n0]*=oneoversqrt2; n0+=n+1; } + */ } } return wn; -- cgit v1.2.1