PVCoordinates.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.utils;

  18. import java.io.Serializable;

  19. import org.hipparchus.analysis.differentiation.DSFactory;
  20. import org.hipparchus.analysis.differentiation.DerivativeStructure;
  21. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  22. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  23. import org.hipparchus.util.FastMath;
  24. import org.orekit.errors.OrekitException;
  25. import org.orekit.errors.OrekitMessages;
  26. import org.orekit.time.TimeShiftable;

  27. /** Simple container for Position/Velocity/Acceleration triplets.
  28.  * <p>
  29.  * The state can be slightly shifted to close dates. This shift is based on
  30.  * a simple quadratic model. It is <em>not</em> intended as a replacement for
  31.  * proper orbit propagation (it is not even Keplerian!) but should be sufficient
  32.  * for either small time shifts or coarse accuracy.
  33.  * </p>
  34.  * <p>
  35.  * This class is the angular counterpart to {@link AngularCoordinates}.
  36.  * </p>
  37.  * <p>Instances of this class are guaranteed to be immutable.</p>
  38.  * @author Fabien Maussion
  39.  * @author Luc Maisonobe
  40.  */
  41. public class PVCoordinates implements TimeShiftable<PVCoordinates>, Serializable {

  42.     /** Fixed position/velocity at origin (both p, v and a are zero vectors). */
  43.     public static final PVCoordinates ZERO = new PVCoordinates(Vector3D.ZERO, Vector3D.ZERO, Vector3D.ZERO);

  44.     /** Serializable UID. */
  45.     private static final long serialVersionUID = 20140407L;

  46.     /** The position. */
  47.     private final Vector3D position;

  48.     /** The velocity. */
  49.     private final Vector3D velocity;

  50.     /** The acceleration. */
  51.     private final Vector3D acceleration;

  52.     /** Simple constructor.
  53.      * <p> Set the Coordinates to default : (0 0 0), (0 0 0), (0 0 0).</p>
  54.      */
  55.     public PVCoordinates() {
  56.         position     = Vector3D.ZERO;
  57.         velocity     = Vector3D.ZERO;
  58.         acceleration = Vector3D.ZERO;
  59.     }

  60.     /** Builds a PVCoordinates triplet with zero acceleration.
  61.      * <p>Acceleration is set to zero</p>
  62.      * @param position the position vector (m)
  63.      * @param velocity the velocity vector (m/s)
  64.      */
  65.     public PVCoordinates(final Vector3D position, final Vector3D velocity) {
  66.         this.position     = position;
  67.         this.velocity     = velocity;
  68.         this.acceleration = Vector3D.ZERO;
  69.     }

  70.     /** Builds a PVCoordinates triplet.
  71.      * @param position the position vector (m)
  72.      * @param velocity the velocity vector (m/s)
  73.      * @param acceleration the acceleration vector (m/s²)
  74.      */
  75.     public PVCoordinates(final Vector3D position, final Vector3D velocity, final Vector3D acceleration) {
  76.         this.position     = position;
  77.         this.velocity     = velocity;
  78.         this.acceleration = acceleration;
  79.     }

  80.     /** Multiplicative constructor.
  81.      * <p>Build a PVCoordinates from another one and a scale factor.</p>
  82.      * <p>The PVCoordinates built will be a * pv</p>
  83.      * @param a scale factor
  84.      * @param pv base (unscaled) PVCoordinates
  85.      */
  86.     public PVCoordinates(final double a, final PVCoordinates pv) {
  87.         position     = new Vector3D(a, pv.position);
  88.         velocity     = new Vector3D(a, pv.velocity);
  89.         acceleration = new Vector3D(a, pv.acceleration);
  90.     }

  91.     /** Subtractive constructor.
  92.      * <p>Build a relative PVCoordinates from a start and an end position.</p>
  93.      * <p>The PVCoordinates built will be end - start.</p>
  94.      * @param start Starting PVCoordinates
  95.      * @param end ending PVCoordinates
  96.      */
  97.     public PVCoordinates(final PVCoordinates start, final PVCoordinates end) {
  98.         this.position     = end.position.subtract(start.position);
  99.         this.velocity     = end.velocity.subtract(start.velocity);
  100.         this.acceleration = end.acceleration.subtract(start.acceleration);
  101.     }

  102.     /** Linear constructor.
  103.      * <p>Build a PVCoordinates from two other ones and corresponding scale factors.</p>
  104.      * <p>The PVCoordinates built will be a1 * u1 + a2 * u2</p>
  105.      * @param a1 first scale factor
  106.      * @param pv1 first base (unscaled) PVCoordinates
  107.      * @param a2 second scale factor
  108.      * @param pv2 second base (unscaled) PVCoordinates
  109.      */
  110.     public PVCoordinates(final double a1, final PVCoordinates pv1,
  111.                          final double a2, final PVCoordinates pv2) {
  112.         position     = new Vector3D(a1, pv1.position,     a2, pv2.position);
  113.         velocity     = new Vector3D(a1, pv1.velocity,     a2, pv2.velocity);
  114.         acceleration = new Vector3D(a1, pv1.acceleration, a2, pv2.acceleration);
  115.     }

  116.     /** Linear constructor.
  117.      * <p>Build a PVCoordinates from three other ones and corresponding scale factors.</p>
  118.      * <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3</p>
  119.      * @param a1 first scale factor
  120.      * @param pv1 first base (unscaled) PVCoordinates
  121.      * @param a2 second scale factor
  122.      * @param pv2 second base (unscaled) PVCoordinates
  123.      * @param a3 third scale factor
  124.      * @param pv3 third base (unscaled) PVCoordinates
  125.      */
  126.     public PVCoordinates(final double a1, final PVCoordinates pv1,
  127.                          final double a2, final PVCoordinates pv2,
  128.                          final double a3, final PVCoordinates pv3) {
  129.         position     = new Vector3D(a1, pv1.position,     a2, pv2.position,     a3, pv3.position);
  130.         velocity     = new Vector3D(a1, pv1.velocity,     a2, pv2.velocity,     a3, pv3.velocity);
  131.         acceleration = new Vector3D(a1, pv1.acceleration, a2, pv2.acceleration, a3, pv3.acceleration);
  132.     }

  133.     /** Linear constructor.
  134.      * <p>Build a PVCoordinates from four other ones and corresponding scale factors.</p>
  135.      * <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4</p>
  136.      * @param a1 first scale factor
  137.      * @param pv1 first base (unscaled) PVCoordinates
  138.      * @param a2 second scale factor
  139.      * @param pv2 second base (unscaled) PVCoordinates
  140.      * @param a3 third scale factor
  141.      * @param pv3 third base (unscaled) PVCoordinates
  142.      * @param a4 fourth scale factor
  143.      * @param pv4 fourth base (unscaled) PVCoordinates
  144.      */
  145.     public PVCoordinates(final double a1, final PVCoordinates pv1,
  146.                          final double a2, final PVCoordinates pv2,
  147.                          final double a3, final PVCoordinates pv3,
  148.                          final double a4, final PVCoordinates pv4) {
  149.         position     = new Vector3D(a1, pv1.position,     a2, pv2.position,
  150.                                     a3, pv3.position,     a4, pv4.position);
  151.         velocity     = new Vector3D(a1, pv1.velocity,     a2, pv2.velocity,
  152.                                     a3, pv3.velocity,     a4, pv4.velocity);
  153.         acceleration = new Vector3D(a1, pv1.acceleration, a2, pv2.acceleration,
  154.                                     a3, pv3.acceleration, a4, pv4.acceleration);
  155.     }

  156.     /** Builds a PVCoordinates triplet from  a {@link FieldVector3D}&lt;{@link DerivativeStructure}&gt;.
  157.      * <p>
  158.      * The vector components must have time as their only derivation parameter and
  159.      * have consistent derivation orders.
  160.      * </p>
  161.      * @param p vector with time-derivatives embedded within the coordinates
  162.      */
  163.     public PVCoordinates(final FieldVector3D<DerivativeStructure> p) {
  164.         position = new Vector3D(p.getX().getReal(), p.getY().getReal(), p.getZ().getReal());
  165.         if (p.getX().getOrder() >= 1) {
  166.             velocity = new Vector3D(p.getX().getPartialDerivative(1),
  167.                                     p.getY().getPartialDerivative(1),
  168.                                     p.getZ().getPartialDerivative(1));
  169.             if (p.getX().getOrder() >= 2) {
  170.                 acceleration = new Vector3D(p.getX().getPartialDerivative(2),
  171.                                             p.getY().getPartialDerivative(2),
  172.                                             p.getZ().getPartialDerivative(2));
  173.             } else {
  174.                 acceleration = Vector3D.ZERO;
  175.             }
  176.         } else {
  177.             velocity     = Vector3D.ZERO;
  178.             acceleration = Vector3D.ZERO;
  179.         }
  180.     }

  181.     /** Transform the instance to a {@link FieldVector3D}&lt;{@link DerivativeStructure}&gt;.
  182.      * <p>
  183.      * The {@link DerivativeStructure} coordinates correspond to time-derivatives up
  184.      * to the user-specified order.
  185.      * </p>
  186.      * @param order derivation order for the vector components (must be either 0, 1 or 2)
  187.      * @return vector with time-derivatives embedded within the coordinates
  188.      */
  189.     public FieldVector3D<DerivativeStructure> toDerivativeStructureVector(final int order) {

  190.         final DSFactory factory;
  191.         final DerivativeStructure x;
  192.         final DerivativeStructure y;
  193.         final DerivativeStructure z;
  194.         switch(order) {
  195.             case 0 :
  196.                 factory = new DSFactory(1, order);
  197.                 x = factory.build(position.getX());
  198.                 y = factory.build(position.getY());
  199.                 z = factory.build(position.getZ());
  200.                 break;
  201.             case 1 :
  202.                 factory = new DSFactory(1, order);
  203.                 x = factory.build(position.getX(), velocity.getX());
  204.                 y = factory.build(position.getY(), velocity.getY());
  205.                 z = factory.build(position.getZ(), velocity.getZ());
  206.                 break;
  207.             case 2 :
  208.                 factory = new DSFactory(1, order);
  209.                 x = factory.build(position.getX(), velocity.getX(), acceleration.getX());
  210.                 y = factory.build(position.getY(), velocity.getY(), acceleration.getY());
  211.                 z = factory.build(position.getZ(), velocity.getZ(), acceleration.getZ());
  212.                 break;
  213.             default :
  214.                 throw new OrekitException(OrekitMessages.OUT_OF_RANGE_DERIVATION_ORDER, order);
  215.         }

  216.         return new FieldVector3D<>(x, y, z);

  217.     }

  218.     /** Transform the instance to a {@link FieldPVCoordinates}&lt;{@link DerivativeStructure}&gt;.
  219.      * <p>
  220.      * The {@link DerivativeStructure} coordinates correspond to time-derivatives up
  221.      * to the user-specified order. As both the instance components {@link #getPosition() position},
  222.      * {@link #getVelocity() velocity} and {@link #getAcceleration() acceleration} and the
  223.      * {@link DerivativeStructure#getPartialDerivative(int...) derivatives} of the components
  224.      * holds time-derivatives, there are several ways to retrieve these derivatives. If for example
  225.      * the {@code order} is set to 2, then both {@code pv.getPosition().getX().getPartialDerivative(2)},
  226.      * {@code pv.getVelocity().getX().getPartialDerivative(1)} and
  227.      * {@code pv.getAcceleration().getX().getValue()} return the exact same value.
  228.      * </p>
  229.      * <p>
  230.      * If derivation order is 1, the first derivative of acceleration will be computed as a
  231.      * Keplerian-only jerk. If derivation order is 2, the second derivative of velocity (which
  232.      * is also the first derivative of acceleration) will be computed as a Keplerian-only jerk,
  233.      * and the second derivative of acceleration will be computed as a Keplerian-only jounce.
  234.      * </p>
  235.      * @param order derivation order for the vector components (must be either 0, 1 or 2)
  236.      * @return pv coordinates with time-derivatives embedded within the coordinates
  237.           * @since 9.2
  238.      */
  239.     public FieldPVCoordinates<DerivativeStructure> toDerivativeStructurePV(final int order) {

  240.         final DSFactory factory;
  241.         final DerivativeStructure x0;
  242.         final DerivativeStructure y0;
  243.         final DerivativeStructure z0;
  244.         final DerivativeStructure x1;
  245.         final DerivativeStructure y1;
  246.         final DerivativeStructure z1;
  247.         final DerivativeStructure x2;
  248.         final DerivativeStructure y2;
  249.         final DerivativeStructure z2;
  250.         switch(order) {
  251.             case 0 :
  252.                 factory = new DSFactory(1, order);
  253.                 x0 = factory.build(position.getX());
  254.                 y0 = factory.build(position.getY());
  255.                 z0 = factory.build(position.getZ());
  256.                 x1 = factory.build(velocity.getX());
  257.                 y1 = factory.build(velocity.getY());
  258.                 z1 = factory.build(velocity.getZ());
  259.                 x2 = factory.build(acceleration.getX());
  260.                 y2 = factory.build(acceleration.getY());
  261.                 z2 = factory.build(acceleration.getZ());
  262.                 break;
  263.             case 1 : {
  264.                 factory = new DSFactory(1, order);
  265.                 final double   r2            = position.getNormSq();
  266.                 final double   r             = FastMath.sqrt(r2);
  267.                 final double   pvOr2         = Vector3D.dotProduct(position, velocity) / r2;
  268.                 final double   a             = acceleration.getNorm();
  269.                 final double   aOr           = a / r;
  270.                 final Vector3D keplerianJerk = new Vector3D(-3 * pvOr2, acceleration, -aOr, velocity);
  271.                 x0 = factory.build(position.getX(),     velocity.getX());
  272.                 y0 = factory.build(position.getY(),     velocity.getY());
  273.                 z0 = factory.build(position.getZ(),     velocity.getZ());
  274.                 x1 = factory.build(velocity.getX(),     acceleration.getX());
  275.                 y1 = factory.build(velocity.getY(),     acceleration.getY());
  276.                 z1 = factory.build(velocity.getZ(),     acceleration.getZ());
  277.                 x2 = factory.build(acceleration.getX(), keplerianJerk.getX());
  278.                 y2 = factory.build(acceleration.getY(), keplerianJerk.getY());
  279.                 z2 = factory.build(acceleration.getZ(), keplerianJerk.getZ());
  280.                 break;
  281.             }
  282.             case 2 : {
  283.                 factory = new DSFactory(1, order);
  284.                 final double   r2              = position.getNormSq();
  285.                 final double   r               = FastMath.sqrt(r2);
  286.                 final double   pvOr2           = Vector3D.dotProduct(position, velocity) / r2;
  287.                 final double   a               = acceleration.getNorm();
  288.                 final double   aOr             = a / r;
  289.                 final Vector3D keplerianJerk   = new Vector3D(-3 * pvOr2, acceleration, -aOr, velocity);
  290.                 final double   v2              = velocity.getNormSq();
  291.                 final double   pa              = Vector3D.dotProduct(position, acceleration);
  292.                 final double   aj              = Vector3D.dotProduct(acceleration, keplerianJerk);
  293.                 final Vector3D keplerianJounce = new Vector3D(-3 * (v2 + pa) / r2 + 15 * pvOr2 * pvOr2 - aOr, acceleration,
  294.                                                               4 * aOr * pvOr2 - aj / (a * r), velocity);
  295.                 x0 = factory.build(position.getX(),     velocity.getX(),      acceleration.getX());
  296.                 y0 = factory.build(position.getY(),     velocity.getY(),      acceleration.getY());
  297.                 z0 = factory.build(position.getZ(),     velocity.getZ(),      acceleration.getZ());
  298.                 x1 = factory.build(velocity.getX(),     acceleration.getX(),  keplerianJerk.getX());
  299.                 y1 = factory.build(velocity.getY(),     acceleration.getY(),  keplerianJerk.getY());
  300.                 z1 = factory.build(velocity.getZ(),     acceleration.getZ(),  keplerianJerk.getZ());
  301.                 x2 = factory.build(acceleration.getX(), keplerianJerk.getX(), keplerianJounce.getX());
  302.                 y2 = factory.build(acceleration.getY(), keplerianJerk.getY(), keplerianJounce.getY());
  303.                 z2 = factory.build(acceleration.getZ(), keplerianJerk.getZ(), keplerianJounce.getZ());
  304.                 break;
  305.             }
  306.             default :
  307.                 throw new OrekitException(OrekitMessages.OUT_OF_RANGE_DERIVATION_ORDER, order);
  308.         }

  309.         return new FieldPVCoordinates<>(new FieldVector3D<>(x0, y0, z0),
  310.                                         new FieldVector3D<>(x1, y1, z1),
  311.                                         new FieldVector3D<>(x2, y2, z2));

  312.     }

  313.     /** Estimate velocity between two positions.
  314.      * <p>Estimation is based on a simple fixed velocity translation
  315.      * during the time interval between the two positions.</p>
  316.      * @param start start position
  317.      * @param end end position
  318.      * @param dt time elapsed between the dates of the two positions
  319.      * @return velocity allowing to go from start to end positions
  320.      */
  321.     public static Vector3D estimateVelocity(final Vector3D start, final Vector3D end, final double dt) {
  322.         final double scale = 1.0 / dt;
  323.         return new Vector3D(scale, end, -scale, start);
  324.     }

  325.     /** Get a time-shifted state.
  326.      * <p>
  327.      * The state can be slightly shifted to close dates. This shift is based on
  328.      * a simple Taylor expansion. It is <em>not</em> intended as a replacement for
  329.      * proper orbit propagation (it is not even Keplerian!) but should be sufficient
  330.      * for either small time shifts or coarse accuracy.
  331.      * </p>
  332.      * @param dt time shift in seconds
  333.      * @return a new state, shifted with respect to the instance (which is immutable)
  334.      */
  335.     public PVCoordinates shiftedBy(final double dt) {
  336.         return new PVCoordinates(new Vector3D(1, position, dt, velocity, 0.5 * dt * dt, acceleration),
  337.                                  new Vector3D(1, velocity, dt, acceleration),
  338.                                  acceleration);
  339.     }

  340.     /** Gets the position.
  341.      * @return the position vector (m).
  342.      */
  343.     public Vector3D getPosition() {
  344.         return position;
  345.     }

  346.     /** Gets the velocity.
  347.      * @return the velocity vector (m/s).
  348.      */
  349.     public Vector3D getVelocity() {
  350.         return velocity;
  351.     }

  352.     /** Gets the acceleration.
  353.      * @return the acceleration vector (m/s²).
  354.      */
  355.     public Vector3D getAcceleration() {
  356.         return acceleration;
  357.     }

  358.     /** Gets the momentum.
  359.      * <p>This vector is the p &otimes; v where p is position, v is velocity
  360.      * and &otimes; is cross product. To get the real physical angular momentum
  361.      * you need to multiply this vector by the mass.</p>
  362.      * <p>The returned vector is recomputed each time this method is called, it
  363.      * is not cached.</p>
  364.      * @return a new instance of the momentum vector (m²/s).
  365.      */
  366.     public Vector3D getMomentum() {
  367.         return Vector3D.crossProduct(position, velocity);
  368.     }

  369.     /**
  370.      * Get the angular velocity (spin) of this point as seen from the origin.
  371.      *
  372.      * <p> The angular velocity vector is parallel to the {@link #getMomentum()
  373.      * angular momentum} and is computed by ω = p &times; v / ||p||²
  374.      *
  375.      * @return the angular velocity vector
  376.      * @see <a href="http://en.wikipedia.org/wiki/Angular_velocity">Angular Velocity on
  377.      *      Wikipedia</a>
  378.      */
  379.     public Vector3D getAngularVelocity() {
  380.         return this.getMomentum().scalarMultiply(1.0 / this.getPosition().getNormSq());
  381.     }

  382.     /** Get the opposite of the instance.
  383.      * @return a new position-velocity which is opposite to the instance
  384.      */
  385.     public PVCoordinates negate() {
  386.         return new PVCoordinates(position.negate(), velocity.negate(), acceleration.negate());
  387.     }

  388.     /** Normalize the position part of the instance.
  389.      * <p>
  390.      * The computed coordinates first component (position) will be a
  391.      * normalized vector, the second component (velocity) will be the
  392.      * derivative of the first component (hence it will generally not
  393.      * be normalized), and the third component (acceleration) will be the
  394.      * derivative of the second component (hence it will generally not
  395.      * be normalized).
  396.      * </p>
  397.      * @return a new instance, with first component normalized and
  398.      * remaining component computed to have consistent derivatives
  399.      */
  400.     public PVCoordinates normalize() {
  401.         final double   inv     = 1.0 / position.getNorm();
  402.         final Vector3D u       = new Vector3D(inv, position);
  403.         final Vector3D v       = new Vector3D(inv, velocity);
  404.         final Vector3D w       = new Vector3D(inv, acceleration);
  405.         final double   uv      = Vector3D.dotProduct(u, v);
  406.         final double   v2      = Vector3D.dotProduct(v, v);
  407.         final double   uw      = Vector3D.dotProduct(u, w);
  408.         final Vector3D uDot    = new Vector3D(1, v, -uv, u);
  409.         final Vector3D uDotDot = new Vector3D(1, w, -2 * uv, v, 3 * uv * uv - v2 - uw, u);
  410.         return new PVCoordinates(u, uDot, uDotDot);
  411.     }

  412.     /** Compute the cross-product of two instances.
  413.      * @param pv1 first instances
  414.      * @param pv2 second instances
  415.      * @return the cross product v1 ^ v2 as a new instance
  416.      */
  417.     public static PVCoordinates crossProduct(final PVCoordinates pv1, final PVCoordinates pv2) {
  418.         final Vector3D p1 = pv1.position;
  419.         final Vector3D v1 = pv1.velocity;
  420.         final Vector3D a1 = pv1.acceleration;
  421.         final Vector3D p2 = pv2.position;
  422.         final Vector3D v2 = pv2.velocity;
  423.         final Vector3D a2 = pv2.acceleration;
  424.         return new PVCoordinates(Vector3D.crossProduct(p1, p2),
  425.                                  new Vector3D(1, Vector3D.crossProduct(p1, v2),
  426.                                               1, Vector3D.crossProduct(v1, p2)),
  427.                                  new Vector3D(1, Vector3D.crossProduct(p1, a2),
  428.                                               2, Vector3D.crossProduct(v1, v2),
  429.                                               1, Vector3D.crossProduct(a1, p2)));
  430.     }

  431.     /** Return a string representation of this position/velocity pair.
  432.      * @return string representation of this position/velocity pair
  433.      */
  434.     public String toString() {
  435.         final String comma = ", ";
  436.         return new StringBuffer().append('{').append("P(").
  437.                 append(position.getX()).append(comma).
  438.                 append(position.getY()).append(comma).
  439.                 append(position.getZ()).append("), V(").
  440.                 append(velocity.getX()).append(comma).
  441.                 append(velocity.getY()).append(comma).
  442.                 append(velocity.getZ()).append("), A(").
  443.                 append(acceleration.getX()).append(comma).
  444.                 append(acceleration.getY()).append(comma).
  445.                 append(acceleration.getZ()).append(")}").toString();
  446.     }

  447.     /** Replace the instance with a data transfer object for serialization.
  448.      * @return data transfer object that will be serialized
  449.      */
  450.     private Object writeReplace() {
  451.         return new DTO(this);
  452.     }

  453.     /** Internal class used only for serialization. */
  454.     private static class DTO implements Serializable {

  455.         /** Serializable UID. */
  456.         private static final long serialVersionUID = 20140723L;

  457.         /** Double values. */
  458.         private double[] d;

  459.         /** Simple constructor.
  460.          * @param pv instance to serialize
  461.          */
  462.         private DTO(final PVCoordinates pv) {
  463.             this.d = new double[] {
  464.                 pv.getPosition().getX(),     pv.getPosition().getY(),     pv.getPosition().getZ(),
  465.                 pv.getVelocity().getX(),     pv.getVelocity().getY(),     pv.getVelocity().getZ(),
  466.                 pv.getAcceleration().getX(), pv.getAcceleration().getY(), pv.getAcceleration().getZ(),
  467.             };
  468.         }

  469.         /** Replace the deserialized data transfer object with a {@link PVCoordinates}.
  470.          * @return replacement {@link PVCoordinates}
  471.          */
  472.         private Object readResolve() {
  473.             return new PVCoordinates(new Vector3D(d[0], d[1], d[2]),
  474.                                      new Vector3D(d[3], d[4], d[5]),
  475.                                      new Vector3D(d[6], d[7], d[8]));
  476.         }

  477.     }

  478. }