1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.orekit.rugged.los;
18
19 import java.util.stream.Stream;
20
21 import org.hipparchus.analysis.differentiation.DerivativeStructure;
22 import org.hipparchus.geometry.euclidean.threed.FieldRotation;
23 import org.hipparchus.geometry.euclidean.threed.FieldVector3D;
24 import org.hipparchus.geometry.euclidean.threed.Rotation;
25 import org.hipparchus.geometry.euclidean.threed.RotationConvention;
26 import org.hipparchus.geometry.euclidean.threed.Vector3D;
27 import org.hipparchus.util.FastMath;
28 import org.orekit.rugged.utils.DSGenerator;
29 import org.orekit.utils.ParameterDriver;
30 import org.orekit.utils.ParameterObserver;
31
32
33
34
35
36 public class FixedRotation implements TimeIndependentLOSTransform {
37
38
39
40
41
42
43
44 private final double SCALE = FastMath.scalb(1.0, -20);
45
46
47 private final Vector3D axis;
48
49
50 private Rotation rotation;
51
52
53 private FieldRotation<DerivativeStructure> rDS;
54
55
56 private final ParameterDriver angleDriver;
57
58
59
60
61
62
63
64
65
66 public FixedRotation(final String name, final Vector3D axis, final double angle) {
67
68 this.axis = axis;
69 this.rotation = null;
70 this.rDS = null;
71 this.angleDriver = new ParameterDriver(name, angle, SCALE, -2 * FastMath.PI, 2 * FastMath.PI);
72 angleDriver.addObserver(new ParameterObserver() {
73 @Override
74 public void valueChanged(final double previousValue, final ParameterDriver driver) {
75
76 rotation = null;
77 rDS = null;
78 }
79 });
80 }
81
82
83 @Override
84 public Stream<ParameterDriver> getParametersDrivers() {
85 return Stream.of(angleDriver);
86 }
87
88
89 @Override
90 public Vector3D transformLOS(final int i, final Vector3D los) {
91 if (rotation == null) {
92
93 rotation = new Rotation(axis, angleDriver.getValue(), RotationConvention.VECTOR_OPERATOR);
94 }
95 return rotation.applyTo(los);
96 }
97
98
99 @Override
100 public FieldVector3D<DerivativeStructure> transformLOS(final int i, final FieldVector3D<DerivativeStructure> los,
101 final DSGenerator generator) {
102 if (rDS == null) {
103
104 final FieldVector3D<DerivativeStructure> axisDS =
105 new FieldVector3D<DerivativeStructure>(generator.constant(axis.getX()),
106 generator.constant(axis.getY()),
107 generator.constant(axis.getZ()));
108 final DerivativeStructure angleDS = generator.variable(angleDriver);
109 rDS = new FieldRotation<DerivativeStructure>(axisDS, angleDS, RotationConvention.VECTOR_OPERATOR);
110 }
111 return rDS.applyTo(los);
112 }
113
114 }