[][src]Struct polys::Reg

pub struct Reg { /* fields omitted */ }

Struct that represents a regular polygon.

Implementations

impl Reg[src]

pub fn new(l: f64, s: f64) -> Reg[src]

Returns a new Poly based on a given length l and sides s

Examples

let reg = polys::Reg::new(3, 5);

Trait Implementations

impl Debug for Reg[src]

impl Polygon for Reg[src]

fn area(&self) -> f64[src]

Gets the area of the Reg.

Examples

let reg  = polys::Reg::new(3, 5);
let area = reg.area();
assert_eq!(area, 15.484296605300704);

This can also be seen by comparing the Rect square and Reg implementations.

let square = polys::Rect::square(7).area();
let reg    = polys::Reg::new(7, 4) .area();
assert_eq!(square, reg);

fn peri(&self) -> f64[src]

Gets the perimeter of the Reg.

Examples

This works on a regular polygon where it has 5 of more sides.

let reg  = polys::Reg::new(3, 5);
let peri = reg.peri();
assert_eq!(peri, 15);

This can also be seen by comparing the Rect square and Reg implementations.

let square = polys::Rect::square(7).peri();
let reg    = polys::Reg::new(7, 4) .peri();
assert_eq!(square, reg);

Auto Trait Implementations

impl RefUnwindSafe for Reg

impl Send for Reg

impl Sync for Reg

impl Unpin for Reg

impl UnwindSafe for Reg

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, 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.