gradzpm_cart: Zernike polynomials and cartesian gradients

View source: R/RcppExports.R

gradzpm_cartR Documentation

Zernike polynomials and cartesian gradients

Description

Calculate Zernike polynomial values and Cartesian gradients in ISO/ANSI sequence for a set of Cartesian coordinates.

Usage

gradzpm_cart(x, y, maxorder = 12L, unit_variance = FALSE, return_zpm = TRUE)

Arguments

x

a vector of x coordinates for points on a unit disk.

y

a vector of y coordinates.

maxorder

the maximum radial polynomial order (defaults to 12).

unit_variance

logical: return with orthonormal scaling? (default false)

return_zpm

logical: return Zernike polynomial matrix? (default true)

Details

Uses the recurrence relations in the above publication to calculate Zernike polynomial values and their directional derivatives in Cartesian coordinates. These are known to be both efficient and numerically stable.

Columns are in ISO/ANSI sequence: for each radial order n >= 0 the azimuthal orders m are sequenced m = -n, -(n-2), ..., (n-2), n, with sine components for negative m and cosine for positive m. Note this is the opposite ordering from the extended Fringe set and the ordering of aberrations is quite different. For example the two components of trefoil are in the 7th and 10th column while coma is in columns 8 and 9 (or 7 and 8 with 0-indexing). Note also that except for tilt and coma-like aberrations (m=1) non-axisymmetric aberrations will be separated.

All three matrices will have the same dimensions on return. Columns 0 and 1 of dzdx will be all 0, while columns 0 and 2 of dzdy are 0.

Value

a named list with the matrices zm (optional but returned by default), dzdx, dzdy.

References

Anderson, T.B. (2018) Optics Express 26, #5, 18878 https://doi.org/10.1364/OE.26.018878 (open access)

See Also

zpm() uses the same recurrence relations for polar coordinates and extended Fringe set ordering, which is the more common indexing scheme for optical design/testing software.

zpm_cart() calculates and returns the Zernike polynomial values only.

Examples

 rho <- seq(0.2, 1., length=5)
 theta <- seq(0, 1.6*pi, length=5)
 rt <- expand.grid(theta, rho)
 x <- c(0, rt[,2]*cos(rt[,1]))
 y <- c(0, rt[,2]*sin(rt[,1]))
 gzpm <- gradzpm_cart(x, y)


mlpeck/zernike documentation built on April 19, 2024, 3:16 p.m.