ModelSpace
All Classes Namespaces Functions Variables Enumerations Pages
CalcFocalPlaneAnglesMatrix.hpp
1/******************************************************************************
2* Copyright (c) ATTX LLC 2024. All Rights Reserved.
3*
4* This software and associated documentation (the "Software") are the
5* proprietary and confidential information of ATTX, LLC. The Software is
6* furnished under a license agreement between ATTX and the user organization
7* and may be used or copied only in accordance with the terms of the agreement.
8* Refer to 'license/attx_license.adoc' for standard license terms.
9*
10* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
11* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION
12* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or
13* transmitted in any form or by any means, for any purpose, without the express
14* written permission of ATTX, LLC.
15******************************************************************************/
16#ifndef GNC_NAVIGATION_MEASUREMENTS_CALC_FOCAL_PLANE_ANGLES_MATRIX_HPP
17#define GNC_NAVIGATION_MEASUREMENTS_CALC_FOCAL_PLANE_ANGLES_MATRIX_HPP
18
19#include <cmath>
20
21#include "gnc/navigation/measurements/CalcFocalPlaneAngles.hpp"
22
23namespace clockwerk {
24
25 /**
26 * @brief Measurement class to calculate focal plane angle sensitivity matrix from tgt and observer state
27 *
28 * This function calculates focal plane angle sensitivity matrix for a given target in
29 * an image frame using the known position of the imager and target. The focal plane
30 * angles are defined as follows:
31 * alpha = atan([xtgt - xobs]/[ztgt - zobs])
32 * beta = atan([ytgt - yobs]/[ztgt - zobs])
33 *
34 * Where target and observer states are differenced to generate the target state in the
35 * focal frame. The focal frame is defined as:
36 * Centered in the center of the reference image
37 * X is "up" in the image
38 * Y is "right" in the image
39 * Z is "into" the image completing the right hand frame
40 *
41 * |----------------------|
42 * | x^ |
43 * | |-->y |
44 * | |
45 * |----------------------|
46 *
47 * The return is a flattened "H" matrix with values:
48 * [dalpha/dx dalpha/dy dalpha/dz 0 0 0]
49 * [dbeta/dx dbeta/dy dbeta/dz 0 0 0]
50 */
51 template <typename T>
53 public:
54 /// @brief Function to focal plane angles
55 /// @param time The reference time (unused)
56 /// @param tar_state The target reference state [x, y, z, vx, vy, vz]
57 /// @param obs_state The observer reference state [x, y, z] representing camera position
58 /// @param out_measurements Implicit return of [dalpha/dx dalpha/dy dalpha/dz 0 0 0, dbeta/dx dbeta/dy, dbeta/dz 0 0 0]
59 int calculateMeasurements(T time, const std::array<T, FOCAL_PLANE_MEAS_TARGET_STATES> &tar_state, const std::array<T, FOCAL_PLANE_MEAS_OBSERVER_STATES> &obs_state,
60 std::array<T, FOCAL_PLANE_MEASUREMENTS*FOCAL_PLANE_MEAS_TARGET_STATES> &out_measurements);
61 private:
62
63 };
64
65 template <typename T>
66 int CalcFocalPlaneAnglesMatrix<T>::calculateMeasurements(T time, const std::array<T, FOCAL_PLANE_MEAS_TARGET_STATES> &tar_state, const std::array<T, FOCAL_PLANE_MEAS_OBSERVER_STATES> &obs_state,
67 std::array<T, FOCAL_PLANE_MEASUREMENTS*FOCAL_PLANE_MEAS_TARGET_STATES> &out_measurements) {
68 // Pre-calculate parameters
69 T focal_x = tar_state[0] - obs_state[0];
70 T focal_y = tar_state[1] - obs_state[1];
71 T focal_z = tar_state[2] - obs_state[2];
72 T one_over_xsquared_zsquared, one_over_ysquared_zsquared;
73 int err = safeDivide(1.0, focal_x*focal_x + focal_z*focal_z, one_over_xsquared_zsquared);
74 if(err) {return err;}
75 err = safeDivide(1.0, focal_y*focal_y + focal_z*focal_z, one_over_ysquared_zsquared);
76 if(err) {return err;}
77
78 out_measurements[0] = focal_z*one_over_xsquared_zsquared;
79 out_measurements[1] = 0.0;
80 out_measurements[2] = -focal_x*one_over_xsquared_zsquared;
81 out_measurements[3] = 0.0;
82 out_measurements[4] = 0.0;
83 out_measurements[5] = 0.0;
84 out_measurements[6] = 0.0;
85 out_measurements[7] = focal_z*one_over_ysquared_zsquared;
86 out_measurements[8] = -focal_y*one_over_ysquared_zsquared;
87 out_measurements[9] = 0.0;
88 out_measurements[10] = 0.0;
89 out_measurements[11] = 0.0;
90
91 return NO_ERROR;
92 };
93
94}
95
96#endif
#define FOCAL_PLANE_MEASUREMENTS
Definition CalcFocalPlaneAngles.hpp:26
#define FOCAL_PLANE_MEAS_TARGET_STATES
Definition CalcFocalPlaneAngles.hpp:24
#define FOCAL_PLANE_MEAS_OBSERVER_STATES
Definition CalcFocalPlaneAngles.hpp:25
Measurement class to calculate focal plane angle sensitivity matrix from tgt and observer state.
Definition CalcFocalPlaneAnglesMatrix.hpp:52
int calculateMeasurements(T time, const std::array< T, 6 > &tar_state, const std::array< T, 3 > &obs_state, std::array< T, 2 *6 > &out_measurements)
Function to focal plane angles.
Definition CalcFocalPlaneAnglesMatrix.hpp:66
Definition Measurements.hpp:39
#define NO_ERROR
Definition clockwerkerrors.h:31