1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.attitudes;
18
19 import java.io.NotSerializableException;
20 import java.io.Serializable;
21 import java.util.ArrayList;
22 import java.util.List;
23
24 import org.orekit.errors.OrekitException;
25 import org.orekit.frames.Frame;
26 import org.orekit.time.AbsoluteDate;
27 import org.orekit.utils.AngularDerivativesFilter;
28 import org.orekit.utils.ImmutableTimeStampedCache;
29 import org.orekit.utils.PVCoordinatesProvider;
30 import org.orekit.utils.TimeStampedAngularCoordinates;
31
32
33
34
35
36
37
38
39 public class TabulatedProvider implements AttitudeProvider {
40
41
42
43 private static final long serialVersionUID = 20140723L;
44
45
46 private final Frame referenceFrame;
47
48
49 private final transient ImmutableTimeStampedCache<TimeStampedAngularCoordinates> table;
50
51
52 private final AngularDerivativesFilter filter;
53
54
55
56
57
58
59
60
61
62 @Deprecated
63 public TabulatedProvider(final List<Attitude> table, final int n, final boolean useRotationRate) {
64 this(table.get(0).getReferenceFrame(),
65 toTimeStampedAngularCoordinates(table),
66 n, useRotationRate ? AngularDerivativesFilter.USE_RR : AngularDerivativesFilter.USE_R);
67 }
68
69
70
71
72
73
74
75 public TabulatedProvider(final Frame referenceFrame, final List<TimeStampedAngularCoordinates> table,
76 final int n, final AngularDerivativesFilter filter) {
77 this.referenceFrame = referenceFrame;
78 this.table = new ImmutableTimeStampedCache<TimeStampedAngularCoordinates>(n, table);
79 this.filter = filter;
80 }
81
82
83 public Attitude getAttitude(final PVCoordinatesProvider pvProv,
84 final AbsoluteDate date, final Frame frame)
85 throws OrekitException {
86
87
88 final List<TimeStampedAngularCoordinates> sample = table.getNeighbors(date);
89
90
91 final TimeStampedAngularCoordinates interpolated =
92 TimeStampedAngularCoordinates.interpolate(date, filter, sample);
93
94
95 return new Attitude(referenceFrame, interpolated);
96
97 }
98
99
100
101
102
103 private static List<TimeStampedAngularCoordinates> toTimeStampedAngularCoordinates(final List<Attitude> attitudes) {
104 final List<TimeStampedAngularCoordinates> converted =
105 new ArrayList<TimeStampedAngularCoordinates>(attitudes.size());
106 for (final Attitude attitude : attitudes) {
107 converted.add(attitude.getOrientation());
108 }
109 return converted;
110 }
111
112
113
114
115
116 private Object writeReplace() throws NotSerializableException {
117 return new DataTransferObject(referenceFrame, table.getAll(), table.getNeighborsSize(), filter);
118 }
119
120
121 private static class DataTransferObject implements Serializable {
122
123
124 private static final long serialVersionUID = 20140723L;
125
126
127 private final Frame referenceFrame;
128
129
130 private final List<TimeStampedAngularCoordinates> list;
131
132
133 private final int n;
134
135
136 private final AngularDerivativesFilter filter;
137
138
139
140
141
142
143
144 public DataTransferObject(final Frame referenceFrame, final List<TimeStampedAngularCoordinates> list,
145 final int n, final AngularDerivativesFilter filter) {
146 this.referenceFrame = referenceFrame;
147 this.list = list;
148 this.n = n;
149 this.filter = filter;
150 }
151
152
153
154
155 private Object readResolve() {
156 return new TabulatedProvider(referenceFrame, list, n, filter);
157 }
158
159 }
160
161 }