Struct bcar::PSlot[][src]

pub struct PSlot {
    pub border: [Point; 4],
}

Parking slot structure.

Examples

let ps = bcar::PSlot::new_phwl(bcar::Point::new(0.0, 0.0), 0.0, 2.2, 6.86);
let def_ps = bcar::PSlot::default();
assert!(ps.border[0].x - def_ps.border[0].x < 0.00001);
assert!(ps.border[0].y - def_ps.border[0].y < 0.00001);
assert!(ps.border[1].x - def_ps.border[1].x < 0.00001);
assert!(ps.border[1].y - def_ps.border[1].y < 0.00001);
assert!(ps.border[2].x - def_ps.border[2].x < 0.00001);
assert!(ps.border[2].y - def_ps.border[2].y < 0.00001);
assert!(ps.border[3].x - def_ps.border[3].x < 0.00001);
assert!(ps.border[3].y - def_ps.border[3].y < 0.00001);

Fields

border: [Point; 4]

Implementations

impl PSlot[src]

pub fn new(border: [Point; 4]) -> PSlot[src]

pub fn new_phwl(p: Point, h: f64, w: f64, l: f64) -> PSlot[src]

Return new parking slot

Arguments

  • p – Parking slot first point.
  • h – Parking slot heading.
  • w – Parking slot width.
  • l – Parking slot length

pub fn default() -> PSlot[src]

Return default PSlot.

Examples

let ps = bcar::PSlot::default();
let p1 = bcar::Point::default();
let p2 = bcar::Point::new(0.0, -2.2);
let p3 = bcar::Point::new(6.86, -2.2);
let p4 = bcar::Point::new(6.86, 0.0);
assert!(ps.border[0].x - p1.x < 0.00001);
assert!(ps.border[0].y - p1.y < 0.00001);
assert!(ps.border[1].x - p2.x < 0.00001);
assert!(ps.border[1].y - p2.y < 0.00001);
assert!(ps.border[2].x - p3.x < 0.00001);
assert!(ps.border[2].y - p3.y < 0.00001);
assert!(ps.border[3].x - p4.x < 0.00001);
assert!(ps.border[3].y - p4.y < 0.00001);

pub fn heading(&self) -> f64[src]

Return the heading of the parking slot.

The heading is given by the direction from the first point to the last point.

Examples

let ps = bcar::PSlot::default();
assert!(ps.heading() - 0.0 < 0.00001);

pub fn length(&self) -> f64[src]

Return the length of the parking slot.

Examples

let ps = bcar::PSlot::default();
assert!(ps.length() - 6.86 < 0.00001);

pub fn width(&self) -> f64[src]

Return the width of the parking slot.

Examples

let ps = bcar::PSlot::default();
assert!(ps.width() - 2.6 < 1e-10);

pub fn parallel(&self) -> bool[src]

Return if the parking slot is parallel.

If not, the parking slot is perpendicular.

Examples

let ps = bcar::PSlot::default();
assert!(ps.parallel());

pub fn right(&self) -> bool[src]

Return if the parking slot is on the right side.

Right side of line given by the first and the last point.

Examples

let ps = bcar::PSlot::default();
assert!(ps.right());

pub fn inside(&self, p: Point) -> bool[src]

Return if the Point p is inside the parking slot.

See https://en.wikipedia.org/wiki/Even%E2%80%93odd_rule.

Examples

let ps = bcar::PSlot::default();
assert!(ps.inside(bcar::Point::new(0.1, -0.1)));
assert!(ps.inside(bcar::Point::new(0.1, -2.1)));
assert!(ps.inside(bcar::Point::new(6.85, -2.1)));
assert!(ps.inside(bcar::Point::new(6.85, -0.1)));

Trait Implementations

impl Clone for PSlot[src]

impl Copy for PSlot[src]

impl Debug for PSlot[src]

impl PartialEq<PSlot> for PSlot[src]

impl StructuralPartialEq for PSlot[src]

Auto Trait Implementations

impl RefUnwindSafe for PSlot

impl Send for PSlot

impl Sync for PSlot

impl Unpin for PSlot

impl UnwindSafe for PSlot

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.