1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.gnss.antenna;
18
19 import org.hipparchus.util.FastMath;
20 import org.hipparchus.util.MathUtils;
21
22
23
24
25
26
27
28 public class TwoDVariation implements PhaseCenterVariationFunction {
29
30
31 private final double polarStart;
32
33
34 private final double polarStep;
35
36
37 private final double azimuthStep;
38
39
40 private final double[][] variations;
41
42
43
44
45
46
47
48 public TwoDVariation(final double polarStart, final double polarStep,
49 final double azimuthStep, final double[][] variations) {
50 this.polarStart = polarStart;
51 this.polarStep = polarStep;
52 this.azimuthStep = azimuthStep;
53 this.variations = new double[variations.length][];
54 for (int i = 0; i < variations.length; ++i) {
55 this.variations[i] = variations[i].clone();
56 }
57 }
58
59
60 @Override
61 public double value(final double polarAngle, final double azimuthAngle) {
62
63
64 final double az = MathUtils.normalizeAngle(azimuthAngle, FastMath.PI);
65 final int iBase = (int) FastMath.floor(az / azimuthStep);
66 final int i = FastMath.max(0, FastMath.min(variations.length - 2, iBase));
67 final int jBase = (int) FastMath.floor((polarAngle - polarStart) / polarStep);
68 final int j = FastMath.max(0, FastMath.min(variations[i].length - 2, jBase));
69
70 final double aInf = i * azimuthStep;
71 final double aSup = aInf + azimuthStep;
72 final double pInf = polarStart + j * polarStep;
73 final double pSup = pInf + polarStep;
74
75 final double vInfInf = variations[i][j];
76 final double vInfSup = variations[i][j + 1];
77 final double vSupInf = variations[i + 1][j];
78 final double vSupSup = variations[i + 1][j + 1];
79
80
81 final double vInf = ((polarAngle - pInf) * vInfSup + (pSup - polarAngle) * vInfInf) / polarStep;
82 final double vSup = ((polarAngle - pInf) * vSupSup + (pSup - polarAngle) * vSupInf) / polarStep;
83 return ((az - aInf) * vSup + (aSup - az) * vInf) / azimuthStep;
84
85 }
86
87 }