DefaultEncounterLOF.java

  1. /* Copyright 2002-2024 CS GROUP
  2.  * Licensed to CS GROUP (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.encounter;

  18. import org.hipparchus.CalculusFieldElement;
  19. import org.hipparchus.Field;
  20. import org.hipparchus.geometry.euclidean.threed.FieldRotation;
  21. import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
  22. import org.hipparchus.geometry.euclidean.threed.Rotation;
  23. import org.hipparchus.geometry.euclidean.threed.Vector3D;
  24. import org.orekit.utils.FieldPVCoordinates;
  25. import org.orekit.utils.PVCoordinates;

  26. /**
  27.  * Default encounter local orbital frame.
  28.  * <p>
  29.  * Note that <b>it is up to the user</b> to choose which object should be at the origin.
  30.  * <p>
  31.  * It is defined as follows :
  32.  * <ul>
  33.  * <li>z axis : Normalized relative velocity vector.</li>
  34.  * <li>y axis : Normalized cross product between z axis and other relative to origin position.</li>
  35.  * <li>x axis : Completes the right handed coordinate system.</li>
  36.  * </ul>
  37.  *
  38.  * @author Vincent Cucchietti
  39.  * @since 12.0
  40.  */
  41. public class DefaultEncounterLOF extends AbstractEncounterLOF {

  42.     /**
  43.      * Constructor.
  44.      *
  45.      * @param other other object to create the encounter frame with (not the origin of the frame !)
  46.      */
  47.     public DefaultEncounterLOF(final PVCoordinates other) {
  48.         super(other);
  49.     }

  50.     /**
  51.      * Field constructor.
  52.      *
  53.      * @param other other object to create the encounter frame with (not the origin of the frame !)
  54.      * @param <T> type of the field elements
  55.      */
  56.     public <T extends CalculusFieldElement<T>> DefaultEncounterLOF(final FieldPVCoordinates<T> other) {
  57.         super(other);
  58.     }

  59.     /** {@inheritDoc} */
  60.     @Override
  61.     public Rotation rotationFromInertial(final PVCoordinates origin, final PVCoordinates other) {
  62.         final Vector3D zAxis = other.getVelocity().subtract(origin.getVelocity()).normalize();
  63.         final Vector3D yAxis = zAxis.crossProduct(other.getPosition().subtract(origin.getPosition()));

  64.         return new Rotation(yAxis, zAxis, Vector3D.PLUS_J, Vector3D.PLUS_K);
  65.     }

  66.     /**
  67.      * {@inheritDoc}
  68.      * <p>
  69.      * In this case, return (0,0,1);
  70.      */
  71.     @Override
  72.     public <T extends CalculusFieldElement<T>> FieldVector3D<T> getAxisNormalToCollisionPlane(final Field<T> field) {
  73.         return FieldVector3D.getPlusK(field);
  74.     }

  75.     /** {@inheritDoc} */
  76.     @Override
  77.     public <T extends CalculusFieldElement<T>> FieldRotation<T> rotationFromInertial(final Field<T> field,
  78.                                                                                      final FieldPVCoordinates<T> origin,
  79.                                                                                      final FieldPVCoordinates<T> other) {
  80.         final FieldVector3D<T> otherVelocity = other.getVelocity();
  81.         final FieldVector3D<T> otherPosition = other.getPosition();

  82.         final FieldVector3D<T> zAxis = otherVelocity.subtract(origin.getVelocity()).normalize();
  83.         final FieldVector3D<T> yAxis = zAxis.crossProduct(otherPosition.subtract(origin.getPosition()));

  84.         return new FieldRotation<>(yAxis, zAxis, FieldVector3D.getPlusJ(field), FieldVector3D.getPlusK(field));
  85.     }

  86.     /**
  87.      * {@inheritDoc}
  88.      * <p>
  89.      * In this case, return (0,0,1);
  90.      */
  91.     @Override
  92.     public Vector3D getAxisNormalToCollisionPlane() {
  93.         return Vector3D.PLUS_K;
  94.     }

  95.     /** {@inheritDoc} */
  96.     @Override
  97.     public String getName() {
  98.         return "DEFAULT_ENCOUNTER_LOF";
  99.     }
  100. }