From 8cc798b87aa297398f1149a299c1b9d497b73e1e Mon Sep 17 00:00:00 2001 From: Sulaiman Ghori Date: Tue, 10 Sep 2024 16:13:01 -0700 Subject: [PATCH] :twisted_rightwards_arrows: (Merge) Finished merge, updated README, interface, etc --- Cargo.lock | 22 ++-- Cargo.toml | 3 +- README.md | 239 +++++++++++------------------------- pyproject.toml | 2 +- src/bin/data-transformer.rs | 13 -- src/coords.rs | 93 -------------- src/fov.rs | 31 +++-- src/lib.rs | 108 ++++++++++++---- src/{bin => }/main.rs | 28 +++-- src/parsing_utils.rs | 5 +- src/rendering.rs | 12 +- src/star.rs | 9 -- src/types/star.rs | 2 +- 13 files changed, 220 insertions(+), 347 deletions(-) delete mode 100644 src/bin/data-transformer.rs delete mode 100644 src/coords.rs rename src/{bin => }/main.rs (88%) delete mode 100644 src/star.rs diff --git a/Cargo.lock b/Cargo.lock index ddeaea2..c746d13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -71,9 +71,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8" [[package]] name = "approx" @@ -168,9 +168,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773d90827bc3feecfb67fab12e24de0749aad83c74b9504ecde46237b5cd24e2" +checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" [[package]] name = "byteorder" @@ -186,9 +186,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] name = "cc" -version = "1.1.16" +version = "1.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9d013ecb737093c0e86b151a7b837993cf9ec6c502946cfb44bedc392421e0b" +checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" dependencies = [ "jobserver", "libc", @@ -1038,18 +1038,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -1122,7 +1122,7 @@ dependencies = [ [[package]] name = "starfinder" -version = "1.0.0" +version = "1.1.0" dependencies = [ "clap", "csv", diff --git a/Cargo.toml b/Cargo.toml index dc5b1a6..a6b3dad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,7 @@ [package] name = "starfinder" -version = "1.0.0" +version = "1.1.0" edition = "2021" -default-run = "main" license-file = "LICENSE" description = "starfinder is a Rust & Python package that provides functionality to read, process, and render star data from the Tycho-2 catalog. It's built with Rust for performance and exposes a Python API for ease of use." homepage = "https://github.com/djmango/starfinder" diff --git a/README.md b/README.md index 8e338e3..6a3197b 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,13 @@ `starfinder` is a Rust & Python package that provides functionality to read, process, and render star data from the Tycho-2 catalog. It's built with Rust for performance and exposes a Python API for ease of use. ## Setup -https://archive.eso.org/ASTROM/TYC-2/data/ -Download catalog.dat from there, put it in data/tycho2/ +1. Download the Tycho-2 catalog: + + - Visit https://archive.eso.org/ASTROM/TYC-2/data/ + - Download `catalog.dat` and place it in `data/tycho2/` + +2. Ensure your project structure looks like this: ``` . @@ -14,208 +18,115 @@ Download catalog.dat from there, put it in data/tycho2/ ├── README.md ├── data │ └── tycho2 -│ ├── catalog.dat -│ ├── index.dat -│ ├── suppl_1.dat -│ └── suppl_2.dat +│ ├── catalog.dat +│ ├── index.dat +│ ├── suppl_1.dat +│ └── suppl_2.dat ├── poetry.lock ├── pyproject.toml -├── src -│ └── bin -│ └── main.rs -│ └── data-transformer.rs +└── src ``` -# Run -To run the renderer with defaults -``` +## Running the Renderer + +### Using Cargo (Rust) + +To run the renderer with default settings: + +```bash cargo run ``` -To run the renderer with cmd arg overrides: -``` -cargo run -- --roll-deg 0.0 --fov-w-deg 75.0 --fov-h-deg 50.0 -``` -### Cmd args - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
██ Flag ████ Description ████ Default value ████ Notes ██
--source, -sThe source file to run`data/tycho2/catalog.dat`
--center-raFOV center point right ascension`180.0`In degrees
--center-decFOV center point declination`0.0`In degrees
--fov-wWidth of FOV`60.0`In degrees
--fov-hHeight of FOV`45.0`In degrees
--rollCritical for determining FOV and should always be specified. Camera sensor roll with respect to the celestial sphere.`0.0`In degrees
--max-magnitudeMaximum visual magnitude (lower is brighter).`12.0`This is essentially a filter, and dimmer stars will be ignored. A higher value can have an effect on performance at the cost of realism. Defaults to a maximum dimmer than Tycho2 dataset - i.e. shows all stars.
--lambda-nmTargeted wavelength - critical for airy disc rendering (nanometers). Default to visible spectrum`540.0`In nanometers. Currently unused - for future revision with PSF rendering
--pixel-size-mSimulated sensor physical pixel size`3e-6`In meters. Currently unused - for future revision with PSF rendering
--widthOutput image width. Should match sensor pixel count.`800`In pixels. Larger values will impact performance.
--heightOutput image height. Should match sensor pixel count.`600`In pixels. Larger values will impact performance.
--output, -oOutput filename`star_map.png`
- - -# C++ +To run with custom arguments: +```bash +cargo run -- --roll 0.0 --fov-w 75.0 --fov-h 50.0 ``` -mkdir build -cd build -cmake .. -make -render --max-ra=60 --min-dec=-30 --max-dec=30 --max-magnitude=11 --width=1000 --height=800 --output=example.png ../data/tycho2/catalog.dat -``` -## Installation +### Command-line Arguments + +| Flag | Description | Default | Notes | +| --------------- | -------------------------------- | ------------------------- | ----------------- | +| --source, -s | Source file path | `data/tycho2/catalog.dat` | | +| --center-ra | FOV center point right ascension | 180.0 | In degrees | +| --center-dec | FOV center point declination | 0.0 | In degrees | +| --fov-w | Width of FOV | 60.0 | In degrees | +| --fov-h | Height of FOV | 45.0 | In degrees | +| --roll | Camera sensor roll | 0.0 | In degrees | +| --max-magnitude | Maximum visual magnitude | 12.0 | Lower is brighter | +| --lambda-nm | Targeted wavelength | 540.0 | In nanometers | +| --pixel-size-m | Simulated sensor pixel size | 3e-6 | In meters | +| --width | Output image width | 800 | In pixels | +| --height | Output image height | 600 | In pixels | +| --output, -o | Output filename | `star_map.png` | | + +## Python Installation and Usage + +### Installation + +Ensure you have Python 3.8 or later, then: -To install `starfinder`, you can use pip: -https://pyo3.rs/v0.22.2/getting-started +`bash` +pip install starfinder + +```` +Or if you want to install the package in development mode: ```bash pipx install maturin maturin develop -``` - -Note: This package requires Python 3.8 or later. - -## Usage +```` -Here's a basic example of how to use `starfinder`: +### Basic Usage ```python from starfinder import StarCatalogArgs, process_star_catalog_py -# Create arguments for star catalog processing args = StarCatalogArgs( - file="path/to/your/tycho2_catalog.dat", - display_count=10, - min_ra=0.0, - max_ra=360.0, - min_dec=-90.0, - max_dec=90.0, + source="data/tycho2/catalog.dat", + center_ra=180.0, + center_dec=0.0, + fov_w=60.0, + fov_h=45.0, + roll=0.0, max_magnitude=6.0, + lambda_nm=540.0, + pixel_size_m=3e-6, width=800, height=600, output="star_map.png" ) -# Process the star catalog process_star_catalog_py(args) ``` -This will read the Tycho-2 catalog, filter the stars based on the given parameters, and generate a star map image. - ## API Reference ### `StarCatalogArgs` -This class represents the arguments for star catalog processing. - Parameters: -- `file` (str): Path to the Tycho-2 catalog file -- `display_count` (int): Number of stars to display in the console output (0 for all) -- `min_ra` (float): Minimum Right Ascension in degrees -- `max_ra` (float): Maximum Right Ascension in degrees -- `min_dec` (float): Minimum Declination in degrees -- `max_dec` (float): Maximum Declination in degrees -- `max_magnitude` (float): Maximum visual magnitude (lower is brighter) -- `width` (int): Output image width in pixels -- `height` (int): Output image height in pixels -- `output` (str): Output image file name +- `source` (str): Path to the Tycho-2 catalog file +- `center_ra` (float): Right Ascension of FOV center (degrees) +- `center_dec` (float): Declination of FOV center (degrees) +- `fov_w` (float): FOV width (degrees) +- `fov_h` (float): FOV height (degrees) +- `roll` (float): Camera roll (degrees) +- `max_magnitude` (float): Maximum visual magnitude +- `lambda_nm` (float): Targeted wavelength (nanometers) +- `pixel_size_m` (float): Sensor pixel size (meters) +- `width` (int): Output image width (pixels) +- `height` (int): Output image height (pixels) +- `output` (str): Output image filename ### `process_star_catalog_py(args: StarCatalogArgs) -> None` -This function processes the star catalog based on the provided arguments. +Processes the star catalog based on the provided arguments. -## Example +## Contributing -Here's a more detailed example that demonstrates how to use `starfinder` to create a star map of the brightest stars: +Contributions to `starfinder` are welcome! Please feel free to submit a Pull Request. -```python -from starfinder import StarCatalogArgs, process_star_catalog_py - -# Create arguments for star catalog processing -args = StarCatalogArgs( - file="tycho2_catalog.dat", - display_count=20, # Display info for the 20 brightest stars - min_ra=0.0, - max_ra=360.0, - min_dec=-90.0, - max_dec=90.0, - max_magnitude=3.0, # Only include stars brighter than magnitude 3 - width=1200, - height=800, - output="bright_stars_map.png" -) - -# Process the star catalog -process_star_catalog_py(args) - -print(f"Star map has been generated: {args.output}") -``` +## License -This script will create a star map of the brightest stars (magnitude 3.0 or brighter) across the entire sky, output information about the 20 brightest stars to the console, and save the star map as "bright_stars_map.png". +This project is licensed under the GPLv3 License - see the LICENSE file for details. diff --git a/pyproject.toml b/pyproject.toml index f9f57af..60d3aa3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "starfinder" -version = "1.0.0" +version = "1.1.0" description = "Generate images of the sky w/ accurate stars for star sensor simulation" requires-python = ">=3.8" classifiers = [ diff --git a/src/bin/data-transformer.rs b/src/bin/data-transformer.rs deleted file mode 100644 index 4613d48..0000000 --- a/src/bin/data-transformer.rs +++ /dev/null @@ -1,13 +0,0 @@ -use clap::Parser; -use starfield_renderer::parsing_utils::{parse_field, parse_star_record, parse_magnitude}; - -/// CLI Arguments -#[derive(Parser, Debug)] -#[command(author, version, about, long_about = None)] -pub struct Args { - -} - -fn main() -> Result<(), Box> { - Ok(()) -} diff --git a/src/coords.rs b/src/coords.rs deleted file mode 100644 index ec13572..0000000 --- a/src/coords.rs +++ /dev/null @@ -1,93 +0,0 @@ -use crate::fov::GRID_RESOLUTION; -use serde::{Deserialize, Serialize}; -use std::f64::consts::PI; -use std::hash::{Hash, Hasher}; - -#[derive(Debug, Deserialize, Serialize, Clone, Copy)] -pub struct StandardCoords { - pub x: f64, - pub y: f64, -} - -#[derive(Debug, Deserialize, Serialize, Clone, Copy)] -pub struct CartesianCoords { - pub x: f64, - pub y: f64, - pub z: f64, -} - -impl CartesianCoords { - pub fn to_equatorial(&self) -> EquatorialCoords { - let ra: f64; - - if self.y < 0.0 { - ra = (2.0 * PI) - self.x.acos(); - } else { - ra = self.x.acos(); - } - - EquatorialCoords { - ra, - dec: self.z.asin(), - } - } -} - - -#[derive(Debug, Deserialize, Serialize, Clone, Copy)] -pub struct EquatorialCoords { - pub ra: f64, - pub dec: f64, -} - -impl EquatorialCoords { - /// Calculate a point's standard coordinates on the plane tangent to the celestial sphere, whose - /// center point sits tangent to the sphere where the camera's central (z) axis meets it - pub fn to_standard(&self, center: EquatorialCoords) -> StandardCoords { - // Right ascension and declination of current object, in radians - let ra = self.ra; - let dec = self.dec; - // Right ascension and declination of center point of tangent plane, in radians - let cra = center.ra; - let cdec = center.dec; - - StandardCoords { - x: (dec.cos() * (ra - cra).sin()) - / ((cdec.cos() * dec.cos() * (ra - cra).cos()) + (dec.sin() * cdec.sin())), - y: ((cdec.sin() * dec.cos() * (ra - cra).cos()) - (cdec.cos() * dec.sin())) - / ((cdec.cos() * dec.cos() * (ra - cra).cos()) + (dec.sin() * cdec.sin())), - } - } - - pub fn to_cartesian(&self) -> CartesianCoords { - CartesianCoords { - x: self.ra.cos(), - y: self.ra.sin(), - z: self.dec.sin(), - } - } - - pub fn to_grid(&self) -> EquatorialCoords { - EquatorialCoords { - ra: ((self.ra / 2.0 * PI) * (1.0 - (2.0 * self.dec / PI).abs()) * GRID_RESOLUTION).round(), - dec: ((2.0 * self.dec / PI) * GRID_RESOLUTION).round(), - } - } -} - -impl PartialEq for EquatorialCoords { - fn eq(&self, other: &Self) -> bool { - self.ra == other.ra && self.dec == other.dec - } -} - -impl Eq for EquatorialCoords { -} - -impl Hash for EquatorialCoords { - fn hash(&self, state: &mut H) { - (self.ra as i32).hash(state); - (self.dec as i32).hash(state); - } -} - diff --git a/src/fov.rs b/src/fov.rs index f05337e..57cdd1c 100644 --- a/src/fov.rs +++ b/src/fov.rs @@ -1,8 +1,9 @@ -use crate::coords::{CartesianCoords, EquatorialCoords}; use nalgebra::{SMatrix, Vector3}; use std::collections::HashSet; use std::f64::consts::PI; +use crate::types::{CartesianCoords, EquatorialCoords}; + pub const GRID_RESOLUTION: f64 = 360.0; pub fn get_fov( @@ -29,14 +30,17 @@ pub fn get_fov( }; let fov_steps_w = ((fov_w / step_size).ceil() + 1.0) as i32; let fov_steps_h = ((fov_h / step_size).ceil() + 1.0) as i32; - let mut scatter_shot : Vec = Vec::new(); + let mut scatter_shot: Vec = Vec::new(); for y in 0..fov_steps_h { for x in 0..fov_steps_w { - scatter_shot.push(EquatorialCoords { - ra: bottom_left.ra + (x as f64 * step_size), - dec: bottom_left.dec + (y as f64 * step_size), - }.to_cartesian()); + scatter_shot.push( + EquatorialCoords { + ra: bottom_left.ra + (x as f64 * step_size), + dec: bottom_left.dec + (y as f64 * step_size), + } + .to_cartesian(), + ); } } @@ -73,7 +77,8 @@ pub fn get_fov( // Row 3 y_roll_axis.x * y_roll_axis.z * (1.0 - dec_dif.cos()) - (y_roll_axis.y * dec_dif.sin()), y_roll_axis.y * y_roll_axis.z * (1.0 - dec_dif.cos()) + (y_roll_axis.x * dec_dif.sin()), - y_roll_axis.z.powi(2) * (1.0 - dec_dif.cos()) + dec_dif.cos(),); + y_roll_axis.z.powi(2) * (1.0 - dec_dif.cos()) + dec_dif.cos(), + ); let z_roll = SMatrix::::new( // Row 1 c_cartesian.x.powi(2) * (1.0 - roll.cos()) + roll.cos(), @@ -95,12 +100,14 @@ pub fn get_fov( let vec: Vector3 = Vector3::new(p.x, p.y, p.z); let transformed = transform * vec; let grid_coord = CartesianCoords { - x: transformed[(0,0)], - y: transformed[(1,0)], - z: transformed[(2,0)], - }.to_equatorial().to_grid(); + x: transformed[(0, 0)], + y: transformed[(1, 0)], + z: transformed[(2, 0)], + } + .to_equatorial() + .to_grid(); final_grid.insert(grid_coord); - }; + } final_grid } diff --git a/src/lib.rs b/src/lib.rs index d2b9b23..2fa614e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,31 +1,38 @@ -use clap::Parser; -use pyo3::prelude::*; - -pub mod coords; pub mod fov; pub mod parsing_utils; pub mod rendering; -pub mod star; -pub mod star; +pub mod types; + +use crate::parsing_utils::read_stars; +use crate::rendering::render_stars; +use crate::types::EquatorialCoords; + +use clap::Parser; +use pyo3::prelude::*; +use std::time::Instant; #[pyclass] #[derive(Parser, Debug, Clone)] pub struct StarCatalogArgs { #[pyo3(get, set)] - pub file: String, + pub source: String, #[pyo3(get, set)] - pub display_count: usize, + pub center_ra: f64, #[pyo3(get, set)] - pub min_ra: f64, + pub center_dec: f64, #[pyo3(get, set)] - pub max_ra: f64, + pub fov_w: f64, #[pyo3(get, set)] - pub min_dec: f64, + pub fov_h: f64, #[pyo3(get, set)] - pub max_dec: f64, + pub roll: f64, #[pyo3(get, set)] pub max_magnitude: f64, #[pyo3(get, set)] + pub lambda_nm: f64, + #[pyo3(get, set)] + pub pixel_size_m: f64, + #[pyo3(get, set)] pub width: u32, #[pyo3(get, set)] pub height: u32, @@ -37,25 +44,29 @@ pub struct StarCatalogArgs { impl StarCatalogArgs { #[new] fn new( - file: String, - display_count: usize, - min_ra: f64, - max_ra: f64, - min_dec: f64, - max_dec: f64, + source: String, + center_ra: f64, + center_dec: f64, + fov_w: f64, + fov_h: f64, + roll: f64, max_magnitude: f64, + lambda_nm: f64, + pixel_size_m: f64, width: u32, height: u32, output: String, ) -> Self { Self { - file, - display_count, - min_ra, - max_ra, - min_dec, - max_dec, + source, + center_ra, + center_dec, + fov_w, + fov_h, + roll, max_magnitude, + lambda_nm, + pixel_size_m, width, height, output, @@ -63,9 +74,56 @@ impl StarCatalogArgs { } } +pub fn process_star_catalog(args: &StarCatalogArgs) -> Result<(), Box> { + let run_start = Instant::now(); + let center_ra = args.center_ra.to_radians(); + let center_dec = args.center_dec.to_radians(); + let roll = args.roll.to_radians(); + let fov_w = args.fov_w.to_radians(); + let fov_h = args.fov_h.to_radians(); + + // 1) Rotate FOV by specified roll + let get_fov_start = Instant::now(); + let center = EquatorialCoords { + ra: center_ra, + dec: center_dec, + }; + let rolled_fov = fov::get_fov(center, fov_w, fov_h, roll); + println!("Total FOV retrieval time: {:?}", get_fov_start.elapsed()); + + // 2) Read stars and filter against rolled_fov to create subset of stars in view of the image + let read_stars_start = Instant::now(); + let stars_in_fov = read_stars(&args.source, rolled_fov, args.max_magnitude)?; + println!( + "Total time to read and parse stars: {:?}", + read_stars_start.elapsed() + ); + + // 3) Render stars in FOV + let render_stars_start = Instant::now(); + let img = render_stars( + stars_in_fov, + args.width, + args.height, + center, + fov_w, + fov_h, + roll, + ); + img.save(&args.output)?; + println!( + "Total parse and write stars: {:?}", + render_stars_start.elapsed() + ); + + println!("Total run time elapsed: {:?}", run_start.elapsed()); + + Ok(()) +} + #[pyfunction] fn process_star_catalog_py(args: StarCatalogArgs) -> PyResult<()> { - process_star_catalog(args) + process_star_catalog(&args) .map_err(|e| PyErr::new::(e.to_string())) } diff --git a/src/bin/main.rs b/src/main.rs similarity index 88% rename from src/bin/main.rs rename to src/main.rs index dc90d00..41a548e 100644 --- a/src/bin/main.rs +++ b/src/main.rs @@ -1,11 +1,11 @@ use clap::Parser; -use starfinder::coords::{EquatorialCoords}; -use starfinder::fov::{get_fov}; -use starfinder::parsing_utils::{read_stars}; -use starfinder::rendering::{render_stars}; use std::path::PathBuf; use std::time::Instant; +use starfinder::fov::get_fov; +use starfinder::parsing_utils::read_stars; +use starfinder::rendering::render_stars; +use starfinder::types::EquatorialCoords; /// CLI Arguments #[derive(Parser, Debug)] @@ -108,13 +108,27 @@ fn main() -> Result<(), Box> { // 2) Read stars and filter against rolled_fov to create subset of stars in view of the image let read_stars_start = Instant::now(); let stars_in_fov = read_stars(args.source, rolled_fov, args.max_magnitude)?; - println!("Total time to read and parse stars: {:?}", read_stars_start.elapsed()); + println!( + "Total time to read and parse stars: {:?}", + read_stars_start.elapsed() + ); // 4) Render stars in FOV let render_stars_start = Instant::now(); - let img = render_stars(stars_in_fov, args.width, args.height, center, fov_w, fov_h, roll); + let img = render_stars( + stars_in_fov, + args.width, + args.height, + center, + fov_w, + fov_h, + roll, + ); img.save(&args.output)?; - println!("Total parse and write stars: {:?}", render_stars_start.elapsed()); + println!( + "Total parse and write stars: {:?}", + render_stars_start.elapsed() + ); println!("Total run time elapsed: {:?}", run_start.elapsed()); diff --git a/src/parsing_utils.rs b/src/parsing_utils.rs index fd926db..c41231b 100644 --- a/src/parsing_utils.rs +++ b/src/parsing_utils.rs @@ -1,11 +1,10 @@ use csv::ReaderBuilder; +use std::collections::HashSet; use std::fs::File; use std::io; -use std::collections::HashSet; use thiserror::Error; -use crate::coords::EquatorialCoords; -use crate::star::Star; +use crate::types::{EquatorialCoords, Star}; /// Errors that can occur during star catalog reading. #[derive(Error, Debug)] diff --git a/src/rendering.rs b/src/rendering.rs index 60b9c70..048909b 100644 --- a/src/rendering.rs +++ b/src/rendering.rs @@ -1,9 +1,7 @@ -use crate::coords::EquatorialCoords; -use crate::star::Star; use image::{ImageBuffer, Rgb}; use nalgebra::SMatrix; -// use spec_math::cephes64::j1; -// use std::f64::consts::PI; + +use crate::types::{EquatorialCoords, Star}; pub fn render_stars( stars: Vec, @@ -23,8 +21,10 @@ pub fn render_stars( .map(|s| s.mag) .fold(f64::NEG_INFINITY, f64::max); let z_roll_mat = SMatrix::::new( - fov_roll.cos(), -fov_roll.sin(), - fov_roll.sin(), fov_roll.cos(), + fov_roll.cos(), + -fov_roll.sin(), + fov_roll.sin(), + fov_roll.cos(), ); let pixel_ratio_w = width as f64 / fov_w; let pixel_ratio_h = height as f64 / fov_h; diff --git a/src/star.rs b/src/star.rs deleted file mode 100644 index 827c9e5..0000000 --- a/src/star.rs +++ /dev/null @@ -1,9 +0,0 @@ -use serde::{Deserialize, Serialize}; -use crate::coords::{EquatorialCoords}; - -/// Represents a star with its right ascension, declination, and magnitude. -#[derive(Debug, Deserialize, Serialize, Clone)] -pub struct Star { - pub coords: EquatorialCoords, - pub mag: f64, -} diff --git a/src/types/star.rs b/src/types/star.rs index d831de9..f99c3b6 100644 --- a/src/types/star.rs +++ b/src/types/star.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; -use crate::coords::EquatorialCoords; +use crate::types::EquatorialCoords; /// Represents a star with its right ascension, declination, and magnitude. #[derive(Debug, Deserialize, Serialize, Clone)]