[][src]Function cdshealpix::best_starting_depth

pub fn best_starting_depth(d_max_rad: f64) -> u8

Returns the the smallest depth (in [0, 29]) at which a shape having the given largest distance from its center to a border overlaps a maximum of 9 cells (the cell containing the center of the shape plus the 8 neighbouring cells).
Info: internally, unrolled binary search loop on 30 pre-computed values (one by depth). @return -1 if the given distance is very large (> ~48deg), else returns the smallest depth (in [0, 29]) at which a shape having the given largest distance from its center to a border overlaps a maximum of 9 cells (the cell containing the center of the shape plus the 8 neighbouring cells).

Input

  • d_max_rad largest possible distance, in radians, between the center and the border of a shape

Output

  • depth = the smallest depth (in [0, 29]) at which a shape having the given largest distance from its center to a border overlaps a maximum of 9 cells (the cell containing the center of the shape plus the 8 neighbouring cells).

Panics

If the given distance is very large (> ~48deg), this function is not valid since the 12 base cells could be overlaped by the shape (see has_best_starting_depth). Thus it panics.

Examples

use cdshealpix::{best_starting_depth};
use std::f64::consts::PI;

assert_eq!(0, best_starting_depth(PI / 4f64)); // 45 deg
assert_eq!(5, best_starting_depth(0.0174533)); //  1 deg
assert_eq!(7, best_starting_depth(0.0043632)); // 15 arcmin
assert_eq!(9, best_starting_depth(0.0013));    // 4.469 arcmin
assert_eq!(15, best_starting_depth(1.454E-5)); // 3 arcsec
assert_eq!(20, best_starting_depth(6.5E-7));   // 0.134 arcsec
assert_eq!(22, best_starting_depth(9.537E-8)); // 20 mas