PV.java

  1. /* Copyright 2002-2019 CS Systèmes d'Information
  2.  * Licensed to CS Systèmes d'Information (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. package org.orekit.estimation.measurements;

  18. import java.util.Arrays;

  19. import org.hipparchus.exception.LocalizedCoreFormats;
  20. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  21. import org.hipparchus.util.FastMath;
  22. import org.orekit.errors.OrekitException;
  23. import org.orekit.propagation.SpacecraftState;
  24. import org.orekit.time.AbsoluteDate;
  25. import org.orekit.utils.TimeStampedPVCoordinates;

  26. /** Class modeling a position-velocity measurement.
  27.  * <p>
  28.  * For position-only measurement see {@link Position}.
  29.  * </p>
  30.  * @see Position
  31.  * @author Luc Maisonobe
  32.  * @since 8.0
  33.  */
  34. public class PV extends AbstractMeasurement<PV> {

  35.     /** Identity matrix, for states derivatives. */
  36.     private static final double[][] IDENTITY = new double[][] {
  37.         {
  38.             1, 0, 0, 0, 0, 0
  39.         }, {
  40.             0, 1, 0, 0, 0, 0
  41.         }, {
  42.             0, 0, 1, 0, 0, 0
  43.         }, {
  44.             0, 0, 0, 1, 0, 0
  45.         }, {
  46.             0, 0, 0, 0, 1, 0
  47.         }, {
  48.             0, 0, 0, 0, 0, 1
  49.         }
  50.     };

  51.     /** Covariance matrix of the PV measurement (size 6x6). */
  52.     private final double[][] covarianceMatrix;

  53.     /** Constructor with two double for the standard deviations.
  54.      * <p>The first double is the position's standard deviation, common to the 3 position's components.
  55.      * The second double is the position's standard deviation, common to the 3 position's components.</p>
  56.      * <p>
  57.      * The measurement must be in the orbit propagation frame.
  58.      * </p>
  59.      * <p>This constructor uses 0 as the index of the propagator related
  60.      * to this measurement, thus being well suited for mono-satellite
  61.      * orbit determination.</p>
  62.      * @param date date of the measurement
  63.      * @param position position
  64.      * @param velocity velocity
  65.      * @param sigmaPosition theoretical standard deviation on position components
  66.      * @param sigmaVelocity theoretical standard deviation on velocity components
  67.      * @param baseWeight base weight
  68.      * @deprecated as of 9.3, replaced by {@link #PV(AbsoluteDate, Vector3D, Vector3D,
  69.      * double, double, double, ObservableSatellite)}
  70.      */
  71.     @Deprecated
  72.     public PV(final AbsoluteDate date, final Vector3D position, final Vector3D velocity,
  73.               final double sigmaPosition, final double sigmaVelocity, final double baseWeight) {
  74.         this(date, position, velocity, sigmaPosition, sigmaVelocity, baseWeight, new ObservableSatellite(0));
  75.     }

  76.     /** Constructor with two double for the standard deviations.
  77.      * <p>The first double is the position's standard deviation, common to the 3 position's components.
  78.      * The second double is the position's standard deviation, common to the 3 position's components.</p>
  79.      * <p>
  80.      * The measurement must be in the orbit propagation frame.
  81.      * </p>
  82.      * @param date date of the measurement
  83.      * @param position position
  84.      * @param velocity velocity
  85.      * @param sigmaPosition theoretical standard deviation on position components
  86.      * @param sigmaVelocity theoretical standard deviation on velocity components
  87.      * @param baseWeight base weight
  88.      * @param propagatorIndex index of the propagator related to this measurement
  89.      * @since 9.0
  90.      * @deprecated as of 9.3, replaced by {@link #PV(AbsoluteDate, Vector3D, Vector3D,
  91.      * double, double, double, ObservableSatellite)}
  92.      */
  93.     @Deprecated
  94.     public PV(final AbsoluteDate date, final Vector3D position, final Vector3D velocity,
  95.               final double sigmaPosition, final double sigmaVelocity, final double baseWeight,
  96.               final int propagatorIndex) {
  97.         this(date, position, velocity, sigmaPosition, sigmaVelocity, baseWeight, new ObservableSatellite(propagatorIndex));
  98.     }

  99.     /** Constructor with two double for the standard deviations.
  100.      * <p>The first double is the position's standard deviation, common to the 3 position's components.
  101.      * The second double is the position's standard deviation, common to the 3 position's components.</p>
  102.      * <p>
  103.      * The measurement must be in the orbit propagation frame.
  104.      * </p>
  105.      * @param date date of the measurement
  106.      * @param position position
  107.      * @param velocity velocity
  108.      * @param sigmaPosition theoretical standard deviation on position components
  109.      * @param sigmaVelocity theoretical standard deviation on velocity components
  110.      * @param baseWeight base weight
  111.      * @param satellite satellite related to this measurement
  112.      * @since 9.3
  113.      */
  114.     public PV(final AbsoluteDate date, final Vector3D position, final Vector3D velocity,
  115.               final double sigmaPosition, final double sigmaVelocity, final double baseWeight,
  116.               final ObservableSatellite satellite) {
  117.         this(date, position, velocity,
  118.              new double[] {
  119.                  sigmaPosition,
  120.                  sigmaPosition,
  121.                  sigmaPosition,
  122.                  sigmaVelocity,
  123.                  sigmaVelocity,
  124.                  sigmaVelocity
  125.              }, baseWeight, satellite);
  126.     }

  127.     /** Constructor with two vectors for the standard deviations and default value for propagator index.
  128.      * <p>One 3-sized vectors for position standard deviations.
  129.      * One 3-sized vectors for velocity standard deviations.
  130.      * The 3-sized vectors are the square root of the diagonal elements of the covariance matrix.</p>
  131.      * <p>The measurement must be in the orbit propagation frame.</p>
  132.      * <p>This constructor uses 0 as the index of the propagator related
  133.      * to this measurement, thus being well suited for mono-satellite
  134.      * orbit determination.</p>
  135.      * @param date date of the measurement
  136.      * @param position position
  137.      * @param velocity velocity
  138.      * @param sigmaPosition 3-sized vector of the standard deviations of the position
  139.      * @param sigmaVelocity 3-sized vector of the standard deviations of the velocity
  140.      * @param baseWeight base weight
  141.      * @since 9.2
  142.      * @deprecated as of 9.3, replaced by {@link #PV(AbsoluteDate, Vector3D, Vector3D,
  143.      * double[], double[], double, ObservableSatellite)}
  144.      */
  145.     @Deprecated
  146.     public PV(final AbsoluteDate date, final Vector3D position, final Vector3D velocity,
  147.               final double[] sigmaPosition, final double[] sigmaVelocity, final double baseWeight) {
  148.         this(date, position, velocity, sigmaPosition, sigmaVelocity, baseWeight, new ObservableSatellite(0));
  149.     }

  150.     /** Constructor with two vectors for the standard deviations.
  151.      * <p>One 3-sized vectors for position standard deviations.
  152.      * One 3-sized vectors for velocity standard deviations.
  153.      * The 3-sized vectors are the square root of the diagonal elements of the covariance matrix.</p>
  154.      * <p>The measurement must be in the orbit propagation frame.</p>
  155.      * @param date date of the measurement
  156.      * @param position position
  157.      * @param velocity velocity
  158.      * @param sigmaPosition 3-sized vector of the standard deviations of the position
  159.      * @param sigmaVelocity 3-sized vector of the standard deviations of the velocity
  160.      * @param baseWeight base weight
  161.      * @param propagatorIndex index of the propagator related to this measurement
  162.      * @since 9.2
  163.      * @deprecated as of 9.3, replaced by {@link #PV(AbsoluteDate, Vector3D, Vector3D,
  164.      * double[], double[], double, ObservableSatellite)}
  165.      */
  166.     @Deprecated
  167.     public PV(final AbsoluteDate date, final Vector3D position, final Vector3D velocity,
  168.               final double[] sigmaPosition, final double[] sigmaVelocity,
  169.               final double baseWeight, final int propagatorIndex) {
  170.         this(date, position, velocity, sigmaPosition, sigmaVelocity,
  171.              baseWeight, new ObservableSatellite(propagatorIndex));
  172.     }

  173.     /** Constructor with two vectors for the standard deviations.
  174.      * <p>One 3-sized vectors for position standard deviations.
  175.      * One 3-sized vectors for velocity standard deviations.
  176.      * The 3-sized vectors are the square root of the diagonal elements of the covariance matrix.</p>
  177.      * <p>The measurement must be in the orbit propagation frame.</p>
  178.      * @param date date of the measurement
  179.      * @param position position
  180.      * @param velocity velocity
  181.      * @param sigmaPosition 3-sized vector of the standard deviations of the position
  182.      * @param sigmaVelocity 3-sized vector of the standard deviations of the velocity
  183.      * @param baseWeight base weight
  184.      * @param satellite satellite related to this measurement
  185.      * @since 9.3
  186.      */
  187.     public PV(final AbsoluteDate date, final Vector3D position, final Vector3D velocity,
  188.               final double[] sigmaPosition, final double[] sigmaVelocity,
  189.               final double baseWeight, final ObservableSatellite satellite) {
  190.         this(date, position, velocity,
  191.              buildPvCovarianceMatrix(sigmaPosition, sigmaVelocity),
  192.              baseWeight, satellite);
  193.     }

  194.     /** Constructor with one vector for the standard deviations and default value for propagator index.
  195.      * <p>The 6-sized vector is the square root of the diagonal elements of the covariance matrix.</p>
  196.      * <p>The measurement must be in the orbit propagation frame.</p>
  197.      * <p>This constructor uses 0 as the index of the propagator related
  198.      * to this measurement, thus being well suited for mono-satellite
  199.      * orbit determination.</p>
  200.      * @param date date of the measurement
  201.      * @param position position
  202.      * @param velocity velocity
  203.      * @param sigmaPV 6-sized vector of the standard deviations
  204.      * @param baseWeight base weight
  205.      * @since 9.2
  206.      * @deprecated as of 9.3, replaced by {@link #PV(AbsoluteDate, Vector3D, Vector3D,
  207.      * double[], double, ObservableSatellite)}
  208.      */
  209.     @Deprecated
  210.     public PV(final AbsoluteDate date, final Vector3D position, final Vector3D velocity,
  211.               final double[] sigmaPV, final double baseWeight) {
  212.         this(date, position, velocity, sigmaPV, baseWeight, new ObservableSatellite(0));
  213.     }

  214.     /** Constructor with one vector for the standard deviations.
  215.      * <p>The 6-sized vector is the square root of the diagonal elements of the covariance matrix.</p>
  216.      * <p>The measurement must be in the orbit propagation frame.</p>
  217.      * @param date date of the measurement
  218.      * @param position position
  219.      * @param velocity velocity
  220.      * @param sigmaPV 6-sized vector of the standard deviations
  221.      * @param baseWeight base weight
  222.      * @param propagatorIndex index of the propagator related to this measurement
  223.      * @since 9.2
  224.      * @deprecated as of 9.3, replaced by {@link #PV(AbsoluteDate, Vector3D, Vector3D,
  225.      * double[], double, ObservableSatellite)}
  226.      */
  227.     @Deprecated
  228.     public PV(final AbsoluteDate date, final Vector3D position, final Vector3D velocity,
  229.               final double[] sigmaPV, final double baseWeight, final int propagatorIndex) {
  230.         this(date, position, velocity, sigmaPV, baseWeight, new ObservableSatellite(0));
  231.     }

  232.     /** Constructor with one vector for the standard deviations.
  233.      * <p>The 6-sized vector is the square root of the diagonal elements of the covariance matrix.</p>
  234.      * <p>The measurement must be in the orbit propagation frame.</p>
  235.      * @param date date of the measurement
  236.      * @param position position
  237.      * @param velocity velocity
  238.      * @param sigmaPV 6-sized vector of the standard deviations
  239.      * @param baseWeight base weight
  240.      * @param satellite satellite related to this measurement
  241.      * @since 9.3
  242.      */
  243.     public PV(final AbsoluteDate date, final Vector3D position, final Vector3D velocity,
  244.               final double[] sigmaPV, final double baseWeight, final ObservableSatellite satellite) {
  245.         this(date, position, velocity, buildPvCovarianceMatrix(sigmaPV), baseWeight, satellite);
  246.     }

  247.     /**
  248.      * Constructor with 2 smaller covariance matrices and default value for propagator index.
  249.      * <p>One 3x3 covariance matrix for position and one 3x3 covariance matrix for velocity.
  250.      * The fact that the covariance matrices are symmetric and positive definite is not checked.</p>
  251.      * <p>The measurement must be in the orbit propagation frame.</p>
  252.      * <p>This constructor uses 0 as the index of the propagator related
  253.      * to this measurement, thus being well suited for mono-satellite
  254.      * orbit determination.</p>
  255.      * @param date date of the measurement
  256.      * @param position position
  257.      * @param velocity velocity
  258.      * @param positionCovarianceMatrix 3x3 covariance matrix of the position
  259.      * @param velocityCovarianceMatrix 3x3 covariance matrix of the velocity
  260.      * @param baseWeight base weight
  261.      * @since 9.2
  262.      * @deprecated as of 9.3, replaced by {@link #PV(AbsoluteDate, Vector3D, Vector3D,
  263.      * double[][], double[][], double, ObservableSatellite)}
  264.      */
  265.     @Deprecated
  266.     public PV(final AbsoluteDate date, final Vector3D position, final Vector3D velocity,
  267.               final double[][] positionCovarianceMatrix, final double[][] velocityCovarianceMatrix,
  268.               final double baseWeight) {
  269.         this(date, position, velocity, positionCovarianceMatrix, velocityCovarianceMatrix,
  270.              baseWeight, new ObservableSatellite(0));
  271.     }

  272.     /**
  273.      * Constructor with 2 smaller covariance matrices.
  274.      * <p>One 3x3 covariance matrix for position and one 3x3 covariance matrix for velocity.
  275.      * The fact that the covariance matrices are symmetric and positive definite is not checked.</p>
  276.      * <p>The measurement must be in the orbit propagation frame.</p>
  277.      * @param date date of the measurement
  278.      * @param position position
  279.      * @param velocity velocity
  280.      * @param positionCovarianceMatrix 3x3 covariance matrix of the position
  281.      * @param velocityCovarianceMatrix 3x3 covariance matrix of the velocity
  282.      * @param baseWeight base weight
  283.      * @param propagatorIndex index of the propagator related to this measurement
  284.      * @since 9.2
  285.      * @deprecated as of 9.3, replaced by {@link #PV(AbsoluteDate, Vector3D, Vector3D,
  286.      * double[][], double[][], double, ObservableSatellite)}
  287.      */
  288.     @Deprecated
  289.     public PV(final AbsoluteDate date, final Vector3D position, final Vector3D velocity,
  290.               final double[][] positionCovarianceMatrix, final double[][] velocityCovarianceMatrix,
  291.               final double baseWeight, final int propagatorIndex) {
  292.         this(date, position, velocity, positionCovarianceMatrix, velocityCovarianceMatrix,
  293.              baseWeight, new ObservableSatellite(propagatorIndex));
  294.     }

  295.     /**
  296.      * Constructor with 2 smaller covariance matrices.
  297.      * <p>One 3x3 covariance matrix for position and one 3x3 covariance matrix for velocity.
  298.      * The fact that the covariance matrices are symmetric and positive definite is not checked.</p>
  299.      * <p>The measurement must be in the orbit propagation frame.</p>
  300.      * @param date date of the measurement
  301.      * @param position position
  302.      * @param velocity velocity
  303.      * @param positionCovarianceMatrix 3x3 covariance matrix of the position
  304.      * @param velocityCovarianceMatrix 3x3 covariance matrix of the velocity
  305.      * @param baseWeight base weight
  306.      * @param satellite satellite related to this measurement
  307.      * @since 9.3
  308.      */
  309.     public PV(final AbsoluteDate date, final Vector3D position, final Vector3D velocity,
  310.               final double[][] positionCovarianceMatrix, final double[][] velocityCovarianceMatrix,
  311.               final double baseWeight, final ObservableSatellite satellite) {
  312.         this(date, position, velocity,
  313.              buildPvCovarianceMatrix(positionCovarianceMatrix, velocityCovarianceMatrix),
  314.              baseWeight, satellite);
  315.     }

  316.     /**
  317.      * Constructor with full covariance matrix but default index for propagator.
  318.      * <p>The fact that the covariance matrix is symmetric and positive definite is not checked.</p>
  319.      * <p>The measurement must be in the orbit propagation frame.</p>
  320.      * <p>This constructor uses 0 as the index of the propagator related
  321.      * to this measurement, thus being well suited for mono-satellite
  322.      * orbit determination.</p>
  323.      * @param date date of the measurement
  324.      * @param position position
  325.      * @param velocity velocity
  326.      * @param covarianceMatrix 6x6 covariance matrix of the PV measurement
  327.      * @param baseWeight base weight
  328.      * @since 9.2
  329.      * @deprecated as of 9.3, replaced by {@link #PV(AbsoluteDate, Vector3D, Vector3D,
  330.      * double[][], double, ObservableSatellite)}
  331.      */
  332.     @Deprecated
  333.     public PV(final AbsoluteDate date, final Vector3D position, final Vector3D velocity,
  334.               final double[][] covarianceMatrix, final double baseWeight) {
  335.         this(date, position, velocity, covarianceMatrix, baseWeight, new ObservableSatellite(0));
  336.     }

  337.     /** Constructor with full covariance matrix and all inputs.
  338.      * <p>The fact that the covariance matrix is symmetric and positive definite is not checked.</p>
  339.      * <p>The measurement must be in the orbit propagation frame.</p>
  340.      * @param date date of the measurement
  341.      * @param position position
  342.      * @param velocity velocity
  343.      * @param covarianceMatrix 6x6 covariance matrix of the PV measurement
  344.      * @param baseWeight base weight
  345.      * @param propagatorIndex index of the propagator related to this measurement
  346.      * @since 9.2
  347.      * @deprecated as of 9.3, replaced by {@link #PV(AbsoluteDate, Vector3D, Vector3D,
  348.      * double[][], double, ObservableSatellite)}
  349.      */
  350.     @Deprecated
  351.     public PV(final AbsoluteDate date, final Vector3D position, final Vector3D velocity,
  352.               final double[][] covarianceMatrix, final double baseWeight, final int propagatorIndex) {
  353.         this(date, position, velocity, covarianceMatrix, baseWeight, new ObservableSatellite(propagatorIndex));
  354.     }

  355.     /** Constructor with full covariance matrix and all inputs.
  356.      * <p>The fact that the covariance matrix is symmetric and positive definite is not checked.</p>
  357.      * <p>The measurement must be in the orbit propagation frame.</p>
  358.      * @param date date of the measurement
  359.      * @param position position
  360.      * @param velocity velocity
  361.      * @param covarianceMatrix 6x6 covariance matrix of the PV measurement
  362.      * @param baseWeight base weight
  363.      * @param satellite satellite related to this measurement
  364.      * @since 9.3
  365.      */
  366.     public PV(final AbsoluteDate date, final Vector3D position, final Vector3D velocity,
  367.               final double[][] covarianceMatrix, final double baseWeight, final ObservableSatellite satellite) {
  368.         super(date,
  369.               new double[] {
  370.                   position.getX(), position.getY(), position.getZ(),
  371.                   velocity.getX(), velocity.getY(), velocity.getZ()
  372.               }, extractSigmas(covarianceMatrix),
  373.               new double[] {
  374.                   baseWeight, baseWeight, baseWeight,
  375.                   baseWeight, baseWeight, baseWeight
  376.               }, Arrays.asList(satellite));
  377.         this.covarianceMatrix = covarianceMatrix;
  378.     }

  379.     /** Get the position.
  380.      * @return position
  381.      */
  382.     public Vector3D getPosition() {
  383.         final double[] pv = getObservedValue();
  384.         return new Vector3D(pv[0], pv[1], pv[2]);
  385.     }

  386.     /** Get the velocity.
  387.      * @return velocity
  388.      */
  389.     public Vector3D getVelocity() {
  390.         final double[] pv = getObservedValue();
  391.         return new Vector3D(pv[3], pv[4], pv[5]);
  392.     }

  393.     /** Get the covariance matrix.
  394.      * @return the covariance matrix
  395.      */
  396.     public double[][] getCovarianceMatrix() {
  397.         return covarianceMatrix;
  398.     }

  399.     /** Get the correlation coefficients matrix.
  400.      * <br>This is the 6x6 matrix M such that:</br>
  401.      * <br>Mij = Pij/(σi.σj)</br>
  402.      * <br>Where: <ul>
  403.      * <li> P is the covariance matrix
  404.      * <li> σi is the i-th standard deviation (σi² = Pii)
  405.      * </ul>
  406.      * @return the correlation coefficient matrix (6x6)
  407.      */
  408.     public double[][] getCorrelationCoefficientsMatrix() {

  409.         // Get the standard deviations
  410.         final double[] sigmas = getTheoreticalStandardDeviation();

  411.         // Initialize the correlation coefficients matric to the covariance matrix
  412.         final double[][] corrCoefMatrix = new double[sigmas.length][sigmas.length];

  413.         // Divide by the standard deviations
  414.         for (int i = 0; i < sigmas.length; i++) {
  415.             for (int j = 0; j < sigmas.length; j++) {
  416.                 corrCoefMatrix[i][j] = covarianceMatrix[i][j] / (sigmas[i] * sigmas[j]);
  417.             }
  418.         }
  419.         return corrCoefMatrix;
  420.     }

  421.     /** {@inheritDoc} */
  422.     @Override
  423.     protected EstimatedMeasurement<PV> theoreticalEvaluation(final int iteration, final int evaluation,
  424.                                                              final SpacecraftState[] states) {

  425.         // PV value
  426.         final ObservableSatellite      satellite = getSatellites().get(0);
  427.         final SpacecraftState          state     = states[satellite.getPropagatorIndex()];
  428.         final TimeStampedPVCoordinates pv        = state.getPVCoordinates();

  429.         // prepare the evaluation
  430.         final EstimatedMeasurement<PV> estimated =
  431.                         new EstimatedMeasurement<>(this, iteration, evaluation, states,
  432.                                                    new TimeStampedPVCoordinates[] {
  433.                                                        pv
  434.                                                    });

  435.         estimated.setEstimatedValue(new double[] {
  436.             pv.getPosition().getX(), pv.getPosition().getY(), pv.getPosition().getZ(),
  437.             pv.getVelocity().getX(), pv.getVelocity().getY(), pv.getVelocity().getZ()
  438.         });

  439.         // partial derivatives with respect to state
  440.         estimated.setStateDerivatives(0, IDENTITY);

  441.         return estimated;
  442.     }

  443.     /** Extract standard deviations from a 6x6 PV covariance matrix.
  444.      * Check the size of the PV covariance matrix first.
  445.      * @param pvCovarianceMatrix the 6x6 PV covariance matrix
  446.      * @return the standard deviations (6-sized vector), they are
  447.      * the square roots of the diagonal elements of the covariance matrix in input.
  448.      */
  449.     private static double[] extractSigmas(final double[][] pvCovarianceMatrix) {

  450.         // Check the size of the covariance matrix, should be 6x6
  451.         if (pvCovarianceMatrix.length != 6 || pvCovarianceMatrix[0].length != 6) {
  452.             throw new OrekitException(LocalizedCoreFormats.DIMENSIONS_MISMATCH_2x2,
  453.                                       pvCovarianceMatrix.length, pvCovarianceMatrix[0],
  454.                                       6, 6);
  455.         }

  456.         // Extract the standard deviations (square roots of the diagonal elements)
  457.         final double[] sigmas = new double[6];
  458.         for (int i = 0; i < sigmas.length; i++) {
  459.             sigmas[i] = FastMath.sqrt(pvCovarianceMatrix[i][i]);
  460.         }
  461.         return sigmas;
  462.     }

  463.     /** Build a 6x6 PV covariance matrix from two 3x3 matrices (covariances in position and velocity).
  464.      * Check the size of the matrices first.
  465.      * @param positionCovarianceMatrix the 3x3 covariance matrix in position
  466.      * @param velocityCovarianceMatrix the 3x3 covariance matrix in velocity
  467.      * @return the 6x6 PV covariance matrix
  468.      */
  469.     private static double[][] buildPvCovarianceMatrix(final double[][] positionCovarianceMatrix,
  470.                                                       final double[][] velocityCovarianceMatrix) {
  471.         // Check the sizes of the matrices first
  472.         if (positionCovarianceMatrix.length != 3 || positionCovarianceMatrix[0].length != 3) {
  473.             throw new OrekitException(LocalizedCoreFormats.DIMENSIONS_MISMATCH_2x2,
  474.                                       positionCovarianceMatrix.length, positionCovarianceMatrix[0],
  475.                                       3, 3);
  476.         }
  477.         if (velocityCovarianceMatrix.length != 3 || velocityCovarianceMatrix[0].length != 3) {
  478.             throw new OrekitException(LocalizedCoreFormats.DIMENSIONS_MISMATCH_2x2,
  479.                                       velocityCovarianceMatrix.length, velocityCovarianceMatrix[0],
  480.                                       3, 3);
  481.         }

  482.         // Build the PV 6x6 covariance matrix
  483.         final double[][] pvCovarianceMatrix = new double[6][6];
  484.         for (int i = 0; i < 3; i++) {
  485.             for (int j = 0; j < 3; j++) {
  486.                 pvCovarianceMatrix[i][j]         = positionCovarianceMatrix[i][j];
  487.                 pvCovarianceMatrix[i + 3][j + 3] = velocityCovarianceMatrix[i][j];
  488.             }
  489.         }
  490.         return pvCovarianceMatrix;
  491.     }

  492.     /** Build a 6x6 PV covariance matrix from a 6-sized vector (position and velocity standard deviations).
  493.      * Check the size of the vector first.
  494.      * @param sigmaPV 6-sized vector with position standard deviations on the first 3 elements
  495.      * and velocity standard deviations on the last 3 elements
  496.      * @return the 6x6 PV covariance matrix
  497.      */
  498.     private static double[][] buildPvCovarianceMatrix(final double[] sigmaPV) {
  499.         // Check the size of the vector first
  500.         if (sigmaPV.length != 6) {
  501.             throw new OrekitException(LocalizedCoreFormats.DIMENSIONS_MISMATCH, sigmaPV.length, 6);

  502.         }

  503.         // Build the PV 6x6 covariance matrix
  504.         final double[][] pvCovarianceMatrix = new double[6][6];
  505.         for (int i = 0; i < sigmaPV.length; i++) {
  506.             pvCovarianceMatrix[i][i] =  sigmaPV[i] * sigmaPV[i];
  507.         }
  508.         return pvCovarianceMatrix;
  509.     }

  510.     /** Build a 6x6 PV covariance matrix from two 3-sized vectors (position and velocity standard deviations).
  511.      * Check the sizes of the vectors first.
  512.      * @param sigmaPosition standard deviations of the position (3-size vector)
  513.      * @param sigmaVelocity standard deviations of the velocity (3-size vector)
  514.      * @return the 6x6 PV covariance matrix
  515.      */
  516.     private static double[][] buildPvCovarianceMatrix(final double[] sigmaPosition,
  517.                                                       final double[] sigmaVelocity) {

  518.         // Check the sizes of the vectors first
  519.         if (sigmaPosition.length != 3) {
  520.             throw new OrekitException(LocalizedCoreFormats.DIMENSIONS_MISMATCH, sigmaPosition.length, 3);

  521.         }
  522.         if (sigmaVelocity.length != 3) {
  523.             throw new OrekitException(LocalizedCoreFormats.DIMENSIONS_MISMATCH, sigmaVelocity.length, 3);

  524.         }

  525.         // Build the PV 6x6 covariance matrix
  526.         final double[][] pvCovarianceMatrix = new double[6][6];
  527.         for (int i = 0; i < sigmaPosition.length; i++) {
  528.             pvCovarianceMatrix[i][i]         =  sigmaPosition[i] * sigmaPosition[i];
  529.             pvCovarianceMatrix[i + 3][i + 3] =  sigmaVelocity[i] * sigmaVelocity[i];
  530.         }
  531.         return pvCovarianceMatrix;
  532.     }
  533. }