Skip to content

Commit

Permalink
ECF to ECI convertion.
Browse files Browse the repository at this point in the history
  • Loading branch information
xclud committed Feb 17, 2024
1 parent 5165109 commit 263fa69
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 12 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
## [2.0.7]

* ECF to ECI convertion.

## [2.0.6]

* Julian to DateTime convertion.

## [2.0.5]

* Julian constructor is public.
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,12 @@ Then, in your code import:
```dart
import 'package:latlng/latlng.dart';
```

## Features

* Julian date and time.
* ECI and ECF Calculations.
* Look Angle Calculation.
* Ground Track.
* WGS84 and WGS72.
* Projection to Tile Index.
33 changes: 23 additions & 10 deletions lib/src/ecef.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,32 @@ class EarthCenteredEarthFixed {
/// Z Coordinate.
final double z;

EarthCenteredEarthFixed operator +(EarthCenteredEarthFixed other) {
final dx = x + other.x;
final dy = x + other.y;
final dz = x + other.z;
/// Convert this ECF to ECI.
EarthCenteredInertial toEci(Angle gmst) {
// ccar.colorado.edu/ASEN5070/handouts/coordsys.doc
//
// [X] [C -S 0][X]
// [Y] = [S C 0][Y]
// [Z]eci [0 0 1][Z]ecf
//
var dx = x * cos(gmst.radians) - y * sin(gmst.radians);
var dy = x * sin(gmst.radians) + y * cos(gmst.radians);
var dz = z;

return EarthCenteredInertial(dx, dy, dz);
}

/// Convert this ECF to ECI.
EarthCenteredInertial toEciByDateTime(DateTime utc) =>
toEci(utc.toUtc().gsmt);

return EarthCenteredEarthFixed(dx, dy, dz);
/// Sum of two ECFs.
EarthCenteredEarthFixed operator +(EarthCenteredEarthFixed other) {
return EarthCenteredEarthFixed(x + other.x, y + other.y, z + other.z);
}

/// Sub of two ECFs.
EarthCenteredEarthFixed operator -(EarthCenteredEarthFixed other) {
final dx = x - other.x;
final dy = x - other.y;
final dz = x - other.z;

return EarthCenteredEarthFixed(dx, dy, dz);
return EarthCenteredEarthFixed(x - other.x, y - other.y, z - other.z);
}
}
8 changes: 8 additions & 0 deletions lib/src/eci.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ class EarthCenteredInertial {
/// Z Coordinate.
final double z;

EarthCenteredInertial operator +(EarthCenteredInertial other) {
return EarthCenteredInertial(x + other.x, y + other.y, z + other.z);
}

EarthCenteredInertial operator -(EarthCenteredInertial other) {
return EarthCenteredInertial(x - other.x, y - other.y, z - other.z);
}

/// Converts this ECI object to ECF.
EarthCenteredEarthFixed toEcf(Angle gmst) {
final s = sin(gmst.radians);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: latlng
description: GeoJSON, Geodesy and Geographical calculations for Dart. Provides LatLong and Mercator projection (EPSG4326).
version: 2.0.6
version: 2.0.7
repository: https://github.com/xclud/dart_latlng
homepage: https://pwa.ir

Expand Down

0 comments on commit 263fa69

Please sign in to comment.