@@ -39,7 +39,7 @@ Profile::Target::Target(const TargetType& aType, const Axis& anAxis, const bool&
39
39
}
40
40
41
41
Profile::TrajectoryTarget::TrajectoryTarget (
42
- const Trajectory& aTrajectory, const Axis& anAxis, const bool & isAntiDirection
42
+ const ostk::astrodynamics:: Trajectory& aTrajectory, const Axis& anAxis, const bool & isAntiDirection
43
43
)
44
44
: Target(TargetType::Trajectory, anAxis, isAntiDirection),
45
45
trajectory(aTrajectory)
@@ -50,6 +50,47 @@ Profile::TrajectoryTarget::TrajectoryTarget(
50
50
}
51
51
}
52
52
53
+ Profile::TrajectoryTarget Profile::TrajectoryTarget::TargetPosition (
54
+ const ostk::astrodynamics::Trajectory& aTrajectory, const Axis& anAxis, const bool & isAntiDirection
55
+ )
56
+ {
57
+ return TrajectoryTarget (TargetType::TargetPosition, aTrajectory, anAxis, isAntiDirection);
58
+ }
59
+
60
+ Profile::TrajectoryTarget Profile::TrajectoryTarget::TargetVelocity (
61
+ const ostk::astrodynamics::Trajectory& aTrajectory, const Axis& anAxis, const bool & isAntiDirection
62
+ )
63
+ {
64
+ return TrajectoryTarget (TargetType::TargetVelocity, aTrajectory, anAxis, isAntiDirection);
65
+ }
66
+
67
+ Profile::TrajectoryTarget::TrajectoryTarget (
68
+ const TargetType& aType,
69
+ const ostk::astrodynamics::Trajectory& aTrajectory,
70
+ const Axis& anAxis,
71
+ const bool & isAntiDirection
72
+ )
73
+ : Target(aType, anAxis, isAntiDirection),
74
+ trajectory(aTrajectory)
75
+ {
76
+ if (!trajectory.isDefined ())
77
+ {
78
+ throw ostk::core::error::runtime::Undefined (" Trajectory" );
79
+ }
80
+
81
+ if (aType == TargetType::Trajectory)
82
+ {
83
+ throw ostk::core::error::RuntimeError (
84
+ " TrajectoryTarget::Trajectory is deprecated. Use TrajectoryTarget::TargetPosition instead."
85
+ );
86
+ }
87
+
88
+ if (aType != TargetType::TargetPosition && aType != TargetType::TargetVelocity)
89
+ {
90
+ throw ostk::core::error::runtime::Wrong (" Target type" );
91
+ }
92
+ }
93
+
53
94
Profile::OrientationProfileTarget::OrientationProfileTarget (
54
95
const Array<Pair<Instant, Vector3d>>& anOrientationProfile, const Axis& anAxis, const bool & isAntiDirection
55
96
)
@@ -211,7 +252,7 @@ Profile Profile::Undefined()
211
252
return {};
212
253
}
213
254
214
- Profile Profile::InertialPointing (const Trajectory& aTrajectory, const Quaternion& aQuaternion)
255
+ Profile Profile::InertialPointing (const ostk::astrodynamics:: Trajectory& aTrajectory, const Quaternion& aQuaternion)
215
256
{
216
257
return {TransformModel::InertialPointing (aTrajectory, aQuaternion)};
217
258
}
@@ -303,12 +344,22 @@ std::function<Quaternion(const State&)> Profile::AlignAndConstrain(
303
344
case TargetType::GeodeticNadir:
304
345
return Profile::ComputeGeodeticNadirDirectionVector;
305
346
case TargetType::Trajectory:
347
+ case TargetType::TargetPosition:
306
348
{
307
- const Shared<const TrajectoryTarget> trajectoryTargetSPtr =
349
+ const Shared<const TrajectoryTarget> targetPositionSPtr =
308
350
std::static_pointer_cast<const TrajectoryTarget>(aTargetSPtr);
309
- return [trajectoryTargetSPtr ](const State& aState) -> Vector3d
351
+ return [targetPositionSPtr ](const State& aState) -> Vector3d
310
352
{
311
- return Profile::ComputeTargetDirectionVector (aState, trajectoryTargetSPtr->trajectory );
353
+ return Profile::ComputeTargetDirectionVector (aState, targetPositionSPtr->trajectory );
354
+ };
355
+ }
356
+ case TargetType::TargetVelocity:
357
+ {
358
+ const Shared<const TrajectoryTarget> targetVelocitySPtr =
359
+ std::static_pointer_cast<const TrajectoryTarget>(aTargetSPtr);
360
+ return [targetVelocitySPtr](const State& aState) -> Vector3d
361
+ {
362
+ return Profile::ComputeTargetVelocityVector (aState, targetVelocitySPtr->trajectory );
312
363
};
313
364
}
314
365
case TargetType::Sun:
@@ -411,20 +462,32 @@ Vector3d Profile::ComputeGeodeticNadirDirectionVector(const State& aState)
411
462
return ITRF_GCRF_transform.applyToVector (nadir).normalized ();
412
463
}
413
464
414
- Vector3d Profile::ComputeTargetDirectionVector (const State& aState, const Trajectory& aTrajectory)
465
+ Vector3d Profile::ComputeTargetDirectionVector (const State& aState, const ostk::astrodynamics:: Trajectory& aTrajectory)
415
466
{
416
- if (!aTrajectory.isDefined ())
417
- {
418
- throw ostk::core::error::runtime::Undefined (" Trajectory" );
419
- }
420
-
421
467
const Vector3d targetPositionCoordinates =
422
468
aTrajectory.getStateAt (aState.accessInstant ()).inFrame (Frame::GCRF ()).getPosition ().accessCoordinates ();
423
469
const Vector3d satellitePositionCoordinates = aState.getPosition ().accessCoordinates ();
424
470
425
471
return (targetPositionCoordinates - satellitePositionCoordinates).normalized ();
426
472
}
427
473
474
+ Vector3d Profile::ComputeTargetVelocityVector (const State& aState, const ostk::astrodynamics::Trajectory& aTrajectory)
475
+ {
476
+ const Transform ITRF_GCRF_transform = Frame::ITRF ()->getTransformTo (Frame::GCRF (), aState.accessInstant ());
477
+
478
+ const State slidingTargetState_GCRF = aTrajectory.getStateAt (aState.accessInstant ());
479
+ const State slidingTargetState_ITRF = slidingTargetState_GCRF.inFrame (Frame::ITRF ());
480
+
481
+ const Vector3d relativePositionDirection =
482
+ (slidingTargetState_GCRF.getPosition ().getCoordinates () - aState.getPosition ().getCoordinates ()).normalized ();
483
+ const Vector3d relativeVelocityDirection =
484
+ ITRF_GCRF_transform.applyToVector (slidingTargetState_ITRF.getVelocity ().getCoordinates ()).normalized ();
485
+
486
+ const Vector3d relativeNormalDirection = relativePositionDirection.cross (relativeVelocityDirection).normalized ();
487
+
488
+ return relativeNormalDirection.cross (relativePositionDirection);
489
+ }
490
+
428
491
Vector3d Profile::ComputeCelestialDirectionVector (const State& aState, const Celestial& aCelestial)
429
492
{
430
493
const Vector3d celestialPositionCoordinates =
0 commit comments