forked from ngageoint/csm
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathPointCloudGM.h
378 lines (353 loc) · 16.7 KB
/
PointCloudGM.h
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
//#############################################################################
//
// FILENAME: PointCloudGM.h
//
// CLASSIFICATION: Unclassified
//
// DESCRIPTION:
//
// Header for abstract class that is to provide a common interface from
// which CSM point cloud geometric models will inherit. It is derived from
// the GeometricModel class.
//
// This sensor model represents a transformation between ECEF space and a
// three-dimensional "model" space that is defined by the model. Even
// though model coordinates are defined by the model
//
// LIMITATIONS: None
//
//
// SOFTWARE HISTORY:
// Date Author Comment
// ----------- ------ -------
// 18-Feb-2013 DME Initial version.
// 27-May-2015 DME Replaced getValidModelRange function with
// getValidModelBounds function.
// 22-Feb-2018 JPK Replaced macros for inclusion in a single
// library. Reformatted for readability
//
// NOTES:
//
//#############################################################################
#ifndef __CSM_POINTCLOUDGM_H
#define __CSM_POINTCLOUDGM_H
#include "GeometricModel.h"
#include "csmPointCloud.h"
#define CSM_POINTCLOUD_FAMILY "PointCloud"
namespace csm
{
class CorrelationModel;
class CSM_EXPORT_API PointCloudGM : public GeometricModel
{
public:
virtual ~PointCloudGM() { }
virtual std::string getFamily() const;
//> This method returns the Family ID for the current model.
//<
//---
// Model-space description
//---
virtual ModelCoordProperties getModelCoordinateProperties() const = 0;
//> This method returns a structure containing human-readable
// descriptions of the model-space coordinate system used by this
// sensor model. See the definition of ModelCoordProperties for an
// example of how it might be initialized.
//<
//---
// Core Transformations
//---
virtual ModelCoord groundToModel(const EcefCoord& groundPt,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const = 0;
//> This method converts the given groundPt (x,y,z in ECEF meters) to a
// returned model coordinate (m0,m1,m2 in the model's coordinate
// space).
//
// Iterative algorithms will use desiredPrecision, in meters, as the
// convergence criterion, otherwise it will be ignored.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the actual precision, in meters, achieved by iterative
// algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
virtual ModelCoordCovar groundToModel(const EcefCoordCovar& groundPt,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const = 0;
//> This method converts the given groundPt (x,y,z in ECEF meters and
// corresponding 3x3 covariance in ECEF meters squared) to a returned
// model coordinate with covariance (m0,m1,m2 in the model's
// coordinate space and corresponding 3x3 covariance).
//
// Iterative algorithms will use desiredPrecision, in meters, as the
// convergence criterion, otherwise it will be ignored.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the actual precision, in meters, achieved by iterative
// algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
virtual EcefCoord modelToGround(const ModelCoord& modelPt,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const = 0;
//> This method converts the given modelPt (m0,m1,m2 in model
// coordinates) to a returned ground coordinate (x,y,z in ECEF meters).
//
// Iterative algorithms will use desiredPrecision, in meters, as the
// convergence criterion, otherwise it will be ignored.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the actual precision, in meters, achieved by iterative
// algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
virtual EcefCoordCovar modelToGround(const ModelCoordCovar& modelPt,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const = 0;
//> This method converts the given modelPt (m0,m1,m2 in model
// coordinates) and corresponding 3x3 covariance to a returned ground
// coordinate with covariance (x,y,z in ECEF meters and corresponding
// 3x3 covariance in ECEF meters squared).
//
// Iterative algorithms will use desiredPrecision, in meters, as the
// convergence criterion, otherwise it will be ignored.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the actual precision, in meters, achieved by iterative
// algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
//---
// Model bounds
//---
virtual ModelBounds getValidModelBounds() const = 0;
//> This method returns an object representing the model-space region
// over which the current model is valid. The ModelBounds object has a
// contains() function that may be used to check whether a given model
// coordinate lies within this region.
//
// NOTE: Attempting to use the model for transformations involving model
// coordinates outside the returned bounds may result in incorrect or
// misleading error estimates!
//<
//---
// Uncertainty Propagation
//---
struct SensorPartials
{
double dM0;
double dM1;
double dM2;
};
//> This type is used to hold the partial derivatives of model
// coordinates m0, m1, and m2, respectively, with respect to a model
// parameter.
//<
virtual SensorPartials computeSensorPartials(int index,
const EcefCoord& groundPt,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const = 0;
//> This is one of two overloaded methods. This method takes only
// the necessary inputs. Some efficiency may be obtained by using the
// other method. Even more efficiency may be obtained by using the
// computeAllSensorPartials method.
//
// This method returns the partial derivatives of m0, m1, and m2 (in
// model coordinates) with respect to the model parameter given by
// index, at the given groundPt (x,y,z in ECEF meters).
//
// Derived model implementations may wish to implement this method by
// calling the groundToImage method and passing the resulting image
// coordinate to the other computeSensorPartials method.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the highest actual precision, in meters, achieved by
// iterative algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
virtual SensorPartials computeSensorPartials(int index,
const ModelCoord& modelPt,
const EcefCoord& groundPt,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const = 0;
//> This is one of two overloaded methods. This method takes
// an input model coordinate for efficiency. Even more efficiency may
// be obtained by using the computeAllSensorPartials method.
//
// This method returns the partial derivatives of m0, m1, and m2 (in
// model coordinates) with respect to the model parameter given by
// index, at the given groundPt (x,y,z in ECEF meters).
//
// The modelPt, corresponding to the groundPt, is given so that it does
// not need to be computed by the method. Results are undefined if
// the modelPt provided does not correspond to the result of calling the
// groundToModel method with the given groundPt.
//
// Implementations with iterative algorithms (typically ground-to-image
// calls) will use desiredPrecision, in meters, as the convergence
// criterion, otherwise it will be ignored.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the highest actual precision, in meters, achieved by
// iterative algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//<
virtual std::vector<SensorPartials> computeAllSensorPartials(const EcefCoord& groundPt,
param::Set pSet = param::VALID,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const;
//> This is one of two overloaded methods. This method takes only
// the necessary inputs. Some efficiency may be obtained by using the
// other method.
//
// This method returns the partial derivatives of m0, m1, and m2 (in
// model coordinates) with respect to each of the model parameters at
// the given groundPt (x,y,z in ECEF meters). Desired model parameters
// are indicated by the given pSet.
//
// Implementations with iterative algorithms (typically ground-to-image
// calls) will use desiredPrecision, in meters, as the convergence
// criterion, otherwise it will be ignored.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the highest actual precision, in meters, achieved by
// iterative algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//
// The value returned is a vector of structures with m0, m1, and m2
// partials for one model parameter in each structure. The indices of
// the corresponding model parameters can be found by calling the
// getParameterSetIndices method for the given pSet.
//
// Derived models may wish to implement this directly for efficiency,
// but an implementation is provided here that calls the
// computeSensorPartials method for each desired parameter index.
//<
virtual std::vector<SensorPartials> computeAllSensorPartials(const ModelCoord& modelPt,
const EcefCoord& groundPt,
param::Set pSet = param::VALID,
double desiredPrecision = 0.001,
double* achievedPrecision = NULL,
WarningList* warnings = NULL) const;
//> This is one of two overloaded methods. This method takes
// an input image coordinate for efficiency.
//
// This method returns the partial derivatives of m0, m1, and m2 (in
// model coordinates) with respect to each of the model parameters at
// the given groundPt (x,y,z in ECEF meters). Desired model parameters
// are indicated by the given pSet.
//
// The modelPt, corresponding to the groundPt, is given so that it does
// not need to be computed by the method. Results are undefined if
// the modelPt provided does not correspond to the result of calling the
// groundToModel method with the given groundPt.
//
// Implementations with iterative algorithms (typically ground-to-image
// calls) will use desiredPrecision, in meters, as the convergence
// criterion, otherwise it will be ignored.
//
// If a non-NULL achievedPrecision argument is received, it will be
// populated with the highest actual precision, in meters, achieved by
// iterative algorithms and 0.0 for deterministic algorithms.
//
// If a non-NULL warnings argument is received, it will be populated
// as applicable.
//
// The value returned is a vector of structures with m0, m1, and m2
// partials for one model parameter in each structure. The indices of
// the corresponding model parameters can be found by calling the
// getParameterSetIndices method for the given pSet.
//
// Derived models may wish to implement this directly for efficiency,
// but an implementation is provided here that calls the
// computeSensorPartials method for each desired parameter index.
//<
virtual std::vector<double> computeGroundPartials(const EcefCoord& groundPt) const = 0;
//> This method returns the partial derivatives of model coordinates m0,
// m1, m2 with respect to the given groundPt (x,y,z in ECEF meters).
//
// The value returned is a vector with nine elements as follows:
//
//- [0] = partial derivative of m0 with respect to x
//- [1] = partial derivative of m0 with respect to y
//- [2] = partial derivative of m0 with respect to z
//- [3] = partial derivative of m1 with respect to x
//- [4] = partial derivative of m1 with respect to y
//- [5] = partial derivative of m1 with respect to z
//- [6] = partial derivative of m2 with respect to x
//- [7] = partial derivative of m2 with respect to y
//- [8] = partial derivative of m2 with respect to z
//<
virtual const CorrelationModel& getCorrelationModel() const = 0;
//> This method returns a reference to a correlation model.
// The correlation model is used to determine the correlation between
// the model parameters of different models of the same type.
// It is primarily used for replacement sensor model generation;
// most applications will use the getCrossCovarianceMatrix function.
//<
inline std::vector<double> getUnmodeledError(const ModelCoord& modelPt) const;
//> This method returns the 3x3 covariance matrix (in model coordinates)
// at the given modelPt for any model error not accounted for by the
// model parameters.
//
// The value returned is a vector of nine elements as follows:
//
//- [0] = m0 variance
//- [1] = m0/m1 covariance
//- [2] = m0/m2 covariance
//- [3] = m1/m0 covariance
//- [4] = m1 variance
//- [5] = m1/m2 covariance
//- [6] = m2/m0 covariance
//- [7] = m2/m1 covariance
//- [8] = m2 variance
//<
virtual std::vector<double> getUnmodeledCrossCovariance(const ModelCoord& pt1,
const ModelCoord& pt2) const = 0;
//> This method returns the 3x3 cross-covariance matrix (in model
// coordinates) between model points pt1 and pt2 for any model error not
// accounted for by the model parameters.
//
// The value returned is a vector of nine elements as follows:
//
//- [0] = pt1.m0/pt2.m0 covariance
//- [1] = pt1.m0/pt2.m1 covariance
//- [2] = pt1.m0/pt2.m2 covariance
//- [3] = pt1.m1/pt2.m0 covariance
//- [4] = pt1.m1/pt2.m1 covariance
//- [5] = pt1.m1/pt2.m2 covariance
//- [6] = pt1.m2/pt2.m0 covariance
//- [7] = pt1.m2/pt2.m1 covariance
//- [8] = pt1.m2/pt2.m2 covariance
//<
};
//*****************************************************************************
// PointCloudGM::getUnmodeledError
//*****************************************************************************
inline std::vector<double> PointCloudGM::getUnmodeledError(const ModelCoord& modelPt) const
{
return getUnmodeledCrossCovariance(modelPt, modelPt);
}
} // namespace csm
#endif