LOFType.java

  1. /* Copyright 2002-2013 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.frames;

  18. import org.apache.commons.math3.geometry.euclidean.threed.Rotation;
  19. import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
  20. import org.orekit.time.AbsoluteDate;
  21. import org.orekit.utils.PVCoordinates;

  22. /** Enumerate for different types of Local Orbital Frames.
  23.  * @author Luc Maisonobe
  24.  */
  25. public enum LOFType {

  26.     /** Constant for TNW frame
  27.      * (X axis aligned with velocity, Z axis aligned with orbital momentum).
  28.      * <p>
  29.      * The axes of this frame are parallel to the axes of the {@link #VNC} frame:
  30.      * <ul>
  31.      *   <li>X<sub>TNW</sub> =  X<sub>VNC</sub></li>
  32.      *   <li>Y<sub>TNW</sub> = -Z<sub>VNC</sub></li>
  33.      *   <li>Z<sub>TNW</sub> =  Y<sub>VNC</sub></li>
  34.      * </ul>
  35.      * </p>
  36.      * @see #VNC
  37.      */
  38.     TNW {
  39.         /** {@inheritDoc} */
  40.         protected Rotation rotationFromInertial(final PVCoordinates pv) {
  41.             return new Rotation(pv.getVelocity(), pv.getMomentum(),
  42.                                 Vector3D.PLUS_I, Vector3D.PLUS_K);
  43.         }
  44.     },

  45.     /** Constant for QSW frame
  46.      * (X axis aligned with position, Z axis aligned with orbital momentum).
  47.      * <p>
  48.      * This frame is also known as the {@link #LVLH} frame, both constants are equivalent.
  49.      * </p>
  50.      * <p>
  51.      * The axes of these frames are parallel to the axes of the {@link #VVLH} frame:
  52.      * <ul>
  53.      *   <li>X<sub>QSW/LVLH</sub> = -Z<sub>VVLH</sub></li>
  54.      *   <li>Y<sub>QSW/LVLH</sub> =  X<sub>VVLH</sub></li>
  55.      *   <li>Z<sub>QSW/LVLH</sub> = -Y<sub>VVLH</sub></li>
  56.      * </ul>
  57.      * </p>
  58.      * @see #LVLH
  59.      * @see #VVLH
  60.      */
  61.     QSW {
  62.         /** {@inheritDoc} */
  63.         protected Rotation rotationFromInertial(final PVCoordinates pv) {
  64.             return new Rotation(pv.getPosition(), pv.getMomentum(),
  65.                                 Vector3D.PLUS_I, Vector3D.PLUS_K);
  66.         }
  67.     },

  68.     /** Constant for Local Vertical, Local Horizontal frame
  69.      * (X axis aligned with position, Z axis aligned with orbital momentum).
  70.      * <p>
  71.      * This frame is also known as the {@link #QSW} frame, both constants are equivalent.
  72.      * </p>
  73.      * <p>
  74.      * The axes of these frames are parallel to the axes of the {@link #VVLH} frame:
  75.      * <ul>
  76.      *   <li>X<sub>LVLH/QSW</sub> = -Z<sub>VVLH</sub></li>
  77.      *   <li>Y<sub>LVLH/QSW</sub> =  X<sub>VVLH</sub></li>
  78.      *   <li>Z<sub>LVLH/QSW</sub> = -Y<sub>VVLH</sub></li>
  79.      * </ul>
  80.      * </p>
  81.      * @see #QSW
  82.      * @see #VVLH
  83.      */
  84.     LVLH {
  85.         /** {@inheritDoc} */
  86.         protected Rotation rotationFromInertial(final PVCoordinates pv) {
  87.             return new Rotation(pv.getPosition(), pv.getMomentum(),
  88.                                 Vector3D.PLUS_I, Vector3D.PLUS_K);
  89.         }
  90.     },

  91.     /** Constant for Vehicle Velocity, Local Horizontal frame
  92.      * (Z axis aligned with opposite of position, Y axis aligned with opposite of orbital momentum).
  93.      * <p>
  94.      * The axes of this frame are parallel to the axes of both the {@link #QSW} and {@link #LVLH} frames:
  95.      * <ul>
  96.      *   <li>X<sub>VVLH</sub> =  Y<sub>QSW/LVLH</sub></li>
  97.      *   <li>Y<sub>VVLH</sub> = -Z<sub>QSW/LVLH</sub></li>
  98.      *   <li>Z<sub>VVLH</sub> = -X<sub>QSW/LVLH</sub></li>
  99.      * </ul>
  100.      * </p>
  101.      * @see #QSW
  102.      * @see #LVLH
  103.      */
  104.     VVLH {
  105.         /** {@inheritDoc} */
  106.         protected Rotation rotationFromInertial(final PVCoordinates pv) {
  107.             return new Rotation(pv.getPosition(), pv.getMomentum(),
  108.                                 Vector3D.MINUS_K, Vector3D.MINUS_J);
  109.         }
  110.     },

  111.     /** Constant for Velocity - Normal - Co-normal frame
  112.      * (X axis aligned with velocity, Y axis aligned with orbital momentum).
  113.      * <p>
  114.      * The axes of this frame are parallel to the axes of the {@link #TNW} frame:
  115.      * <ul>
  116.      *   <li>X<sub>VNC</sub> =  X<sub>TNW</sub></li>
  117.      *   <li>Y<sub>VNC</sub> =  Z<sub>TNW</sub></li>
  118.      *   <li>Z<sub>VNC</sub> = -Y<sub>TNW</sub></li>
  119.      * </ul>
  120.      * </p>
  121.      * @see #TNW
  122.      */
  123.     VNC {
  124.         /** {@inheritDoc} */
  125.         protected Rotation rotationFromInertial(final PVCoordinates pv) {
  126.             return new Rotation(pv.getVelocity(), pv.getMomentum(),
  127.                                 Vector3D.PLUS_I, Vector3D.PLUS_J);
  128.         }
  129.     };

  130.     /** Get the transform from an inertial frame defining position-velocity and the local orbital frame.
  131.      * @param date current date
  132.      * @param pv position-velocity of the spacecraft in some inertial frame
  133.      * @return transform from the frame where position-velocity are defined to local orbital frame
  134.      */
  135.     public Transform transformFromInertial(final AbsoluteDate date, final PVCoordinates pv) {

  136.         // compute the translation part of the transform
  137.         final Transform translation = new Transform(date, pv.negate());

  138.         // compute the rotation part of the transform
  139.         final Rotation r = rotationFromInertial(pv);
  140.         final Vector3D p = pv.getPosition();
  141.         final Vector3D momentum = pv.getMomentum();
  142.         final Transform rotation =
  143.                 new Transform(date, r, new Vector3D(1.0 / p.getNormSq(), r.applyTo(momentum)));

  144.         return new Transform(date, translation, rotation);

  145.     }

  146.     /** Get the rotation from inertial frame to local orbital frame.
  147.      * @param pv position-velocity of the spacecraft in some inertial frame
  148.      * @return rotation from inertial frame to local orbital frame
  149.      */
  150.     protected abstract Rotation rotationFromInertial(final PVCoordinates pv);

  151. }