sigma-py / orthopy

:triangular_ruler: Orthogonal polynomials in all shapes and sizes.
182 stars 18 forks source link

Zernike cosine polynomials should have switched sign #117

Closed Wellidontcare closed 2 years ago

Wellidontcare commented 2 years ago

The polynomials generated by orthopy are not in accordance to the formal definition of the zernikes.

For example, $Z_{1}^{1} $ should be $2 \rho \cos \phi $ but the orthopy generated polynomial looks like $-2\rho \cos \phi $.

This is an issue with all polynomials with azimuthal degree $m > 0$. Sadly, I do not fully understand the source code, so I can not easily spot the mistake.

An easy fix could be multiplying every output polynomial where $m > 0 $ by $-1 $ where $m $ can be calculated from the OSA/ANSI index $j $ (which I believe to be self.L in the zernike.py) by

n = int(sqrt(2*j+1) - 0.5)
m = int(2*j - n*(n+2))
Wellidontcare commented 2 years ago

Never mind the polynomials are generated correctly, matplotlib imshow seems to flip the y-axis.