RayZaler 0.1
The free opto-mechanical simulation framework
Zernike.h
1//
2// Copyright (c) 2024 Gonzalo José Carracedo Carballal
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU Lesser General Public License as
6// published by the Free Software Foundation, either version 3 of the
7// License, or (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU Lesser General Public License for more details.
13//
14// You should have received a copy of the GNU Lesser General Public
15// License along with this program. If not, see
16// <http://www.gnu.org/licenses/>
17//
18
19#ifndef _ZERNIKE_H
20#define _ZERNIKE_H
21
22#include <Vector.h>
23#include <vector>
24
25//
26// Implementation inspired from https://www.mrao.cam.ac.uk/~bn204/oof/zernikes.html
27//
28namespace RZ {
29 class Zernike {
30 unsigned int m_n = 0; // Radial order
31 int m_l = 0; // Angular order
32
33 int m_m;
34 int m_nRadTerm;
35
36 std::vector<Real> m_coefs;
37 std::vector<int> m_powers;
38
39 void initFromNL(unsigned, int);
40
41 public:
42 inline unsigned
43 n() const
44 {
45 return m_n;
46 }
47
48 inline int
49 m() const
50 {
51 return m_m;
52 }
53
54 inline int
55 l() const
56 {
57 return m_l;
58 }
59
60 Zernike(unsigned int n, int l);
61 Zernike(unsigned int j = 0);
62 Real operator()(double x, double y) const;
63
64 Real gradX(double x, double y) const;
65 Real gradY(double x, double y) const;
66 };
67}
68
69#endif // _ZERNIKE_H
Definition: Zernike.h:29