Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/djmango/starfinder
Browse files Browse the repository at this point in the history
  • Loading branch information
dudewad committed Sep 11, 2024
2 parents b8c22d5 + 7d785e7 commit 1a32a7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/fov.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn get_fov(
ra: 180.0_f64.to_radians(),
dec: 0.0_f64.to_radians(),
};
let fov_size = fov_w.max(fov_h)/ (4.0 * PI);
let fov_size = fov_w.max(fov_h);
let ra_dif = center.ra - view_init_center.ra;
let dec_dif = center.dec - view_init_center.dec;
// Calculate FOV bounds in cartesian coords
Expand Down Expand Up @@ -107,7 +107,7 @@ pub fn get_fov(
z: transformed[(2, 0)],
}
.to_equatorial()
.to_grid(fov_size);
.to_grid(fov_size/(4.0*PI));
let next_coord = EquatorialCoords {
ra: grid_coord.ra + 1.0,
dec: grid_coord.dec,
Expand Down
15 changes: 8 additions & 7 deletions src/types/coords.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

use serde::{Deserialize, Serialize};
use std::f64::consts::PI;
use std::hash::{Hash, Hasher};
Expand All @@ -20,14 +21,14 @@ impl CartesianCoords {
let ra: f64;

if self.y < 0.0 {
ra = (2.0 * PI) - self.x.acos();
ra = (2.0 * PI) - self.x.clamp(-1.0, 1.0).acos();
} else {
ra = self.x.acos();
ra = self.x.clamp(-1.0, 1.0).acos();
}

EquatorialCoords {
ra,
dec: self.z.asin(),
dec: self.z.clamp(-1.0, 1.0).asin(),
}
}
}
Expand Down Expand Up @@ -67,9 +68,10 @@ impl EquatorialCoords {
}

pub fn to_grid(&self, fov_size: f64) -> EquatorialCoords {
let clamped_size = fov_size.clamp(0.02, 1.0);
EquatorialCoords {
ra: (self.ra / (2.0 * PI) * (1.0 - (2.0 * self.dec.abs() / PI)).powf(0.5) / fov_size).round(),
dec: (self.dec / 2.0 / fov_size).round(),
ra: (self.ra / (2.0 * PI) * (1.0 - (2.0 * self.dec.abs() / PI)).powf(0.5) / clamped_size).round(),
dec: (self.dec / (2.0 * PI) / clamped_size).round(),
}
}
}
Expand All @@ -88,5 +90,4 @@ impl Hash for EquatorialCoords {
(self.ra as i32).hash(state);
(self.dec as i32).hash(state);
}
}

}

0 comments on commit 1a32a7c

Please sign in to comment.