1 /* Copyright 2022-2025 Luc Maisonobe
2 * Licensed to CS GROUP (CS) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * CS licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.orekit.files.ccsds.ndm.adm.acm;
19
20 import java.util.List;
21
22 import org.hipparchus.linear.DiagonalMatrix;
23 import org.orekit.time.AbsoluteDate;
24 import org.orekit.time.TimeStamped;
25 import org.orekit.utils.units.Unit;
26
27 /** Covariance entry.
28 * @author Luc Maisonobe
29 * @since 12.0
30 */
31 public class AttitudeCovariance implements TimeStamped {
32
33 /** Type of the elements. */
34 private final AttitudeCovarianceType type;
35
36 /** Entry date. */
37 private final AbsoluteDate date;
38
39 /** Covariance matrix. */
40 private final DiagonalMatrix matrix;
41
42 /** Simple constructor.
43 * @param type type of the elements
44 * @param date entry date
45 * @param fields matrix diagonal elements
46 * @param first index of first field to consider
47 */
48 public AttitudeCovariance(final AttitudeCovarianceType type, final AbsoluteDate date,
49 final String[] fields, final int first) {
50 final List<Unit> units = type.getUnits();
51 this.type = type;
52 this.date = date;
53 this.matrix = new DiagonalMatrix(units.size());
54 for (int k = 0; k < matrix.getRowDimension(); ++k) {
55 matrix.setEntry(k, k, units.get(k).toSI(Double.parseDouble(fields[first + k])));
56 }
57 }
58
59 /** {@inheritDoc} */
60 @Override
61 public AbsoluteDate getDate() {
62 return date;
63 }
64
65 /** Get the covariance matrix.
66 * @return covariance matrix
67 */
68 public DiagonalMatrix getMatrix() {
69 return matrix;
70 }
71
72 /** Get the type of the elements.
73 * @return type of the elements
74 */
75 public AttitudeCovarianceType getType() {
76 return type;
77 }
78
79 }