# SGP in Rust
A simple implementation of the Simplified General Perturbations models (SGP8/SGP4) in Rust.
The results are validated against the original MATLAB implementations:
- [Original MATLAB SGP8 reference](<https://www.mathworks.com/matlabcentral/fileexchange/75492-sgp8/>)
- [Original MATLAB SGP4 reference](<https://www.mathworks.com/matlabcentral/fileexchange/62013-sgp4>)
## License
This project is licensed under the GNU General Public License v3.0 only (GPL-3.0-only). See the [LICENSE](LICENSE) file for details.
## Usage
Simple usage example.
1. `cargo add sgp` to add the dependency.
2. Use the following code to propagate a satellite using SGP4:
```rust
use sgp::sgp4;
use sgp::parse_tle_lines;
fn main() {
let tle_line1 = "1 25544U 98067A 20344.91667824 .00016717 00000-0 10270-3 0 9003";
let tle_line2 = "2 25544 51.6442 348.7413 0002393 85.0646 325.0584 15.49325993257145";
let sat = parse_tle_lines(tle_line1, tle_line2).expect("Error parsing TLE lines");
// Propagate to 60 minutes after epoch
let (position, velocity) = sgp4(60.0_f64, &sat);
println!("Position (km): {:?}", position);
println!("Velocity (km/s): {:?}", velocity);
}
```
For SGP8 usage, use `sgp::sgp8` just like `sgp::sgp4`.
## update
- 2025-11-23 21:50+8: remove accidentally added reference code in Matlab and related two reports.