Skip to main content

Field

Struct Field 

Source
pub struct Field { /* private fields */ }
Expand description

The angular extent of a frame.

Feed a Field to Constraint::within (circular membership sized by a RadiusPolicy) or Constraint::frame (rectangular membership) to build a search Constraint.

§Example

use target_match::{Field, Optics, RadiusPolicy};

let field = Field::from_optics(Optics {
    focal_mm: 800.0,
    pixel_um: (3.76, 3.76),
    binning: (1, 1),
    pixels: (6248, 4176),
})
.unwrap();

assert!(field.width().degrees() > 0.0);
assert!(field.height().degrees() > 0.0);
assert!(field.diagonal().degrees() > field.width().degrees());
assert!(field.pixel_scale().is_some(), "derived from optics, so plate scale is known");
let _radius = field.radius(RadiusPolicy::Circumscribed);

Implementations§

Source§

impl Field

Source

pub fn from_optics(o: Optics) -> Result<Self>

Derive a field from full optics.

Effective pixel size = pixel size × binning (per axis); pixel scale (arcsec/px) = effective pixel size (mm) / focal length (mm) × arcsec/radian; field extent = pixel scale × pixel count.

§Example
use target_match::{Field, Optics};

let field = Field::from_optics(Optics {
    focal_mm: 800.0,
    pixel_um: (3.76, 3.76),
    binning: (1, 1),
    pixels: (6248, 4176),
})
.unwrap();
let (sx, _) = field.pixel_scale().unwrap();
assert!((sx - 0.969).abs() < 1e-2, "≈0.969 arcsec/px");
§Errors

Error::InvalidOptics if any input is non-positive or non-finite.

Source

pub fn from_pixel_scale( scale_arcsec_px: (f64, f64), pixels: (u32, u32), ) -> Result<Self>

Build a field from a directly supplied pixel scale (arcsec/px, per axis) and sensor pixel counts.

§Example
use target_match::Field;

let field = Field::from_pixel_scale((0.9694, 0.9694), (6248, 4176)).unwrap();
assert_eq!(field.pixel_scale(), Some((0.9694, 0.9694)));
assert!((field.width().degrees() - 1.683).abs() < 1e-2);
§Errors

Error::InvalidOptics if any input is non-positive or non-finite.

Source

pub fn from_fov(width: Angle, height: Angle) -> Result<Self>

Build a field directly from its angular width and height (no optics; pixel scale is unknown).

§Example
use skymath::Angle;
use target_match::Field;

let field = Field::from_fov(Angle::from_degrees(2.0), Angle::from_degrees(1.0)).unwrap();
assert_eq!(field.width().degrees(), 2.0);
assert!(field.pixel_scale().is_none(), "no optics, so no plate scale");
§Errors

Error::InvalidOptics if width or height is non-positive or non-finite.

Source

pub fn width(self) -> Angle

Field width (x extent). See also height and diagonal.

§Example
use skymath::Angle;
use target_match::Field;

let field = Field::from_fov(Angle::from_degrees(2.0), Angle::from_degrees(1.0)).unwrap();
assert_eq!(field.width().degrees(), 2.0);
Source

pub fn height(self) -> Angle

Field height (y extent). See also width and diagonal.

§Example
use skymath::Angle;
use target_match::Field;

let field = Field::from_fov(Angle::from_degrees(2.0), Angle::from_degrees(1.0)).unwrap();
assert_eq!(field.height().degrees(), 1.0);
Source

pub fn diagonal(self) -> Angle

Diagonal field of view — hypot(width, height). Halved, this is the RadiusPolicy::Circumscribed search radius.

§Example
use skymath::Angle;
use target_match::Field;

let field = Field::from_fov(Angle::from_degrees(2.0), Angle::from_degrees(1.0)).unwrap();
assert!((field.diagonal().degrees() - 2.0_f64.hypot(1.0)).abs() < 1e-9);
Source

pub fn pixel_scale(self) -> Option<(f64, f64)>

Per-axis pixel scale (arcsec/px), if this field was built with a scale (via from_optics or from_pixel_scale) — None for from_fov.

§Example
use target_match::{Field, Optics};

let field = Field::from_optics(Optics {
    focal_mm: 800.0, pixel_um: (3.76, 3.76), binning: (1, 1), pixels: (6248, 4176),
})
.unwrap();
let (sx, sy) = field.pixel_scale().unwrap();
assert!((sx - 0.969).abs() < 1e-2);
assert_eq!(sx, sy);
Source

pub fn radius(self, policy: RadiusPolicy) -> Angle

Compute a search radius from this field under policy. Feeds Constraint::within, which calls this internally.

§Example
use skymath::Angle;
use target_match::{Field, RadiusPolicy};

let field = Field::from_fov(Angle::from_degrees(2.0), Angle::from_degrees(1.0)).unwrap();
let r = field.radius(RadiusPolicy::Explicit(Angle::from_degrees(3.0)));
assert!((r.degrees() - 3.0).abs() < 1e-9);

Trait Implementations§

Source§

impl Clone for Field

Source§

fn clone(&self) -> Field

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Field

Source§

impl Debug for Field

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Field

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Field

Source§

fn eq(&self, other: &Field) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Field

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Field

Auto Trait Implementations§

§

impl Freeze for Field

§

impl RefUnwindSafe for Field

§

impl Send for Field

§

impl Sync for Field

§

impl Unpin for Field

§

impl UnsafeUnpin for Field

§

impl UnwindSafe for Field

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.