Struct oldnav_lib::navdata::geohash::Bounds [] [src]

pub struct Bounds {
    pub x_min: f64,
    pub x_max: f64,
    pub y_min: f64,
    pub y_max: f64,
}

A rectangular boundary

Fields

x_min: f64

x coordinate minimum

x_max: f64

x coordinate maximum

y_min: f64

y coordinate minimum

y_max: f64

y coordinate maximum

Methods

impl Bounds
[src]

fn new(x_min: f64, x_max: f64, y_min: f64, y_max: f64) -> Bounds

Constructor for Bounds

fn mid(&self) -> Vector2<f64>

Get the midpoint of this Bound

fn contains(&self, position: &Vector2<f64>) -> bool

Test whether a Vector2 position falls within this Bound

Example

A point which falls within a boundary:

use nalgebra::Vector2;
let b = Bounds::new(-21.0, 0.0, 2.0, 4.0);
let p1 = Vector2{x: -2.1, y: 2.45};

assert_eq!(true, b.contains(&p1));

A point that falls outside a boundary:

use nalgebra::Vector2;
let b = Bounds::new(-21.0, 0.0, 2.0, 4.0);
let p2: Vector2<f64> = Vector2{x: -100.0, y: 2.45};

assert_eq!(false, b.contains(&p2));

fn x_range(&self) -> f64

get the width of the boundary

fn y_range(&self) -> f64

get the height of the boundary

Trait Implementations

impl Copy for Bounds
[src]

impl Debug for Bounds
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl Clone for Bounds
[src]

fn clone(&self) -> Bounds

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more