FieldPVCoordinates.java

  1. /* Copyright 2002-2017 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 org.hipparchus.Field;
  19. import org.hipparchus.RealFieldElement;
  20. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  21. import org.orekit.time.TimeShiftable;

  22. /** Simple container for Position/Velocity pairs, using {@link RealFieldElement}.
  23.  * <p>
  24.  * The state can be slightly shifted to close dates. This shift is based on
  25.  * a simple linear model. It is <em>not</em> intended as a replacement for
  26.  * proper orbit propagation (it is not even Keplerian!) but should be sufficient
  27.  * for either small time shifts or coarse accuracy.
  28.  * </p>
  29.  * <p>
  30.  * This class is the angular counterpart to {@link FieldAngularCoordinates}.
  31.  * </p>
  32.  * <p>Instances of this class are guaranteed to be immutable.</p>
  33.  * @param <T> the type of the field elements
  34.  * @author Luc Maisonobe
  35.  * @since 6.0
  36.  * @see PVCoordinates
  37.  */
  38. public class FieldPVCoordinates<T extends RealFieldElement<T>>
  39.     implements TimeShiftable<FieldPVCoordinates<T>> {

  40.     /** The position. */
  41.     private final FieldVector3D<T> position;

  42.     /** The velocity. */
  43.     private final FieldVector3D<T> velocity;

  44.     /** The acceleration. */
  45.     private final FieldVector3D<T> acceleration;

  46.     /** Builds a FieldPVCoordinates triplet with zero acceleration.
  47.      * @param position the position vector (m)
  48.      * @param velocity the velocity vector (m/s)
  49.      */
  50.     public FieldPVCoordinates(final FieldVector3D<T> position, final FieldVector3D<T> velocity) {
  51.         this.position     = position;
  52.         this.velocity     = velocity;
  53.         final T zero      = position.getX().getField().getZero();
  54.         this.acceleration = new FieldVector3D<>(zero, zero, zero);
  55.     }

  56.     /** Builds a FieldPVCoordinates triplet.
  57.      * @param position the position vector (m)
  58.      * @param velocity the velocity vector (m/s)
  59.      * @param acceleration the acceleration vector (m/s²)
  60.      */
  61.     public FieldPVCoordinates(final FieldVector3D<T> position, final FieldVector3D<T> velocity,
  62.                               final FieldVector3D<T> acceleration) {
  63.         this.position     = position;
  64.         this.velocity     = velocity;
  65.         this.acceleration = acceleration;
  66.     }

  67.     /** Builds a FieldPVCoordinates from a field and a regular PVCoordinates.
  68.      * @param field field for the components
  69.      * @param pv PVCoordinates triplet to convert
  70.      */
  71.     public FieldPVCoordinates(final Field<T> field, final PVCoordinates pv) {
  72.         this.position     = new FieldVector3D<>(field, pv.getPosition());
  73.         this.velocity     = new FieldVector3D<>(field, pv.getVelocity());
  74.         this.acceleration = new FieldVector3D<>(field, pv.getAcceleration());
  75.     }

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

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

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

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

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

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

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

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

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

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

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

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

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

  276.     /** Get fixed position/velocity at origin (both p, v and a are zero vectors).
  277.      * @param field field for the components
  278.      * @param <T> the type of the field elements
  279.      * @return a new fixed position/velocity at origin
  280.      */
  281.     public static <T extends RealFieldElement<T>> FieldPVCoordinates<T> getZero(final Field<T> field) {
  282.         return new FieldPVCoordinates<>(field, PVCoordinates.ZERO);
  283.     }

  284.     /** Estimate velocity between two positions.
  285.      * <p>Estimation is based on a simple fixed velocity translation
  286.      * during the time interval between the two positions.</p>
  287.      * @param start start position
  288.      * @param end end position
  289.      * @param dt time elapsed between the dates of the two positions
  290.      * @param <T> the type of the field elements
  291.      * @return velocity allowing to go from start to end positions
  292.      */
  293.     public static <T extends RealFieldElement<T>> FieldVector3D<T> estimateVelocity(final FieldVector3D<T> start,
  294.                                                                                     final FieldVector3D<T> end,
  295.                                                                                     final double dt) {
  296.         final double scale = 1.0 / dt;
  297.         return new FieldVector3D<>(scale, end, -scale, start);
  298.     }

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

  314.     /** Get a time-shifted state.
  315.      * <p>
  316.      * The state can be slightly shifted to close dates. This shift is based on
  317.      * a simple quadratic model. It is <em>not</em> intended as a replacement for
  318.      * proper orbit propagation (it is not even Keplerian!) but should be sufficient
  319.      * for either small time shifts or coarse accuracy.
  320.      * </p>
  321.      * @param dt time shift in seconds
  322.      * @return a new state, shifted with respect to the instance (which is immutable)
  323.      */
  324.     public FieldPVCoordinates<T> shiftedBy(final T dt) {
  325.         final T one = dt.getField().getOne();
  326.         return new FieldPVCoordinates<>(new FieldVector3D<>(one, position,
  327.                                                             dt, velocity,
  328.                                                             dt.multiply(dt).multiply(0.5), acceleration),
  329.                                         new FieldVector3D<>(one, velocity,
  330.                                                             dt, acceleration),
  331.                                         acceleration);
  332.     }

  333.     /** Gets the position.
  334.      * @return the position vector (m).
  335.      */
  336.     public FieldVector3D<T> getPosition() {
  337.         return position;
  338.     }

  339.     /** Gets the velocity.
  340.      * @return the velocity vector (m/s).
  341.      */
  342.     public FieldVector3D<T> getVelocity() {
  343.         return velocity;
  344.     }

  345.     /** Gets the acceleration.
  346.      * @return the acceleration vector (m/s²).
  347.      */
  348.     public FieldVector3D<T> getAcceleration() {
  349.         return acceleration;
  350.     }

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

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

  376.     /** Get the opposite of the instance.
  377.      * @return a new position-velocity which is opposite to the instance
  378.      */
  379.     public FieldPVCoordinates<T> negate() {
  380.         return new FieldPVCoordinates<>(position.negate(), velocity.negate(), acceleration.negate());
  381.     }

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

  409.     /** Compute the cross-product of two instances.
  410.      * @param pv2 second instances
  411.      * @return the cross product v1 ^ v2 as a new instance
  412.      */
  413.     public FieldPVCoordinates<T> crossProduct(final FieldPVCoordinates<T> pv2) {
  414.         final FieldVector3D<T> p1 = position;
  415.         final FieldVector3D<T> v1 = velocity;
  416.         final FieldVector3D<T> a1 = acceleration;
  417.         final FieldVector3D<T> p2 = pv2.position;
  418.         final FieldVector3D<T> v2 = pv2.velocity;
  419.         final FieldVector3D<T> a2 = pv2.acceleration;
  420.         return new FieldPVCoordinates<>(FieldVector3D.crossProduct(p1, p2),
  421.                                         new FieldVector3D<>(1, FieldVector3D.crossProduct(p1, v2),
  422.                                                             1, FieldVector3D.crossProduct(v1, p2)),
  423.                                         new FieldVector3D<>(1, FieldVector3D.crossProduct(p1, a2),
  424.                                                             2, FieldVector3D.crossProduct(v1, v2),
  425.                                                             1, FieldVector3D.crossProduct(a1, p2)));
  426.     }

  427.     /** Convert to a constant position-velocity.
  428.      * @return a constant position-velocity
  429.      */
  430.     public PVCoordinates toPVCoordinates() {
  431.         return new PVCoordinates(position.toVector3D(), velocity.toVector3D(), acceleration.toVector3D());
  432.     }

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

  449. }