Q2dChebyshevFit: Fit MSF surface to 2dQ polynomials
Version 1.0.0 (7.34 KB) by
Yiwen Fan
Rapid and accurate surface fitting that supporting thousands of Q terms
Function for fitting a surface to 2DQ polynomials
Usage:
- [amn, bmn, z_recon_map] = Q2dChebyshevFit(z_map, M, N, J, K)
Description:
- This function takes as input a freeform surface and fits it to 2D-Q polynomials, returning the coefficients of the fit as well as the reconstructed map.
Inputs:
- z_map - The sag table of the freeform surface.
- M - The highest azimutal fitting order.
- N - The highest radial fitting order.
- J - The sampling number on azimuthal direction, default: 2M+1
- K - The sampling number on radial direction, default: 2(N+1)
Outputs:
- amn, bmn - The fitted coefficients z_recon_map
- The surface calculated by amn, bmn coefficients
Date: 05/22/2025
Acknowledgments:
- This fitting algorithm was completely developed by Professor Greg Forbes. For detailed deduction please refer to (1) https://doi.org/10.1364/OE.18.013851 (2) https://doi.org/10.1364/OE.18.019700 (3) https://doi.org/10.1364/OE.20.002483 (4) https://doi.org/10.1364/OE.21.019061 (5) https://doi.org/10.1117/12.2191135
- This work was partially contributed by Ilhan Kaya and Nick Takaki, who wrote all the supporting functions attached below. I (Yiwen) have made some modifications to handle the numerical accuracy when comes to high order.
- I (Yiwen) use traditional least-square fitting for getting the rotationally-symmetric component (Qbfs) for a stabler performance. If you know how to properly handle the Qbfs fitting with decent numerical accuracy, please let me know ♥
- There is a Python package for 2d-Q fitting: https://github.com/npdata/Scikit-qfit/tree/master
---
There is another function I developed that fits MSF surfaces to Zernike polynomials https://www.mathworks.com/matlabcentral/fileexchange/132713-zernikelegendrefit-fast-precise-high-capacity-fitting
Cite As
Yiwen Fan (2025). Q2dChebyshevFit: Fit MSF surface to 2dQ polynomials (https://uk.mathworks.com/matlabcentral/fileexchange/181194-q2dchebyshevfit-fit-msf-surface-to-2dq-polynomials), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2025a
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0 |
