FieldPVCoordinates.java

  1. /* Copyright 2002-2016 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 java.util.ArrayList;
  20. import java.util.Collection;
  21. import java.util.List;

  22. import org.apache.commons.math3.RealFieldElement;
  23. import org.apache.commons.math3.geometry.euclidean.threed.FieldVector3D;
  24. import org.apache.commons.math3.util.Pair;
  25. import org.orekit.time.AbsoluteDate;
  26. import org.orekit.time.TimeShiftable;

  27. /** Simple container for Position/Velocity pairs, using {@link RealFieldElement}.
  28.  * <p>
  29.  * The state can be slightly shifted to close dates. This shift is based on
  30.  * a simple linear 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 FieldAngularCoordinates}.
  36.  * </p>
  37.  * <p>Instances of this class are guaranteed to be immutable.</p>
  38.  * @param <T> the type of the field elements
  39.  * @author Luc Maisonobe
  40.  * @since 6.0
  41.  * @see PVCoordinates
  42.  */
  43. public class FieldPVCoordinates<T extends RealFieldElement<T>>
  44.     implements TimeShiftable<FieldPVCoordinates<T>>, Serializable {

  45.     /** Serializable UID. */
  46.     private static final long serialVersionUID = 20140411L;

  47.     /** The position. */
  48.     private final FieldVector3D<T> position;

  49.     /** The velocity. */
  50.     private final FieldVector3D<T> velocity;

  51.     /** The acceleration. */
  52.     private final FieldVector3D<T> acceleration;

  53.     /** Builds a PVCoordinates triplet with zero acceleration.
  54.      * @param position the position vector (m)
  55.      * @param velocity the velocity vector (m/s)
  56.      */
  57.     public FieldPVCoordinates(final FieldVector3D<T> position, final FieldVector3D<T> velocity) {
  58.         this.position     = position;
  59.         this.velocity     = velocity;
  60.         final T zero      = position.getX().getField().getZero();
  61.         this.acceleration = new FieldVector3D<T>(zero, zero, zero);
  62.     }

  63.     /** Builds a PVCoordinates triplet.
  64.      * @param position the position vector (m)
  65.      * @param velocity the velocity vector (m/s)
  66.      * @param acceleration the acceleration vector (m/s²)
  67.      */
  68.     public FieldPVCoordinates(final FieldVector3D<T> position, final FieldVector3D<T> velocity,
  69.                               final FieldVector3D<T> acceleration) {
  70.         this.position     = position;
  71.         this.velocity     = velocity;
  72.         this.acceleration = acceleration;
  73.     }

  74.     /** Multiplicative constructor
  75.      * <p>Build a PVCoordinates from another one and a scale factor.</p>
  76.      * <p>The PVCoordinates built will be a * pv</p>
  77.      * @param a scale factor
  78.      * @param pv base (unscaled) PVCoordinates
  79.      */
  80.     public FieldPVCoordinates(final double a, final FieldPVCoordinates<T> pv) {
  81.         position     = new FieldVector3D<T>(a, pv.position);
  82.         velocity     = new FieldVector3D<T>(a, pv.velocity);
  83.         acceleration = new FieldVector3D<T>(a, pv.acceleration);
  84.     }

  85.     /** Multiplicative constructor
  86.      * <p>Build a PVCoordinates from another one and a scale factor.</p>
  87.      * <p>The PVCoordinates built will be a * pv</p>
  88.      * @param a scale factor
  89.      * @param pv base (unscaled) PVCoordinates
  90.      */
  91.     public FieldPVCoordinates(final T a, final FieldPVCoordinates<T> pv) {
  92.         position     = new FieldVector3D<T>(a, pv.position);
  93.         velocity     = new FieldVector3D<T>(a, pv.velocity);
  94.         acceleration = new FieldVector3D<T>(a, pv.acceleration);
  95.     }

  96.     /** Multiplicative constructor
  97.      * <p>Build a PVCoordinates from another one and a scale factor.</p>
  98.      * <p>The PVCoordinates built will be a * pv</p>
  99.      * @param a scale factor
  100.      * @param pv base (unscaled) PVCoordinates
  101.      */
  102.     public FieldPVCoordinates(final T a, final PVCoordinates pv) {
  103.         position     = new FieldVector3D<T>(a, pv.getPosition());
  104.         velocity     = new FieldVector3D<T>(a, pv.getVelocity());
  105.         acceleration = new FieldVector3D<T>(a, pv.getAcceleration());
  106.     }

  107.     /** Subtractive constructor
  108.      * <p>Build a relative PVCoordinates from a start and an end position.</p>
  109.      * <p>The PVCoordinates built will be end - start.</p>
  110.      * @param start Starting PVCoordinates
  111.      * @param end ending PVCoordinates
  112.      */
  113.     public FieldPVCoordinates(final FieldPVCoordinates<T> start, final FieldPVCoordinates<T> end) {
  114.         this.position     = end.position.subtract(start.position);
  115.         this.velocity     = end.velocity.subtract(start.velocity);
  116.         this.acceleration = end.acceleration.subtract(start.acceleration);
  117.     }

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

  132.     /** Linear constructor
  133.      * <p>Build a PVCoordinates from two other ones and corresponding scale factors.</p>
  134.      * <p>The PVCoordinates built will be a1 * u1 + a2 * u2</p>
  135.      * @param a1 first scale factor
  136.      * @param pv1 first base (unscaled) PVCoordinates
  137.      * @param a2 second scale factor
  138.      * @param pv2 second base (unscaled) PVCoordinates
  139.      */
  140.     public FieldPVCoordinates(final T a1, final FieldPVCoordinates<T> pv1,
  141.                               final T a2, final FieldPVCoordinates<T> pv2) {
  142.         position     = new FieldVector3D<T>(a1, pv1.position, a2, pv2.position);
  143.         velocity     = new FieldVector3D<T>(a1, pv1.velocity, a2, pv2.velocity);
  144.         acceleration = new FieldVector3D<T>(a1, pv1.acceleration, a2, pv2.acceleration);
  145.     }

  146.     /** Linear constructor
  147.      * <p>Build a PVCoordinates from two other ones and corresponding scale factors.</p>
  148.      * <p>The PVCoordinates built will be a1 * u1 + a2 * u2</p>
  149.      * @param a1 first scale factor
  150.      * @param pv1 first base (unscaled) PVCoordinates
  151.      * @param a2 second scale factor
  152.      * @param pv2 second base (unscaled) PVCoordinates
  153.      */
  154.     public FieldPVCoordinates(final T a1, final PVCoordinates pv1,
  155.                               final T a2, final PVCoordinates pv2) {
  156.         position     = new FieldVector3D<T>(a1, pv1.getPosition(), a2, pv2.getPosition());
  157.         velocity     = new FieldVector3D<T>(a1, pv1.getVelocity(), a2, pv2.getVelocity());
  158.         acceleration = new FieldVector3D<T>(a1, pv1.getAcceleration(), a2, pv2.getAcceleration());
  159.     }

  160.     /** Linear constructor
  161.      * <p>Build a PVCoordinates from three other ones and corresponding scale factors.</p>
  162.      * <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3</p>
  163.      * @param a1 first scale factor
  164.      * @param pv1 first base (unscaled) PVCoordinates
  165.      * @param a2 second scale factor
  166.      * @param pv2 second base (unscaled) PVCoordinates
  167.      * @param a3 third scale factor
  168.      * @param pv3 third base (unscaled) PVCoordinates
  169.      */
  170.     public FieldPVCoordinates(final double a1, final FieldPVCoordinates<T> pv1,
  171.                            final double a2, final FieldPVCoordinates<T> pv2,
  172.                            final double a3, final FieldPVCoordinates<T> pv3) {
  173.         position     = new FieldVector3D<T>(a1, pv1.position,     a2, pv2.position,     a3, pv3.position);
  174.         velocity     = new FieldVector3D<T>(a1, pv1.velocity,     a2, pv2.velocity,     a3, pv3.velocity);
  175.         acceleration = new FieldVector3D<T>(a1, pv1.acceleration, a2, pv2.acceleration, a3, pv3.acceleration);
  176.     }

  177.     /** Linear constructor
  178.      * <p>Build a PVCoordinates from three other ones and corresponding scale factors.</p>
  179.      * <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3</p>
  180.      * @param a1 first scale factor
  181.      * @param pv1 first base (unscaled) PVCoordinates
  182.      * @param a2 second scale factor
  183.      * @param pv2 second base (unscaled) PVCoordinates
  184.      * @param a3 third scale factor
  185.      * @param pv3 third base (unscaled) PVCoordinates
  186.      */
  187.     public FieldPVCoordinates(final T a1, final FieldPVCoordinates<T> pv1,
  188.                               final T a2, final FieldPVCoordinates<T> pv2,
  189.                               final T a3, final FieldPVCoordinates<T> pv3) {
  190.         position     = new FieldVector3D<T>(a1, pv1.position,     a2, pv2.position,     a3, pv3.position);
  191.         velocity     = new FieldVector3D<T>(a1, pv1.velocity,     a2, pv2.velocity,     a3, pv3.velocity);
  192.         acceleration = new FieldVector3D<T>(a1, pv1.acceleration, a2, pv2.acceleration, a3, pv3.acceleration);
  193.     }

  194.     /** Linear constructor
  195.      * <p>Build a PVCoordinates from three other ones and corresponding scale factors.</p>
  196.      * <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3</p>
  197.      * @param a1 first scale factor
  198.      * @param pv1 first base (unscaled) PVCoordinates
  199.      * @param a2 second scale factor
  200.      * @param pv2 second base (unscaled) PVCoordinates
  201.      * @param a3 third scale factor
  202.      * @param pv3 third base (unscaled) PVCoordinates
  203.      */
  204.     public FieldPVCoordinates(final T a1, final PVCoordinates pv1,
  205.                               final T a2, final PVCoordinates pv2,
  206.                               final T a3, final PVCoordinates pv3) {
  207.         position     = new FieldVector3D<T>(a1, pv1.getPosition(),     a2, pv2.getPosition(),     a3, pv3.getPosition());
  208.         velocity     = new FieldVector3D<T>(a1, pv1.getVelocity(),     a2, pv2.getVelocity(),     a3, pv3.getVelocity());
  209.         acceleration = new FieldVector3D<T>(a1, pv1.getAcceleration(), a2, pv2.getAcceleration(), a3, pv3.getAcceleration());
  210.     }

  211.     /** Linear constructor
  212.      * <p>Build a PVCoordinates from four other ones and corresponding scale factors.</p>
  213.      * <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4</p>
  214.      * @param a1 first scale factor
  215.      * @param pv1 first base (unscaled) PVCoordinates
  216.      * @param a2 second scale factor
  217.      * @param pv2 second base (unscaled) PVCoordinates
  218.      * @param a3 third scale factor
  219.      * @param pv3 third base (unscaled) PVCoordinates
  220.      * @param a4 fourth scale factor
  221.      * @param pv4 fourth base (unscaled) PVCoordinates
  222.      */
  223.     public FieldPVCoordinates(final double a1, final FieldPVCoordinates<T> pv1,
  224.                               final double a2, final FieldPVCoordinates<T> pv2,
  225.                               final double a3, final FieldPVCoordinates<T> pv3,
  226.                               final double a4, final FieldPVCoordinates<T> pv4) {
  227.         position     = new FieldVector3D<T>(a1, pv1.position,     a2, pv2.position,     a3, pv3.position,     a4, pv4.position);
  228.         velocity     = new FieldVector3D<T>(a1, pv1.velocity,     a2, pv2.velocity,     a3, pv3.velocity,     a4, pv4.velocity);
  229.         acceleration = new FieldVector3D<T>(a1, pv1.acceleration, a2, pv2.acceleration, a3, pv3.acceleration, a4, pv4.acceleration);
  230.     }

  231.     /** Linear constructor
  232.      * <p>Build a PVCoordinates from four other ones and corresponding scale factors.</p>
  233.      * <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4</p>
  234.      * @param a1 first scale factor
  235.      * @param pv1 first base (unscaled) PVCoordinates
  236.      * @param a2 second scale factor
  237.      * @param pv2 second base (unscaled) PVCoordinates
  238.      * @param a3 third scale factor
  239.      * @param pv3 third base (unscaled) PVCoordinates
  240.      * @param a4 fourth scale factor
  241.      * @param pv4 fourth base (unscaled) PVCoordinates
  242.      */
  243.     public FieldPVCoordinates(final T a1, final FieldPVCoordinates<T> pv1,
  244.                               final T a2, final FieldPVCoordinates<T> pv2,
  245.                               final T a3, final FieldPVCoordinates<T> pv3,
  246.                               final T a4, final FieldPVCoordinates<T> pv4) {
  247.         position     = new FieldVector3D<T>(a1, pv1.position,     a2, pv2.position,     a3, pv3.position,     a4, pv4.position);
  248.         velocity     = new FieldVector3D<T>(a1, pv1.velocity,     a2, pv2.velocity,     a3, pv3.velocity,     a4, pv4.velocity);
  249.         acceleration = new FieldVector3D<T>(a1, pv1.acceleration, a2, pv2.acceleration, a3, pv3.acceleration, a4, pv4.acceleration);
  250.     }

  251.     /** Linear constructor
  252.      * <p>Build a PVCoordinates from four other ones and corresponding scale factors.</p>
  253.      * <p>The PVCoordinates built will be a1 * u1 + a2 * u2 + a3 * u3 + a4 * u4</p>
  254.      * @param a1 first scale factor
  255.      * @param pv1 first base (unscaled) PVCoordinates
  256.      * @param a2 second scale factor
  257.      * @param pv2 second base (unscaled) PVCoordinates
  258.      * @param a3 third scale factor
  259.      * @param pv3 third base (unscaled) PVCoordinates
  260.      * @param a4 fourth scale factor
  261.      * @param pv4 fourth base (unscaled) PVCoordinates
  262.      */
  263.     public FieldPVCoordinates(final T a1, final PVCoordinates pv1,
  264.                               final T a2, final PVCoordinates pv2,
  265.                               final T a3, final PVCoordinates pv3,
  266.                               final T a4, final PVCoordinates pv4) {
  267.         position     = new FieldVector3D<T>(a1, pv1.getPosition(),     a2, pv2.getPosition(),
  268.                                             a3, pv3.getPosition(),     a4, pv4.getPosition());
  269.         velocity     = new FieldVector3D<T>(a1, pv1.getVelocity(),     a2, pv2.getVelocity(),
  270.                                             a3, pv3.getVelocity(),     a4, pv4.getVelocity());
  271.         acceleration = new FieldVector3D<T>(a1, pv1.getAcceleration(), a2, pv2.getAcceleration(),
  272.                                             a3, pv3.getAcceleration(), a4, pv4.getAcceleration());
  273.     }

  274.     /** Estimate velocity between two positions.
  275.      * <p>Estimation is based on a simple fixed velocity translation
  276.      * during the time interval between the two positions.</p>
  277.      * @param start start position
  278.      * @param end end position
  279.      * @param dt time elapsed between the dates of the two positions
  280.      * @param <T> the type of the field elements
  281.      * @return velocity allowing to go from start to end positions
  282.      */
  283.     public static <T extends RealFieldElement<T>> FieldVector3D<T> estimateVelocity(final FieldVector3D<T> start,
  284.                                                                                     final FieldVector3D<T> end,
  285.                                                                                     final double dt) {
  286.         final double scale = 1.0 / dt;
  287.         return new FieldVector3D<T>(scale, end, -scale, start);
  288.     }

  289.     /** Get a time-shifted state.
  290.      * <p>
  291.      * The state can be slightly shifted to close dates. This shift is based on
  292.      * a simple quadratic model. It is <em>not</em> intended as a replacement for
  293.      * proper orbit propagation (it is not even Keplerian!) but should be sufficient
  294.      * for either small time shifts or coarse accuracy.
  295.      * </p>
  296.      * @param dt time shift in seconds
  297.      * @return a new state, shifted with respect to the instance (which is immutable)
  298.      */
  299.     public FieldPVCoordinates<T> shiftedBy(final double dt) {
  300.         return new FieldPVCoordinates<T>(new FieldVector3D<T>(1, position, dt, velocity, 0.5 * dt * dt, acceleration),
  301.                                          new FieldVector3D<T>(1, velocity, dt, acceleration),
  302.                                          acceleration);
  303.     }

  304.     /** Interpolate position-velocity.
  305.      * <p>
  306.      * The interpolated instance is created by polynomial Hermite interpolation
  307.      * ensuring velocity remains the exact derivative of position.
  308.      * </p>
  309.      * <p>
  310.      * Note that even if first time derivatives (velocities)
  311.      * from sample can be ignored, the interpolated instance always includes
  312.      * interpolated derivatives. This feature can be used explicitly to
  313.      * compute these derivatives when it would be too complex to compute them
  314.      * from an analytical formula: just compute a few sample points from the
  315.      * explicit formula and set the derivatives to zero in these sample points,
  316.      * then use interpolation to add derivatives consistent with the positions.
  317.      * </p>
  318.      * @param date interpolation date
  319.      * @param useVelocities if true, use sample points velocities,
  320.      * otherwise ignore them and use only positions
  321.      * @param sample sample points on which interpolation should be done
  322.      * @param <T> the type of the field elements
  323.      * @return a new position-velocity, interpolated at specified date
  324.      * @deprecated as of 7.0, replaced with {@link TimeStampedFieldPVCoordinates#interpolate(AbsoluteDate, CartesianDerivativesFilter, Collection)}
  325.      */
  326.     @Deprecated
  327.     public static <T extends RealFieldElement<T>> FieldPVCoordinates<T> interpolate(final AbsoluteDate date,
  328.                                                                                     final boolean useVelocities,
  329.                                                                                     final Collection<Pair<AbsoluteDate, FieldPVCoordinates<T>>> sample) {
  330.         final List<TimeStampedFieldPVCoordinates<T>> list = new ArrayList<TimeStampedFieldPVCoordinates<T>>(sample.size());
  331.         for (final Pair<AbsoluteDate, FieldPVCoordinates<T>> pair : sample) {
  332.             list.add(new TimeStampedFieldPVCoordinates<T>(pair.getFirst(),
  333.                                                           pair.getSecond().getPosition(),
  334.                                                           pair.getSecond().getVelocity(),
  335.                                                           pair.getSecond().getAcceleration()));
  336.         }
  337.         return TimeStampedFieldPVCoordinates.interpolate(date,
  338.                                                          useVelocities ? CartesianDerivativesFilter.USE_PV : CartesianDerivativesFilter.USE_P,
  339.                                                          list);
  340.     }

  341.     /** Gets the position.
  342.      * @return the position vector (m).
  343.      */
  344.     public FieldVector3D<T> getPosition() {
  345.         return position;
  346.     }

  347.     /** Gets the velocity.
  348.      * @return the velocity vector (m/s).
  349.      */
  350.     public FieldVector3D<T> getVelocity() {
  351.         return velocity;
  352.     }

  353.     /** Gets the acceleration.
  354.      * @return the acceleration vector (m/s²).
  355.      */
  356.     public FieldVector3D<T> getAcceleration() {
  357.         return acceleration;
  358.     }

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

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

  384.     /** Get the opposite of the instance.
  385.      * @return a new position-velocity which is opposite to the instance
  386.      */
  387.     public FieldPVCoordinates<T> negate() {
  388.         return new FieldPVCoordinates<T>(position.negate(), velocity.negate(), acceleration.negate());
  389.     }

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

  417.     /** Convert to a constant position-velocity without derivatives.
  418.      * @return a constant position-velocity
  419.      */
  420.     public PVCoordinates toPVCoordinates() {
  421.         return new PVCoordinates(position.toVector3D(), velocity.toVector3D(), acceleration.toVector3D());
  422.     }

  423.     /** Return a string representation of this position/velocity pair.
  424.      * @return string representation of this position/velocity pair
  425.      */
  426.     public String toString() {
  427.         final String comma = ", ";
  428.         return new StringBuffer().append('{').append("P(").
  429.                                   append(position.getX().getReal()).append(comma).
  430.                                   append(position.getY().getReal()).append(comma).
  431.                                   append(position.getZ().getReal()).append("), V(").
  432.                                   append(velocity.getX().getReal()).append(comma).
  433.                                   append(velocity.getY().getReal()).append(comma).
  434.                                   append(velocity.getZ().getReal()).append("), A(").
  435.                                   append(acceleration.getX().getReal()).append(comma).
  436.                                   append(acceleration.getY().getReal()).append(comma).
  437.                                   append(acceleration.getZ().getReal()).append(")}").toString();
  438.     }

  439. }