1 /* Copyright 2002-2025 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
19 import org.hipparchus.CalculusFieldElement;
20 import org.hipparchus.Field;
21 import org.hipparchus.geometry.euclidean.threed.FieldRotation;
22 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
23 import org.hipparchus.geometry.euclidean.threed.Rotation;
24 import org.hipparchus.geometry.euclidean.threed.Vector3D;
25 import org.orekit.utils.FieldPVCoordinates;
26 import org.orekit.utils.PVCoordinates;
27
28 /**
29 * Default encounter local orbital frame.
30 * <p>
31 * Note that <b>it is up to the user</b> to choose which object should be at the origin.
32 * <p>
33 * It is defined as follows :
34 * <ul>
35 * <li>z axis : Normalized relative velocity vector.</li>
36 * <li>y axis : Normalized cross product between z axis and other relative to origin position.</li>
37 * <li>x axis : Completes the right handed coordinate system.</li>
38 * </ul>
39 *
40 * @author Vincent Cucchietti
41 * @since 12.0
42 */
43 public class DefaultEncounterLOF extends AbstractEncounterLOF {
44
45 /**
46 * Constructor.
47 *
48 * @param other other object to create the encounter frame with (not the origin of the frame !)
49 */
50 public DefaultEncounterLOF(final PVCoordinates other) {
51 super(other);
52 }
53
54 /**
55 * Field constructor.
56 *
57 * @param other other object to create the encounter frame with (not the origin of the frame !)
58 * @param <T> type of the field elements
59 */
60 public <T extends CalculusFieldElement<T>> DefaultEncounterLOF(final FieldPVCoordinates<T> other) {
61 super(other);
62 }
63
64 /** {@inheritDoc} */
65 @Override
66 public Rotation rotationFromInertial(final PVCoordinates origin, final PVCoordinates other) {
67 final Vector3D zAxis = other.getVelocity().subtract(origin.getVelocity()).normalize();
68 final Vector3D yAxis = zAxis.crossProduct(other.getPosition().subtract(origin.getPosition()));
69
70 return new Rotation(yAxis, zAxis, Vector3D.PLUS_J, Vector3D.PLUS_K);
71 }
72
73 /**
74 * {@inheritDoc}
75 * <p>
76 * In this case, return (0,0,1);
77 */
78 @Override
79 public <T extends CalculusFieldElement<T>> FieldVector3D<T> getAxisNormalToCollisionPlane(final Field<T> field) {
80 return FieldVector3D.getPlusK(field);
81 }
82
83 /** {@inheritDoc} */
84 @Override
85 public <T extends CalculusFieldElement<T>> FieldRotation<T> rotationFromInertial(final Field<T> field,
86 final FieldPVCoordinates<T> origin,
87 final FieldPVCoordinates<T> other) {
88 final FieldVector3D<T> otherVelocity = other.getVelocity();
89 final FieldVector3D<T> otherPosition = other.getPosition();
90
91 final FieldVector3D<T> zAxis = otherVelocity.subtract(origin.getVelocity()).normalize();
92 final FieldVector3D<T> yAxis = zAxis.crossProduct(otherPosition.subtract(origin.getPosition()));
93
94 return new FieldRotation<>(yAxis, zAxis, FieldVector3D.getPlusJ(field), FieldVector3D.getPlusK(field));
95 }
96
97 /**
98 * {@inheritDoc}
99 * <p>
100 * In this case, return (0,0,1);
101 */
102 @Override
103 public Vector3D getAxisNormalToCollisionPlane() {
104 return Vector3D.PLUS_K;
105 }
106
107 /** {@inheritDoc} */
108 @Override
109 public String getName() {
110 return "DEFAULT_ENCOUNTER_LOF";
111 }
112 }