-
Notifications
You must be signed in to change notification settings - Fork 2
/
ZernikePartial.m
92 lines (92 loc) · 3.8 KB
/
ZernikePartial.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
function Z = ZernikePartial( c, x, y )
switch c
case 1 % 0 0
X = zeros( length( x ), 1 );
Y = zeros( length( x ), 1 );
case 2 % 1 -1
X = zeros( length( x ), 1 );
Y = ones( length( x ), 1 );
case 3 % 1 1
X = ones( length( x ), 1 );
Y = zeros( length( x ), 1 );
case 4 % 2 -2
X = 2 .* y;
Y = 2 .* x;
case 5 % 2 0
X = 4 .* x;
Y = 4 .* y;
case 6 % 2 2
X = 2 .* x;
Y = -2 .* y;
case 7 % 3 -3
X = 6 .* x .* y;
Y = 3 .* (x.^2 - y.^2);
case 8 % 3 -1
X = 6 .* x .* y;
Y = 3 .* x.^2 + 9 .* y.^2 - 2;
case 9 % 3 1
X = 9 .* x.^2 + 3 .* y.^2 - 2;
Y = 6 .* x .* y;
case 10 % 3 3
X = 3 .* x.^2 - 3 .* y.^2;
Y = -6 .* x .* y;
case 11 % 4 -4
X = 12 .* x.^2 .* y - 4 .* y.^3;
Y = 4 .* x .* (x.^2 - 3 .* y.^2);
case 12 % 4 -2
X = -6 .* y + 24 .* x.^2 .* y + 8 .* y.^3;
Y = 2 .* x .* (4 .* x.^2 + 12 .* y.^2 - 3);
case 13 % 4 0
X = 12 .* x .* (2 .* (x.^2 + y.^2) -1);
Y = 12 .* y .* (2 .* (x.^2 + y.^2) - 1);
case 14 % 4 2
X = 2 .* x .* (8 .* x.^2 - 3);
Y = 2 .* y .* (3 - 8 .* y.^2);
case 15 % 4 4
X = 4 .* x .* (x.^2 - 3 .* y.^2);
Y = -4 .* y .* (y.^2 - 3 .* x.^2);
case 16 % 5 -5
X = 20 .* x .* y .* (x.^2 - y.^2);
Y = 5 .* (x.^4 - 6 .* x.^2 .* y.^2 + y.^4);
case 17 % 5 -3
X = 4 .* x .* y .* (15 .* x.^2 + 5 .* y.^2 - 6);
Y = 15 .* x.^4 - 6 .* x.^2 .* (5 .* y.^2 - 2) - y.^2 .* (25 .* y.^2 - 12);
case 18 % 5 -1
X = 8 .* x .* y .* (5 .* x.^2 + 5 .* y.^2 - 3);
Y = 50 .* x.^4 + 12 .* x.^2 .* (5 .* y.^2 - 3) + 2 .* y.^2 .* (5 .* y.^2 -6) + 3;
case 19 % 5 1
X = 50 .* x.^4 + 12 .* (5 .* y.^2 - 3) .* x.^2 + 10 .* y.^4 - 12 .* y.^2 + 3;
Y = 8 .* x .* y .* (5 .* (x.^2 + y.^2) - 3);
case 20 % 5 3
X = 25 .* x.^4 - 6 .* x.^2 .* (y.^2 + 2) - 3 .* y.^2 .* (5 .* y.^2 - 4);
Y = -4 .* x .* y .* (5 .* x.^2 + 15 .* y.^2 - 6);
case 21 % 5 5
X = -5 .* (x.^4 - 6 .* y.^2 .* x.^2 + y.^4);
Y = -20 .* x .* y .* (x.^2 - y.^2);
case 22 % 6 -6
X = 6 .* y .* (5 .* x.^4 - 10 .* y.^2 .* x.^2 + y.^4);
Y = 6 .* x .* (x.^4 - 10 .* x.^2 .* y.^3 + 5 .* y.^5);
case 23 % 6 -4
X = 4 .* y .* (30 .* x.^4 - 15 .* x.^2 - 6 .* y.^4 + 5 .* y.^2);
Y = 4 .* x .* (30 .* y.^4 - 15 .* y.^2 - 6 .* x.^4 + 5 .* x.^2);
case 24 % 6 -2
X = 2 .* y .* (5 .* (5 .* x.^2 + y.^2) .* (3 .* (x.^2 + y.^2) - 4) + 40 .* x.^2 + 6);
Y = 2 .* x .* (5 .* (x.^2 + 5 .* y.^2) .* (3 .* (x.^2 + y.^2) - 4) + 40 .* y.^2 + 6);
case 25 % 6 0
X = 24 .* x .* (1 + 5 .* (x.^2 + y.^2) .* (x.^2 + y.^2 - 1));
Y = 24 .* y .* (1 + 5 .* (x.^2 + y.^2) .* (x.^2 + y.^2 -1));
case 26 % 6 2
X = 2 .* x .* (15 .* (x.^2 + y.^2) .* (3 .* x.^2 - y.^2) - 40 .* x.^2 + 6);
Y = 2 .* y .* (15 .* (x.^2 + y.^2) .* (x.^2 - 3 .* y.^2) + 40 .* y.^2 - 6);
case 27 % 6 4
X = 4 .* x .* (9 .* x.^4 - 5 .* (6 .* y.^2 + 1) .* x.^2 - 15 .* y.^2 .* (y.^2 - 1));
Y = 4 .* y .* (9 .* x.^4 - 5 .* y.^2 .* (6 .* x.^2 + 1) - 15 .* x.^2 .* (x.^2 - 1));
case 28 % 6 6
X = 6 .* x .* (x.^4 - 10 .* y.^2 .* x.^2 + 5 .* y.^4);
Y = -6 .* y .* (5 .* x.^4 - 10 .* x.^2 .* y.^2 + y.^4);
otherwise
X = zeros( size( x, 1 ) );
Y = zeros( size( x, 1 ) );
end
Z = [X, Y];
end