Skip to content

Commit 47a583c

Browse files
Fix/integrator (#311)
* Add geosynchronous orbit computation and validation for longitude and latitude * Bump version to 9.0.0-preview-4 for IO.Astrodynamics and 0.9.0.0-preview-4 for CLI
1 parent 351f6f8 commit 47a583c

4 files changed

Lines changed: 34 additions & 3 deletions

File tree

IO.Astrodynamics.Net/IO.Astrodynamics.CLI/IO.Astrodynamics.CLI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<FileVersion>0.0.1</FileVersion>
1010
<PackAsTool>true</PackAsTool>
1111
<ToolCommandName>astro</ToolCommandName>
12-
<Version>0.9.0.0-preview-3</Version>
12+
<Version>0.9.0.0-preview-4</Version>
1313
<Title>Astrodynamics command line interface</Title>
1414
<Authors>Sylvain Guillet</Authors>
1515
<Description>This CLI allows end user to exploit IO.Astrodynamics framework </Description>

IO.Astrodynamics.Net/IO.Astrodynamics.Tests/Body/CelestialBodyTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,21 @@ public void GeosynchronousOrbit2()
270270
Assert.Equal(new Vector3(-1171.3783810266016, -2842.7805399479103, 2.354430257176734), orbit.ToStateVector().Velocity, TestHelpers.VectorComparer);
271271
}
272272

273+
[Fact]
274+
public void GeosynchronousOrbitThrowsOnInvalidLongitude()
275+
{
276+
var epoch = new TimeSystem.Time(new DateTime(2021, 1, 1, 0, 0, 0, DateTimeKind.Unspecified), TimeFrame.TDBFrame);
277+
Assert.Throws<ArgumentOutOfRangeException>(() => TestHelpers.EarthAtJ2000.GeosynchronousOrbit(4.0, 0.0, epoch));
278+
Assert.Throws<ArgumentOutOfRangeException>(() => TestHelpers.EarthAtJ2000.GeosynchronousOrbit(-4.0, 0.0, epoch));
279+
}
280+
281+
[Fact]
282+
public void GeosynchronousOrbitThrowsOnInvalidLatitude()
283+
{
284+
var epoch = new TimeSystem.Time(new DateTime(2021, 1, 1, 0, 0, 0, DateTimeKind.Unspecified), TimeFrame.TDBFrame);
285+
Assert.Throws<ArgumentOutOfRangeException>(() => TestHelpers.EarthAtJ2000.GeosynchronousOrbit(0.0, 2.0, epoch));
286+
Assert.Throws<ArgumentOutOfRangeException>(() => TestHelpers.EarthAtJ2000.GeosynchronousOrbit(0.0, -2.0, epoch));
287+
}
273288

274289
[Fact]
275290
public void TrueSolarDayJan()

IO.Astrodynamics.Net/IO.Astrodynamics/Body/CelestialBody.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,16 +244,32 @@ public double AngularVelocity(Time epoch)
244244
return (2.0 * Constants.PI) / siderealRotationPeriod.TotalSeconds;
245245
}
246246

247+
/// <summary>
248+
/// Computes the Keplerian elements for a geosynchronous orbit at the specified longitude and latitude.
249+
/// The latitude parameter defines the orbital inclination — for non-zero latitude, the satellite follows
250+
/// an inclined geosynchronous orbit tracing a figure-eight ground track. The specified (longitude, latitude)
251+
/// is the sub-satellite point only at the given epoch.
252+
/// </summary>
253+
/// <param name="longitude">Planetocentric longitude in radians, in range [-π, π].</param>
254+
/// <param name="latitude">Planetocentric latitude in radians, in range [-π/2, π/2]. Defines the orbital inclination.</param>
255+
/// <param name="epoch">The epoch at which to compute the orbit.</param>
256+
/// <returns>Keplerian elements for the geosynchronous orbit.</returns>
257+
/// <exception cref="ArgumentOutOfRangeException">Thrown when longitude or latitude is out of range.</exception>
247258
public KeplerianElements GeosynchronousOrbit(double longitude, double latitude, Time epoch)
248259
{
260+
if (longitude < -Constants.PI || longitude > Constants.PI)
261+
throw new ArgumentOutOfRangeException(nameof(longitude), longitude, "Longitude must be in range [-π, π] radians.");
262+
if (latitude < -Constants.PI2 || latitude > Constants.PI2)
263+
throw new ArgumentOutOfRangeException(nameof(latitude), latitude, "Latitude must be in range [-π/2, π/2] radians.");
264+
249265
var sideralRotation2 = System.Math.Pow(SideralRotationPeriod(epoch).TotalSeconds, 2);
250266
var radius = System.Math.Cbrt((GM * sideralRotation2) / (4 * Constants.PI * Constants.PI));
251267
var bodyfFixedCoordinates = new Planetocentric(longitude, latitude, radius).ToCartesianCoordinates();
252268
var icrfPos = bodyfFixedCoordinates.Rotate(Frame.ToFrame(Frame.ICRF, epoch).Rotation);
253269
var icrfRot = Vector3.VectorZ.Rotate(Frame.ToFrame(Frame.ICRF, epoch).Rotation);
254270
var inertialVelocity = icrfRot.Cross(icrfPos).Normalize() * System.Math.Sqrt(GM / radius);
255271
var sv = new StateVector(icrfPos, inertialVelocity, this, epoch, Frame.ICRF);
256-
return new KeplerianElements(radius, 0.0, sv.Inclination(), sv.AscendingNode(), (sv.ArgumentOfPeriapsis() + sv.MeanAnomaly()) % Constants._2PI, 0.0, this, epoch, sv.Frame);
272+
return new KeplerianElements(radius, 0.0, sv.Inclination(), sv.AscendingNode(), sv.ArgumentOfPeriapsis() + sv.MeanAnomaly(), 0.0, this, epoch, sv.Frame);
257273
}
258274

259275
/// <summary>

IO.Astrodynamics.Net/IO.Astrodynamics/IO.Astrodynamics.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<!-- NuGet package metadata (replaces IO.Astrodynamics.nuspec) -->
1414
<PackageId>IO.Astrodynamics</PackageId>
15-
<Version>9.0.0-preview-3</Version>
15+
<Version>9.0.0-preview-4</Version>
1616
<Authors>Sylvain Guillet</Authors>
1717
<Copyright>Sylvain Guillet</Copyright>
1818
<Title>IO Astrodynamics framework</Title>

0 commit comments

Comments
 (0)